← Policy catalog
</> ValidatingAdmissionPolicy · Apache-2.0

Provisions GCP Disks Without a Customer-Managed Key

storageclass-cmek-gcp-pd

severityLow resourceStorageClasses productKubernetes bundles1

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.

Rejects unless

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").

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'].

Applies to

  • storageclasses · storage.k8s.io/v1 · CREATE, UPDATE

Manifest

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.

Validate with kubeapt

Check a workload against this one policy, before anything is installed on a cluster.

$ kubeapt validate -p ./storageclass-cmek-gcp-pd.yaml -r ./workload.yaml

Or 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 ./manifests

Or against every namespace in the cluster your kubeconfig points at:

$ kubeapt validate --policy-name storageclass-cmek-gcp-pd -A