๐ก๏ธ Google GKE Cluster Node Pool uses default Service account๐ข
- Contextual name: ๐ก๏ธ Cluster Node Pool uses default Service account๐ข
- ID:
/ce/ca/google/gke/node-pool-service-account - Tags:
- ๐ข Policy with categories
- ๐ข Policy with type
- ๐ข Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicโ
- ๐ง prod.logic.yaml๐ข
Descriptionโ
Descriptionโ
This policy identifies Google GKE Cluster Node Pools that are configured to use the default Compute Engine service account instead of dedicated, least-privilege IAM service accounts.
Rationaleโ
By default, GKE nodes use the Compute Engine default service account, which has broad permissions that often exceed the requirements of a GKE cluster.
To follow the principle of least privilege, a dedicated service account should be created and used to run the GKE cluster. In addition, separate service accounts should be created for individual Kubernetes workloads as needed.
At a minimum, the node service account requires the following roles:
monitoring.viewermonitoring.metricWriterlogging.logWriterAdditional roles may be required for specific use cases, such as pulling images from Google Container Registry (GCR).
Impactโ
Instances using the default service account are automatically granted the https://www.googleapis.com/auth/cloud-platform, which allows unrestricted access to all Google Cloud APIs.This means that IAM permissions are determined entirely by the roles assigned to the service account.
... see more
Remediationโ
Remediationโ
Configure GKE Node Pools with a Least-Privilege Service Accountโ
From gcloud CLIโ
Create a minimally privileged service account
gcloud iam service-accounts create {{node-sa-name}} \
--display-name "GKE Node Service Account"Capture the service account email
export {{node-sa-email}}=$(gcloud iam service-accounts list \
--format='value(email)' \
--filter='displayName:GKE Node Service Account')Capture the project ID
export {{project-id}}=$(gcloud config get-value project)Grant the required roles to the service account
gcloud projects add-iam-policy-binding ${{project-id}} \
--member serviceAccount:${{node-sa-email}} \
--role roles/monitoring.metricWriter
gcloud projects add-iam-policy-binding ${{project-id}} \
--member serviceAccount:${{node-sa-email}} \
--role roles/monitoring.viewer
gcloud projects add-iam-policy-binding ${{project-id}} \
--member serviceAccount:${{node-sa-email}} \... see more