Review Kubernetes image digest pinning

Specify the exact image content and manage reviewed updates.

Description

A tag can move to different image content. A digest identifies specific content so you can deploy it again.

Potential impact

After a tag moves, the same Pod configuration can start an unreviewed image on a different node or at a later time.

Remediation

Check the image’s provenance and vulnerabilities in a trusted registry, then put its digest in image. Verify that the target platform is supported and the workload can pull the image. Review patches before updating the digest.

Examples

Replace registry.example.com and the example 64-character SHA-256 value with the actual repository and verified digest.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: private-image-test
spec:
  containers:
    - name: uses-private-image
      image: registry.example.com/app
      imagePullPolicy: Always

registry.example.com/app uses the implicit latest tag. Always checks what that tag refers to when the container starts.

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: private-image-test
spec:
  containers:
    - name: uses-private-image
      image: registry.example.com/app@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
      imagePullPolicy: Always

The digest after @ pins the image content. Both Pods use the same Always pull policy.

References