An engineering team is deploying an application to Google Kubernetes Engine (GKE) that requires access to a Google Cloud Storage bucket. To adhere to security best practices, the team decides to use Workload Identity instead of exporting static service account keys. What is the correct sequence of steps to configure Workload Identity binding between the Kubernetes Service Account (KSA) and the GCP Service Account (GSA)?
- 1Create a GCP Service Account (GSA) and grant it the required IAM storage permissions on the target bucket.
- 2Create a Kubernetes Service Account (KSA) within the specific Kubernetes namespace of your GKE cluster.
- 3Grant the Workload Identity User role (roles/iam.workloadIdentityUser) on the GSA to the member 'serviceAccount:PROJECT_ID.svc.id.goog[NAMESPACE/KSA_NAME]'.
- 4Annotate the KSA with the email address of the GSA using the annotation 'iam.gke.io/gcp-service-account=GSA_EMAIL'.
- 5Configure the Pod manifest to use the annotated KSA via the 'serviceAccountName' field and deploy the Pod.
Cevap
The correct order to configure Workload Identity is: First, create the GCP Service Account with resource permissions. Second, create the Kubernetes Service Account in the cluster namespace. Third, bind the Workload Identity User role on the GCP Service Account to the Kubernetes Service Account principal. Fourth, annotate the Kubernetes Service Account with the GCP Service Account email. Fifth, configure and deploy the Pod using the annotated Kubernetes Service Account.
The configuration of Workload Identity requires creating the GCP Service Account with access permissions and the Kubernetes Service Account in the cluster, granting the roles/iam.workloadIdentityUser IAM role on the GCP Service Account to the Kubernetes Service Account member URI, annotating the Kubernetes Service Account with the GCP Service Account email, and finally attaching the annotated Kubernetes Service Account to the Pod definition.
Adım Adım Çözüm
Anahtar Kavram
Workload Identity allows GKE workloads to impersonate a GCP Service Account by binding the roles/iam.workloadIdentityUser role to the Kubernetes Service Account identity string and annotating the KSA.