DEV Community

Cover image for 5.Execute Rolling Updates in Kubernetes
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

5.Execute Rolling Updates in Kubernetes

Lab Information

An application currently running on the Kubernetes cluster employs the nginx web server. The Nautilus application development team has introduced some recent changes that need deployment. They've crafted an image nginx:1.18 with the latest updates.

Execute a rolling update for this application, integrating the nginx:1.18 image. The deployment is named nginx-deployment.

Ensure all pods are operational post-update.

Note: The kubectl utility on jump_host is set up to operate with the Kubernetes cluster

Lab Solutions

Step 1: Check Current Deployment Status

First, let's check the current state of the deployment:

Check current deployment details

kubectl get deployment nginx-deployment
Enter fullscreen mode Exit fullscreen mode

Check current pods and their images

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Check current image being used

kubectl get deployment nginx-deployment -o jsonpath='{.spec.template.spec.containers[0].image}' && echo
Enter fullscreen mode Exit fullscreen mode

Step 2: Perform Rolling Update

Get detailed deployment information

kubectl describe deployment nginx-deployment
Enter fullscreen mode Exit fullscreen mode

Update the deployment using the correct container name

kubectl set image deployment/nginx-deployment nginx-container=nginx:1.18
Enter fullscreen mode Exit fullscreen mode

Watch the update progress

kubectl rollout status deployment/nginx-deployment --timeout=300s
Enter fullscreen mode Exit fullscreen mode

Check current pods and their images

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Confirm the image has been updated

kubectl get deployment nginx-deployment -o jsonpath='{.spec.template.spec.containers[0].image}' && echo
Enter fullscreen mode Exit fullscreen mode

Check rollout history

kubectl rollout history deployment/nginx-deployment
Enter fullscreen mode Exit fullscreen mode


Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.

Top comments (0)