GKE interview question · Most asked
How does Workload Identity Federation for GKE work?
How it works
Summary
It lets a Kubernetes ServiceAccount act as a Google Cloud identity without keys: the GKE metadata server exchanges the Pod's Kubernetes token for short-lived Google credentials. You grant IAM roles directly to the Kubernetes ServiceAccount's principal (or bind it to impersonate a Google service account).
Longer Answer
- Principal format:
principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/PROJECT_ID.svc.id.goog/subject/ns/NAMESPACE/sa/KSA_NAME. - Enabled by default on Autopilot; enable it on Standard clusters and node pools.
- One Kubernetes ServiceAccount per workload, least-privilege roles.
- Replaces mounting JSON keys as Secrets, which leak easily.
Key Points
- Pods get Google credentials without keys.
- Grant roles to the Kubernetes ServiceAccount principal.
- On by default in Autopilot.
- Per-workload ServiceAccounts.
Explanation
What interviewers look for
Keyless workload authentication and least privilege per workload.
More GKE questions
- GKE Autopilot or Standard: what's the difference, and how do you choose?
- How do you upgrade GKE clusters safely?
- Explain GKE networking: VPC-native clusters, Dataplane V2 and private clusters.
- Pods on GKE can't pull images from Artifact Registry. How do you troubleshoot it?
- How do you control costs on GKE?
- How do you secure a GKE cluster?
- A GKE workload is evicted repeatedly on Autopilot. What could be happening?
- How would you run a multi-region application on GKE?