Skip to content

CICD-149 · Set an image digest explicitly ​

Encyclopedia · Kubernetes fundamentals · All snippets

Previous · CICD-148 · Next · CICD-150

1. Where it fits ​

  • Placement Bash run step following checkout, or equivalent lab terminal.
  • Prerequisites isolated Kubernetes namespace, kubectl and reviewed manifests.
  • Platforms kubernetes, local-lab.
  • Parameters IMAGE.

2. Copy the snippet ​

bash
[[ "${IMAGE:?}" =~ @sha256:[0-9a-f]{64}$ ]]
kubectl -n staging set image deployment/web web="$IMAGE"

3. How it works ​

The Bash regex requires a sha256 image reference. kubectl then updates the specific container so mutable tags cannot silently change the intended candidate.

4. Verify the result ​

Names map to deployment and container. Verify rollout and the running Pod image ID.

Validation syntax-validated (Bash parse). Status definitions.