Skip to the page

CI/CD for developers · mid

Image tags, versions and knowing what is running

Tag every image with the commit SHA and deploy by digest. The latest tag hides which code runs and breaks rollbacks.

The notes

What you must know

  • With latest, applying the same manifest changes nothing in the pod template, so no rollout happens. Pods pick up whatever latest points to whenever they restart, so different pods can run different code.
  • Rolling back to a revision that also says latest pulls the newest image again, which may contain someone else's unfinished change.
  • Tag with the git commit SHA on every build, and add a semantic version for releases if useful. Never reuse or move a tag. In ECR, turn on immutable tags.
  • What is running: kubectl get pods -o jsonpath on status.containerStatuses[*].imageID shows the digest each pod really runs. Compare it with what the registry says.
  • Expose the version: a /version endpoint or build info in logs and metrics, so an incident starts with which version.
  • Deploy by digest (image@sha256:...) for the strongest guarantee. Tags can be moved unless immutable.
  • GitOps: the Git history of the environment repository is the record of what was deployed and when.

The red pen

Common traps: mistake → fix

  • Mistake: latest is fine for staging

    Fix: It breaks rollouts and rollbacks there too.

  • Mistake: A tag is a fixed version

    Fix: Tags can be moved unless immutable. A digest is fixed.

  • Mistake: kubectl rollout undo goes back to the old code if the tag is the same

    Fix: It goes back to the old manifest, which can pull new code.

Easy to hard

Questions interviewers ask, easy to hard

  1. Why is the latest tag a problem in Kubernetes?
  2. How do you find out which version a pod is running?
  3. Which tag scheme do you use and why?
  4. Why use immutable tags in a registry?
  5. Nobody knows which version is running in production. How do you find out and prevent it?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview