Kubernetes Lab 7 - Rolling Updates
Problem
Your company's developers have just finished developing a new version of their jedi-themed mobile game. They are ready to update the backend services that are running in your Kubernetes cluster. There is a deployment in the cluster managing the replicas for this application. The deployment is called jedi-deployment. You have been asked to update the image for the container named jedi-ws in this deployment template to a new version, bitnami/nginx:1.19.0.
After you have updated the image using a rolling update, check on the status of the update to make sure it is working. If it is not working, perform a rollback to the previous state.
Setup
First, create the initial deployment by saving the following YAML to a file named jedi-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: jedi-deployment
labels:
app: jedi
spec:
replicas: 3
selector:
matchLabels:
app: jedi
template:
metadata:
labels:
app: jedi
spec:
containers:
- name: jedi-ws
image: bitnami/nginx:1.18.0
ports:
- containerPort: 8080
Apply the deployment:
Verify the deployment is running:
Tasks
- Update the deployment to use the new image
bitnami/nginx:1.19.0for the container namedjedi-ws - Check the rollout status to verify the update is progressing
- View the rollout history to see the deployment revisions
- If the update fails, perform a rollback to the previous working version
Hints
- Use
kubectl set imageto update the container image - Use
kubectl rollout statusto check rollout progress - Use
kubectl rollout historyto view revision history - Use
kubectl rollout undoto rollback if needed - Watch pods in real-time with
kubectl get pods -w
Verification
After completing the lab, you should be able to:
- See the deployment running with the updated image:
- View the rollout history showing multiple revisions: