Skip to content

feat(adapters): agent-sandbox authenticates to GKE with Google credentials - #138

Merged
reachjalil merged 2 commits into
pre-releasefrom
feat/agent-sandbox-gke-google-auth
Nov 21, 2026
Merged

reachjalil merged 2 commits into
pre-releasefrom
feat/agent-sandbox-gke-google-auth

Conversation

@reachjalil

Copy link
Copy Markdown
Member

A control plane outside a GKE cluster, like ours on the Compute Engine VMs in docs/deploy/gcp-vms.md, could reach GKE only with a long-lived Kubernetes service-account token. This adds auth: google: the agent-sandbox pool authenticates to the GKE API server as a Google service account, using the same token code gcp-sandboxes uses.

  • Credentials accepted: the VM's service account through the metadata server (the default when the pool has no credential), a service-account key, or workload identity federation that impersonates a service account.
  • Scopes: tokens carry cloud-platform and userinfo.email. GKE's docs say tokens "must include the userinfo.email OAuth scope"; without it RBAC sees the account's numeric ID, not the email it binds. Compute Engine leaves that scope out by default, so the guide now gives the control node --scopes=cloud-platform,userinfo-email.
  • Fail closed:
    • apiServer must be https://: the token opens every Google API its account may use.
    • Federation without service_account_impersonation_url is refused, since a federated identity has no email for RBAC to bind.
  • Token handling: a token the API server rejects (401) is dropped, only that token and at most every 10 s, so the next call fetches again.
  • Shared token code: Google token sources now take several scopes (comma-joined for the metadata server, a list for impersonation). The single-scope caller, gcp-sandboxes, is unchanged.
  • Docs: docs/providers/agent-sandbox.md covers setup. Use the DNS-based endpoint (public certificate, no CA file), give the service account roles/container.clusterViewer on the project, bind the Role to kind: User with the account's email, and allow egress to the metadata server and DNS.

Tests

  • A fake metadata server feeding the fake Kubernetes API checks the scopes asked for and that a rejected token is dropped and fetched again.
  • The config checks: no apiServer, http://, a bad auth value, federation without impersonation, and a credential that isn't Google's.
  • Impersonation is asked for a list of two scopes.
  • Invalidate drops only the rejected token, rate-limited.
  • Breaking the invalidation makes its test fail.
  • make verify and the site build pass.

Review: an independent review found the plain-http and federation gaps and the over-eager token drop, all fixed in the second commit. It found no credential in any error or log.

Not run: GKE. Also unverified is how the real metadata server treats a scopes list that includes scopes the VM lacks; it fails closed either way.

🤖 Generated with Claude Code

reachjalil and others added 2 commits November 20, 2026 16:33
…tials

auth: google makes an agent-sandbox pool send Google access tokens to a GKE
API server instead of a Kubernetes token: the VM's service account through
the metadata server (the default without a credential), a service-account
key, or workload identity federation, through cloudhttp.GoogleTokens. A
control plane on Compute Engine can then drive GKE pools without a
long-lived Kubernetes token.

Tokens carry cloud-platform and userinfo.email: GKE identifies an account
by email, which RBAC binds, only with userinfo.email. Google token sources
now take several scopes (comma-joined for the metadata server, a list for
impersonation), and a token the API server rejects (401) is dropped so the
next call fetches a new one. The Compute Engine guide gives the control
node the userinfo-email scope.

Tested with a fake metadata server and the fake API server; not run
against GKE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jalil <reachjalil@gmail.com>
…ion, and drops only the rejected token

Found by an independent review: a Google token could go to an http://
apiServer; a federation config without impersonation has no email for RBAC;
a 401 cleared whatever token was cached, on every call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jalil <reachjalil@gmail.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI passed at 890f77b.

@reachjalil
reachjalil merged commit 02d850d into pre-release Nov 21, 2026
23 checks passed
@reachjalil
reachjalil deleted the feat/agent-sandbox-gke-google-auth branch November 21, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant