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.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate