What is the correct sequential order of steps required to configure GKE Workload Identity so that an application running in a Kubernetes namespace can access Google Cloud resources using a dedicated Google Service Account (GSA) without relying on static service account keys?
- 1Enable Workload Identity on the GKE cluster to establish the workload identity pool for the Google Cloud project.
- 2Create a Google Service Account (GSA) and grant it the specific IAM roles required for the target GCP resources.
- 3Create a Kubernetes Service Account (KSA) in the dedicated GKE namespace where the workload resides.
- 4Grant the `roles/iam.workloadIdentityUser` role on the GSA to the KSA member identity (`serviceAccount:PROJECT_ID.svc.id.goog[NAMESPACE/KSA_NAME]`).
- 5Annotate the Kubernetes Service Account with `iam.gke.io/gcp-service-account=GSA_EMAIL` to link the KSA to the GSA.
Answer
The correct sequence starts with enabling Workload Identity on the GKE cluster, followed by creating and granting IAM roles to the Google Service Account (GSA). Next, create the Kubernetes Service Account (KSA), grant the `roles/iam.workloadIdentityUser` role on the GSA to the KSA identity URI, and finally annotate the KSA with the GSA's email address.
Configuring Workload Identity follows a logical top-down sequence: infrastructure setup, identity provisioning on both GCP and Kubernetes layers, authorization via IAM binding, and pod configuration via KSA annotation. First, the GKE cluster must have Workload Identity enabled to create the workload identity pool. Second, the Google Service Account (GSA) is created and assigned resource permissions. Third, the Kubernetes Service Account (KSA) is created in the target namespace. Fourth, the IAM role `roles/iam.workloadIdentityUser` is granted on the GSA to the formatted KSA member URI. Finally, the KSA is annotated with the GSA email so the GKE metadata server handles keyless token negotiation.
Step-by-Step Solution
Key Concept
GKE Workload Identity Configuration Sequence