π‘οΈ 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