Secret Manager
Configure GKE’s Secret Manager add-on, which lets workloads mount secrets from Google Secret Manager via a CSI driver, using the secretManagerConfig field on GCPManagedControlPlane.
This is a distinct feature from Secret Sync (secretSyncConfig), which synchronizes secrets into native Kubernetes Secrets instead of mounting them as volumes. The two features can be enabled independently or together.
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedControlPlane
metadata:
name: mygcpmanagedcontrolplane
spec:
secretManagerConfig:
enabled: true
Automatic secret rotation
By default, secrets mounted via the CSI driver are only refreshed when the mounting pod restarts. To periodically refresh cached secrets, enable rotation and optionally set the interval (GKE defaults to 2 minutes if unset):
spec:
secretManagerConfig:
enabled: true
rotationConfig:
enabled: true
rotationInterval: 5m
It’s worth noting that rotationConfig is only valid when enabled is set to true, and the same goes for
rotationInterval when rotationConfig.enabled is true. Further, the rotationInterval has a minimum value
of 60s, enforced by GCP.
IAM requirements
Workloads reading secrets need the roles/secretmanager.secretAccessor role on the secrets they mount, granted to the Kubernetes service account’s associated IAM identity (typically via Workload Identity):
gcloud secrets add-iam-policy-binding SECRET_NAME \
--member="principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/PROJECT_ID.svc.id.goog/subject/ns/NAMESPACE/sa/KSA_NAME" \
--role="roles/secretmanager.secretAccessor"
Omitting secretManagerConfig leaves any Secret Manager settings alone, whereas explicitly setting enabled: false
disables it. The field is mutable and can be changed on an existing cluster.