More Info:

Kubernetes workloads should not use cluster node service accounts to authenticate to Google Cloud APIs. Each Kubernetes Workload that needs to authenticate to other Google services using Cloud IAM should be provisioned a dedicated Service account. Enabling Workload Identity manages the distribution and rotation of Service account keys for the workloads to use.

Risk Level

Medium

Address

Security, Operational Excellence, Best Practice

Compliance Standards

CISGKE

Triage and Remediation

Remediation

To remediate the misconfiguration of using Dedicated GCP Service Accounts and Workload Identity for Clusters in GCP, follow these steps:

  1. Open the GCP Console and navigate to the Kubernetes Engine.

  2. Select the cluster for which you want to remediate the misconfiguration.

  3. Click on the “Edit” button at the top of the page.

  4. Under the “Security” section, select “Workload Identity.”

  5. Select the checkbox “Enable Workload Identity.”

  6. In the “Service Account” field, enter the name of the dedicated service account that you want to use for the cluster.

  7. Click on the “Save” button to apply the changes.

  8. Once the changes are applied, verify that the dedicated service account is being used for the cluster by running the following command in the Cloud Shell:

kubectl get pods --namespace kube-system -o=jsonpath='{.items[*].spec.serviceAccountName}'

This command will return the name of the service account being used by the pods in the kube-system namespace. Verify that it matches the dedicated service account that you specified in step 6.

By following these steps, you have successfully remediated the misconfiguration of using Dedicated GCP Service Accounts and Workload Identity for Clusters in GCP.

Additional Reading: