Kubernetes Workload Identity: Projected Tokens and OIDC to Cloud IAM
How pods can talk to AWS, GCP, and Azure with no static keys, using audience-bound projected ServiceAccount tokens and the cluster OIDC issuer.
Key takeaways
- Kubernetes workload identity replaces static cloud keys with short-lived, audience-bound projected ServiceAccount tokens.
- The kubelet mounts and rotates the token, and AWS, GCP or Azure validates it against your cluster's public OIDC issuer before issuing temporary credentials.
- Most failures come from a wrong audience, an unreachable issuer, or clock skew.
On this page
Kubernetes workload identity lets pods call AWS, GCP and Azure with no static keys. The kubelet mounts a short-lived projected ServiceAccount token bound to one audience, and the cloud's IAM validates it against your cluster's OIDC issuer, then exchanges it for temporary credentials. Configure the audience per cloud, publish the issuer, and delete the keys.
Verified against
Kubernetes 1.37 (stable release 1.37.2), against the kubernetes.io ServiceAccount and projected volume docs, the Amazon EKS IRSA and Pod Identity guides, the GKE Workload Identity Federation guide, and the AKS workload identity overview. Checked October 2026.
Every incident review we've sat through that started with "how did an attacker read our S3 bucket" ended in the same place: a long-lived access key sitting in a Kubernetes Secret, mounted into a pod, never rotated, and copied into three other namespaces because someone needed it fast. Static cloud credentials in a cluster are the worst kind of liability. They don't expire, they're readable by anyone with get secrets in the namespace, they end up in env dumps and crash logs, and when they leak you have no idea which of forty deployments actually used them.
The fix is to stop putting keys in the cluster at all. This is workload identity federation: the pod proves who it is with a token that expires in an hour, and the cloud exchanges it for real credentials. No secret to leak.
Projected ServiceAccount tokens
The old ServiceAccount token was a JWT with no expiry, stored in a Secret, mounted at a fixed path. It was a bearer token for the whole cluster lifetime. Projected tokens replace that. The kubelet requests a token from the API server on the pod's behalf, scopes it to a specific audience, gives it a TTL, and rotates it before it expires, all without a Secret object existing anywhere.
The volume looks like this:
# k8s/billing-worker/token-volume.yaml (pod spec fragment)
volumes:
- name: aws-token
projected:
sources:
- serviceAccountToken:
path: token
audience: sts.amazonaws.com
expirationSeconds: 3600
Three things matter here. audience binds the token to one relying party: a token minted for sts.amazonaws.com is rejected by GCP and vice versa. expirationSeconds sets the TTL; it defaults to one hour and must be at least 600 seconds. The kubelet rotates the file in place once the token is older than 80% of its TTL or older than 24 hours, and the docs are clear that the application is responsible for reloading it, which current cloud SDKs do by re-reading the path. And the token never touches etcd as a Secret. If a pod is compromised, the attacker gets a token good for at most an hour, usable against exactly one audience.
The cluster OIDC issuer
For any cloud to trust these tokens, it needs to fetch your cluster's signing keys. The API server exposes an OIDC discovery document at /.well-known/openid-configuration and a JWKS endpoint with the public keys. Check what your issuer URL is:
$ kubectl get --raw /.well-known/openid-configuration | jq .issuer
On EKS this is an oidc.eks.<region>.amazonaws.com/id/<hash> URL that AWS hosts for you. On self-managed clusters you configure it with --service-account-issuer on the API server, and you must publish the discovery and JWKS documents somewhere the cloud provider can reach over HTTPS. That last part trips people up: the issuer has to be publicly resolvable, or configured explicitly in the cloud's federation setup. A private issuer URL that only resolves inside your VPC will fail validation every time.
Federating the ServiceAccount to each cloud
The pattern is identical across providers: annotate the ServiceAccount, tell the cloud to trust system:serviceaccount:<namespace>:<name> as a subject, done.
AWS (IRSA). Create an IAM role with a trust policy tied to your OIDC provider, then annotate the SA:
# k8s/billing-worker/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: billing-worker
namespace: payments
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/billing-s3-reader
The role's trust policy conditions on <issuer>:aud equal to sts.amazonaws.com and <issuer>:sub equal to system:serviceaccount:payments:billing-worker. The EKS pod identity webhook sees the annotation and injects the projected token volume and AWS_WEB_IDENTITY_TOKEN_FILE for you. EKS Pod Identity (the newer approach) skips the OIDC provider entirely and uses an agent on the node, which is simpler to manage if you're all-in on EKS. As of October 2026 AWS documents that it only works for Linux pods on EC2 nodes (not Fargate, not Windows), so IRSA is still what you want for portability and mixed node types.
GCP (Workload Identity Federation for GKE). Google's current guide grants IAM roles directly to the Kubernetes ServiceAccount as a principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/my-project.svc.id.goog/subject/ns/payments/sa/billing-worker member, with no Google service account in between. Where a Google API doesn't support that yet, the documented alternative is to link the KSA to a Google service account:
$ gcloud iam service-accounts add-iam-policy-binding \
billing@my-project.iam.gserviceaccount.com \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:my-project.svc.id.goog[payments/billing-worker]"
# k8s/billing-worker/serviceaccount.yaml (GKE, linked-GSA mode)
metadata:
annotations:
iam.gke.io/gcp-service-account: billing@my-project.iam.gserviceaccount.com
Azure (Workload Identity). Create a federated credential on the app registration pointing at your issuer and the subject system:serviceaccount:payments:billing-worker, then annotate the ServiceAccount:
# k8s/billing-worker/serviceaccount.yaml (AKS)
metadata:
annotations:
azure.workload.identity/client-id: 00000000-0000-0000-0000-000000000000
The AKS docs also require the label azure.workload.identity/use: "true" on the pod template; only labeled pods are mutated by the webhook, and forgetting it is the most common reason nothing gets injected. The Azure side in more depth is in Azure workload identity federation without secrets.
A full manifest
Here's the SA plus a Deployment that mounts the token itself, which is what you do when the cloud SDK doesn't auto-inject:
# k8s/billing-worker/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: billing-worker
namespace: payments
spec:
replicas: 2
selector:
matchLabels: { app: billing-worker }
template:
metadata:
labels: { app: billing-worker }
spec:
serviceAccountName: billing-worker
containers:
- name: worker
image: registry.internal/billing-worker:1.9.2
env:
- name: AWS_ROLE_ARN
value: arn:aws:iam::111122223333:role/billing-s3-reader
- name: AWS_WEB_IDENTITY_TOKEN_FILE
value: /var/run/secrets/aws/token
volumeMounts:
- name: aws-token
mountPath: /var/run/secrets/aws
readOnly: true
volumes:
- name: aws-token
projected:
sources:
- serviceAccountToken:
path: token
audience: sts.amazonaws.com
expirationSeconds: 3600
Gotchas that will cost you an afternoon
Audience mismatch is the number one failure. The aud claim in the token must equal what the cloud's federation config expects: sts.amazonaws.com for AWS STS, api://AzureADTokenExchange for Azure. Get it wrong and you get an opaque "invalid identity token" with no hint which field is off.
Issuer reachability, as above: if the cloud can't GET your JWKS, nothing works, and the error rarely says so plainly.
Clock skew matters because these tokens are short-lived and validated on nbf/exp. If your nodes drift more than a couple of minutes from the cloud's clock, valid tokens get rejected as expired or not-yet-valid. Run NTP and mean it.
Finally, don't set expirationSeconds too low chasing security theater. The API rejects anything under 600 seconds, and short TTLs add refresh churn for no real gain since the token is already single-audience and single-pod. Cluster admins can also cap the maximum with --service-account-max-token-expiration, so a 24-hour request may come back shorter. If you want cryptographic identity that travels across service meshes rather than just to cloud IAM, look at SPIFFE instead; it's the right tool for in-mesh mTLS.
Questions people ask
What is the difference between IRSA and EKS Pod Identity?
IRSA federates through an IAM OIDC identity provider for your cluster's issuer, and the role's trust policy names the ServiceAccount as the subject. EKS Pod Identity skips the OIDC provider: you create a Pod Identity association and an agent on the node hands out credentials. Pod Identity is less IAM plumbing, but it only runs on Linux EC2 nodes, so Fargate and Windows pods still need IRSA.
Why does my cloud reject the projected ServiceAccount token?
Check three things in order. Decode the token and confirm aud matches the cloud's expected audience and sub matches system:serviceaccount:<namespace>:<name> exactly. Confirm the cloud can fetch your issuer's discovery document and JWKS over public HTTPS. Then check node clock skew, since exp and nbf are validated strictly. Wrong audience is the usual culprit.
Do projected ServiceAccount tokens rotate automatically?
Yes. The kubelet requests a new token once the current one is older than 80% of its TTL or older than 24 hours, and rewrites the mounted file. Your application must re-read the file rather than caching the token at startup. Current AWS, Google and Azure SDKs read the token path on each credential refresh, so this only bites hand-rolled clients.
The call we'd make
Kill every static cloud key in your clusters and federate through the OIDC issuer. On EKS, use IRSA unless you're certain you'll never leave EKS, in which case Pod Identity is less to babysit. Set token TTL to 3600, pin the audience explicitly per cloud, and put a CI check in place that fails any manifest mounting an AWS or GCP key from a Secret. The migration is a few hours per workload; the alternative is explaining to an auditor why a five-year-old access key was still valid.
Sources
Cite this article
Kiril Urbonas (2026). Kubernetes Workload Identity: Projected Tokens and OIDC to Cloud IAM. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/kubernetes-workload-identity-projected-tokens-oidc
[Kubernetes Workload Identity: Projected Tokens and OIDC to Cloud IAM](https://www.devopsness.com/blog/kubernetes-workload-identity-projected-tokens-oidc) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
kaniko CVE-2026-105769: Lookalike ACR Hosts Get Your Azure Token. Rebuild on v1.25.20
A FROM line pointing at a host like x.azurecr.io.attacker.com is enough to make kaniko hand the build's Entra ID token to that host. Which kaniko forks and images are affected, how to find Azure identities in your build pods, and what to rotate.
Sign Container Images With Cosign: Keyless GitHub Actions Workflow, SBOM and In-Cluster Checks
One workflow that builds, signs keylessly with GitHub OIDC, attaches an SBOM and SLSA provenance, plus the Kyverno policy that refuses anything unsigned. Copy it, change three names, ship it.
GitLab CVE-2026-110264: A Second CVSS 10 RCE in Nine Days. Patch to 19.5.1
An unauthenticated regex-compiler RCE reaching back to GitLab 7.0, no workaround, and backports on older branches that fix only the critical bug. The exact version per branch and the commands to get there.
You might have missed
Evergreen posts worth revisiting.