The five layers
An agent on Kubernetes can draw on five distinct layers of identity. They answer different questions, and a production deployment usually needs several at once. Pick a layer to see which parts of the cluster are involved.
Layer 1 · ServiceAccount token
Which pod is this?
The kubelet asks the API server’s TokenRequest API for a token bound to this pod, with an audience and expiry from the pod spec, and writes it into a projected volume. It replaces the file before it expires. The token stops validating when the pod is deleted.
- Good for
- Calling the Kubernetes API, and as the starting credential for everything else here.
- Limit
- It names a ServiceAccount. Two agents that share one are indistinguishable.
Layer 2 · Federation
How do I reach things outside the cluster without a secret?
The agent presents its ServiceAccount token to a cloud token service or an authorization server. That service fetches the cluster’s public keys from its OIDC discovery endpoint, verifies the token, and matches issuer, subject and audience against a trust rule. It returns a short-lived credential for the outside world.
- Good for
- Cloud APIs, model providers, and any authorization server that accepts a platform token as a client assertion.
- Limit
- The trust rule is the whole boundary. One that matches any subject from the cluster lets every pod be your agent.
Layer 3 · Certificates and SPIFFE
How do two workloads prove themselves to each other?
Two routes to an X.509 identity. With Pod Certificates, the kubelet generates a key, files a PodCertificateRequest with a signer, and mounts the result. With SPIRE, a node agent attests the calling process over a local socket and hands it a SPIFFE certificate. Either way the workload gets a short-lived certificate, usually carrying a SPIFFE ID, and a trust bundle to verify peers.
- Good for
- Mutual TLS between agents, tools and gateways inside your infrastructure, across clusters and clouds.
- Limit
- Kubernetes ships the Pod Certificates API but no signer. And a certificate identifies the workload, never the user it is acting for.
Layer 4 · Gateway and mesh
Where is policy enforced?
Agent traffic leaves through a proxy the agent does not control: a mesh waypoint, an MCP-aware gateway, or an egress proxy. It can authenticate the agent by its workload identity, validate tokens as an MCP resource server, apply per-tool policy, exchange tokens for the next hop, and attach credentials to outbound calls so the agent never holds them.
- Good for
- Per-tool authorization, token exchange and credential injection without changing agent code.
- Limit
- It only governs traffic that goes through it. Pair it with a network policy that leaves no other way out.
Layer 5 · User delegation
Whose behalf is this request on?
None of the layers above says anything about a person. If the agent is doing work for a user, the user’s token arrives with the request and must travel separately from the workload identity. At each hop it is exchanged for a token aimed at the next service, with the user as subject and the agent as actor. Inside the cluster, a transaction token can carry the user and the approved request through every service.
- Good for
- Applying the user’s own permissions downstream, and audit logs that show both the person and the software.
- Limit
- It needs an authorization server that supports token exchange, and services that check audience instead of accepting whatever arrives.
Token exchange →Transaction tokens →Enterprise-managed (ID-JAG) →
The first four identify the workload: which pod, which service account, which certificate. Only the fifth identifies the person the workload is acting for. Treating a workload identity as if it were the user is the most common mistake in agent deployments, and the reason the last layer exists.
What ships in Kubernetes
The current stable release is v1.37 (August 2026); v1.38 is planned for December. Everything in the first group below is generally available in supported releases.
| Capability | Since | What it gives an agent |
|---|---|---|
| Bound ServiceAccount tokens (TokenRequest API, projected volumes) | GA v1.20; default for pods since v1.22 | A short-lived, audience-scoped JWT tied to one pod |
| ServiceAccount issuer discovery (OIDC) | GA v1.21 | Lets outside systems verify those tokens |
| Token ID and pod and node claims | GA v1.32 | Tokens traceable in audit logs to a pod and node |
| Structured authentication configuration | GA v1.34 | The API server accepts tokens from external issuers, with CEL claim mapping |
| External ServiceAccount token signing | GA v1.36 | Signing keys can live in a KMS or HSM |
| Pod Certificates | GA v1.37 | The kubelet obtains and rotates an X.509 certificate per pod |
| ClusterTrustBundle | GA v1.37 | Trust anchors distributed to pods as a projected volume |
| ServiceAccount tokens for image credential providers | Beta since v1.34 | Image pulls with workload identity instead of pull secrets |
| Constrained impersonation | Beta since v1.36 | Impersonation limited to specific resources and verbs |
Two things are worth knowing about the newest entries. Kubernetes 1.37 ships the Pod Certificates API without a signer: you install one. And there is no built-in SPIFFE identity or token-exchange feature in Kubernetes itself; those come from projects layered on top.
A baseline pod
The settings that matter most cost nothing: a dedicated service account, no default API token, and a token minted for one specific audience.
apiVersion: v1
kind: ServiceAccount
metadata:
name: research-agent # one per agent, never shared
namespace: agents
automountServiceAccountToken: false
---
apiVersion: v1
kind: Pod
metadata:
name: research-agent
namespace: agents
spec:
serviceAccountName: research-agent
automountServiceAccountToken: false # no Kubernetes API token unless needed
containers:
- name: agent
image: registry.example/research-agent:1.4.2
volumeMounts:
- name: identity
mountPath: /var/run/agent-identity
readOnly: true
volumes:
- name: identity
projected:
sources:
# A token for one consumer only. Read it fresh each time; it rotates.
- serviceAccountToken:
audience: https://sts.example
expirationSeconds: 3600
path: token
# v1.37+: an X.509 identity from an installed signer
- podCertificate:
signerName: example.com/agent-identity
keyType: ED25519
credentialBundlePath: credentialbundle.pem
- clusterTrustBundle:
signerName: example.com/agent-identity
path: trust-bundle.pem
One service account per agent. RBAC, federation trust rules and mesh policy all match on the service account. Two agents that share one are the same principal everywhere, and no downstream control can tell them apart.
Set the audience. The default pod token is addressed to the Kubernetes API server. Sending it anywhere else invites that system to replay it against your cluster. Ask for a separate token per consumer.
Verify the right way. An outside system checking the token against the cluster’s published keys learns that it is authentic and unexpired. It does not learn whether the pod still exists. Where that matters, the Kubernetes documentation says to use the TokenReview API.
Reaching the cloud
All three major clouds accept a pod’s ServiceAccount token in place of a stored key. The mechanics differ; the shape is the same as workload identity federation.
| Platform | Mechanism | In one line |
|---|---|---|
| GKE | Workload Identity Federation for GKE | IAM roles are granted directly to the Kubernetes service account as a federated principal; a node metadata server performs the exchange |
| EKS | EKS Pod Identity, or IAM Roles for Service Accounts | An association maps a namespace and service account to an IAM role; an agent on the node, or the STS web identity call, returns role credentials |
| AKS | Microsoft Entra Workload ID | The token is presented as a client assertion and matched against a federated identity credential on a managed identity |
Whatever the platform, the trust rule should pin the issuer, the audience, and the exact subject (system:serviceaccount:<namespace>:<name>). Wildcards in the subject are how one compromised pod becomes every pod.
The same exchange works with your own authorization server. Several accept a Kubernetes ServiceAccount token as a client assertion, which gives an agent an OAuth client identity with nothing to store.
Workload-to-workload
For calls between an agent and tools you run, the usual answer is mutual TLS with SPIFFE identities. There are now three ways to get the certificates.
- A service mesh. Istio and others issue each workload a SPIFFE identity derived from its service account and handle mutual TLS for you. In Istio’s ambient mode this happens in a per-node proxy with no sidecar.
- SPIRE. A node agent attests each calling process and issues SPIFFE credentials over the Workload API. More to operate, and more control: identities can span clusters and clouds, and selectors can include the container image.
- Pod Certificates. New and native. The kubelet handles the key and rotation; you supply the signer. The SPIFFE project has published a specification for reading credentials from files that is designed around this.
Mutual TLS authenticates. It does not authorize. Pair it with policy that names which identities may call which endpoints, or every workload in the trust domain can reach every other.
Where a gateway terminates TLS between agent and tool, the certificate does not arrive. That gap is what workload identity tokens with proof of possession are being standardized to close.
Gateways and policy
Much of what this site describes can be enforced at a proxy, without touching agent code. That is attractive when agents are built by many teams on many frameworks.
- agentgateway is an open-source proxy for model, MCP and agent-to-agent traffic. It can act as the OAuth resource server for MCP, apply per-tool rules or ask an external policy engine through AuthZEN, perform token exchange and the enterprise ID-JAG flow on the agent’s behalf, and run as an egress proxy. Istio can use it as a gateway or ambient waypoint, though that integration is marked experimental.
- Agent Router, the project formerly called Envoy AI Gateway, offers MCP routes with OAuth validation, claim-based authorization and per-backend credential injection.
- Kube Agentic Networking, a SIG Network subproject, is defining Kubernetes APIs for agent traffic policy, including tool-level MCP authorization and SPIFFE-based agent identity. Early releases only.
- A Kubernetes AI Gateway working group has proposed standardizing egress gateways with managed authentication and token injection for third-party AI APIs. Nothing has shipped.
A gateway controls only the traffic that passes through it. Add a NetworkPolicy that denies all other egress from agent pods, including the cloud metadata address, or the control is advisory.
Sandboxed agents
Agent Sandbox is a SIG Apps project that adds a Sandbox resource: an isolated, stateful, single-pod runtime for an agent, with templates, claims and pre-warmed pools. The project is at version 1.0, with an API still labeled v1beta1.
Its defaults are a good statement of what an agent pod should look like. Sandboxes created from a template do not mount a ServiceAccount token, and get a generated NetworkPolicy that allows the public internet while blocking private address ranges and cloud metadata endpoints. Isolation itself is delegated to a sandboxed container runtime such as gVisor or Kata.
It has no built-in credential broker. Credentials reach a sandbox the way they reach any pod, which for an agent executing untrusted code means you should bring your own: see sandboxes.
Checklist
- Each agent has its own ServiceAccount and namespace-scoped RBAC, or no Kubernetes API access at all.
- The default token is not mounted. Projected tokens name a specific audience.
- No long-lived API keys in Secrets where federation is available.
- Federation trust rules pin issuer, audience and exact subject.
- Agent pods can reach the network only through a gateway or egress proxy.
- Workload-to-workload calls use mutual TLS with an explicit allow policy.
- User delegation travels as its own token and is exchanged at each hop, never forwarded.
- An admission policy enforces the above, so a new agent cannot quietly skip it.