storageclass-cmek-gcp-pd
Without a Cloud KMS key, disks provisioned from this class fall back to Google-managed keys that you cannot rotate, audit or revoke, so snapshots and disk images stay readable to anyone with project-level access.
object.provisioner != 'pd.csi.storage.gke.io' ||
(has(object.parameters) && 'disk-encryption-kms-key' in object.parameters &&
object.parameters['disk-encryption-kms-key'] != '')
GCP Persistent Disk StorageClasses must use customer-managed encryption keys (parameters."disk-encryption-kms-key").
Set the disk-encryption-kms-key parameter to a Cloud KMS key resource path on pd.csi.storage.gke.io StorageClasses. Field: parameters['disk-encryption-kms-key'].
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: storageclass-cmek-gcp-pd
annotations:
kubeapt.io/uuid: "b6471576-2bd6-4115-bbc2-07510127f17b"
security.kubeapt.io/displayName: "Provisions GCP Disks Without a Customer-Managed Key"
security.kubeapt.io/description: "Without a Cloud KMS key, disks provisioned from this class fall back to Google-managed keys that you cannot rotate, audit or revoke, so snapshots and disk images stay readable to anyone with project-level access."
security.kubeapt.io/resource: "StorageClasses"
security.kubeapt.io/severity: "Low"
security.kubeapt.io/remediation: "Set the disk-encryption-kms-key parameter to a Cloud KMS key resource path on pd.csi.storage.gke.io StorageClasses. Field: parameters['disk-encryption-kms-key']."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- storage.k8s.io
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- storageclasses
validations:
- expression: |
object.provisioner != 'pd.csi.storage.gke.io' ||
(has(object.parameters) && 'disk-encryption-kms-key' in object.parameters &&
object.parameters['disk-encryption-kms-key'] != '')
message: |
GCP Persistent Disk StorageClasses must use customer-managed encryption keys (parameters."disk-encryption-kms-key").Save it as storageclass-cmek-gcp-pd.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./storageclass-cmek-gcp-pd.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name storageclass-cmek-gcp-pd -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name storageclass-cmek-gcp-pd -A