How do I redeploy everything in kubernetes after updating a dockerfile?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Updating a Dockerfile does not change anything in Kubernetes by itself. The cluster only reacts when a new image exists in a registry and a workload is updated to use that image, so the real deployment workflow is build, push, update the workload, and verify the rollout.
Build and Push a New Image
Kubernetes cannot deploy an image that only exists on your laptop. After editing the Dockerfile, build a fresh image and push it to the registry your cluster can reach.
Use an immutable tag whenever possible:
An immutable tag such as a commit SHA makes it clear exactly what is running. Mutable tags such as latest make deployments harder to reason about and harder to roll back safely.
Update the Kubernetes Workload
Pushing a new image is not enough. You still need to update the Deployment, StatefulSet, or other controller so Kubernetes knows a new rollout is required.
Imperative example:
Declarative example:
In GitOps systems, the same idea applies except the image reference is changed in Git and then reconciled by the controller.
Verify What the Cluster Is Actually Running
A completed rollout status is necessary, but it is not enough by itself. Confirm that the pods actually reference the image you intended:
If you need the resolved image ID:
Then run smoke tests against the service. A rollout that completes successfully but serves broken traffic is still a failed deployment.
“Redeploy Everything” Is Usually the Wrong Default
Most Dockerfile changes affect one workload, not the whole cluster. Restarting or redeploying everything is usually more risk than benefit.
Broad redeploys make sense when:
- a shared base image has a critical security update
- a runtime or sidecar pattern changed across many services
- a cluster-wide incident requires broad restarts
Even then, staged rollouts are usually safer than restarting the entire environment blindly.
Understand rollout restart
kubectl rollout restart restarts pods, but it does not change the image reference in the spec:
This is useful when the manifest already points at the desired image tag and you simply need fresh pods. It is not a substitute for updating to a newly built immutable image tag.
Plan Rollback Before Deployment
Every rollout should have a rollback path:
If the rollout behaves badly, gather details quickly:
The goal is not only to revert but also to confirm the previous version is healthy again after the rollback.
Common Pitfalls
The biggest mistake is rebuilding the image locally and forgetting to push it to the registry.
Another issue is relying on mutable tags and assuming every node pulled the newest content. That makes it hard to know what is really running.
People also say "redeploy everything" when the correct operational move is to update only the workload affected by the Dockerfile change.
Finally, a restart is not the same as an image update. If the workload spec never changed, Kubernetes may simply restart pods on the same old image.
Summary
- After changing a Dockerfile, build and push a new image first.
- Update the Kubernetes workload explicitly so the cluster uses that image.
- Prefer immutable image tags for traceable and safe rollouts.
- Verify the running image and smoke-test the service after rollout.
- Redeploy only what changed unless you have a clear cluster-wide reason to do more.
Related reading
- How do I remove the Kubernetes dashboard resources from my deployment on Google Cloud Platform?
- How do I run a container from the command line in Kubernetes like docker run?
- How do I run curl command from within a Kubernetes pod
- How do I run private docker images on Google Container Engine
- How do I run a command on an already existing Docker container?
- How do I run a docker instance from a DockerFile?
- How do I reference cross-stack resources in the same app?
- How do I run a spring boot executable jar in a Production environment?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.