Perform In-Place Updates on a Kubernetes Deployment
Scenario
You are working with a Kubernetes Deployment running in the prod namespace.
An existing Deployment named nginx-deployment is already running with two
containers:
| Container | Image |
|---|---|
nginx | public.ecr.aws/nginx/nginx:stable-alpine |
sidecar | busybox:latest |
Task
Make the following changes to the nginx-deployment Deployment in the prod
namespace:
- Update the
nginxcontainer image topublic.ecr.aws/nginx/nginx:alpine - Update the
sidecarcontainer image tobusybox:musl - Rename the
nginxcontainer tonginx-prod - Rename the
sidecarcontainer tosidecar-prod - Change the update strategy to
Recreate - Scale the Deployment to
3replicas
Ensure the Deployment reaches a healthy state after applying all changes.
Hint — Editing a Deployment In-Place
The fastest way to apply all changes at once is to edit the Deployment directly — one edit triggers a single rollout:
kubectl edit deployment nginx-deployment -n prod
Inside the editor, update name, image, strategy.type, and replicas
all in one save.
Alternatively, you can update images without editing using kubectl set image.
Note that this only updates images — container names, strategy, and replicas
still require a direct edit:
kubectl set image deployment/nginx-deployment -n prod \
nginx=public.ecr.aws/nginx/nginx:alpine \
sidecar=busybox:musl
Scale replicas separately:
kubectl scale deployment nginx-deployment -n prod --replicas=3
After any change, verify the rollout completes:
kubectl rollout status deployment/nginx-deployment -n prod
Documentation