Interview Prep/DevSecOps/Kubernetes Security

How do you enforce that only signed images run in a cluster?

AdvancedConceptKubernetes Security
Answer

Verify at admission with Kyverno verifyImages, Sigstore policy-controller, or Ratify with Gatekeeper. A Kyverno example for keyless images built by GitHub Actions:

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata: { name: verify-signed-images }
spec:
  validationFailureAction: Enforce
  rules:
  - name: keyless-github
    match:
      any:
      - resources: { kinds: ["Pod"] }
    verifyImages:
    - imageReferences: ["ghcr.io/acme/*"]
      mutateDigest: true
      attestors:
      - entries:
        - keyless:
            subject: "https://github.com/acme/*"
            issuer: "https://token.actions.githubusercontent.com"

mutateDigest rewrites tags to the verified digest so a tag cannot be swapped after verification. Start in Audit mode, then enforce.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security