Rolling Update of an NGINX Deployment on Kubernetes
This article documents the process of performing a rolling update on a Kubernetes deployment to update the NGINX web server to version 1.18
. The deployment, named nginx-deployment
, was updated to reflect recent changes from the application development team.
1. Initiating the Rolling Update
To start the rolling update, the kubectl set image
command was used. This command tells Kubernetes to update the nginx-container
within the nginx-deployment
to use the new nginx:1.18
image. Kubernetes then begins the rolling update process, which creates new pods with the updated image while gracefully terminating the old ones, ensuring the application remains available.
thor@jumphost ~$ kubectl set image deployment/nginx-deployment nginx-container=nginx:1.18 deployment.apps/nginx-deployment image updated
2. Verifying the Rollout Status
After initiating the update, the kubectl rollout status
command was used to monitor the progress. The command confirms that the new pods have been successfully created and are ready to serve traffic.
thor@jumphost ~$ kubectl rollout status deployment/nginx-deployment deployment "nginx-deployment" successfully rolled out
3. Checking for Pods in the Correct Namespace
Initially, a check for pods using the label app=nginx
failed to show any resources. This is because the deployment's pods were located in the default namespace, while the initial command may have been looking in a different or unspecified namespace. To resolve this, kubectl get pods
was run with the --all-namespaces
flag. This command correctly located the pods and showed them running in the default
namespace.
thor@jumphost ~$ kubectl get pods -l app=nginx No resources found in default namespace. thor@jumphost ~$ kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default nginx-deployment-58cf54c7f6-hzwvn 1/1 Running 0 2m43s default nginx-deployment-58cf54c7f6-w4wh4 1/1 Running 0 2m51s default nginx-deployment-58cf54c7f6-wznkx 1/1 Running 0 2m41s kube-system coredns-5d78c9869d-bn6v4 1/1 Running 0 13m kube-system coredns-5d78c9869d-g75tz 1/1 Running 0 13m kube-system etcd-kodekloud-control-plane 1/1 Running 0 13m kube-system kindnet-grrg5 1/1 Running 0 13m kube-system kube-apiserver-kodekloud-control-plane 1/1 Running 0 13m kube-system kube-controller-manager-kodekloud-control-plane 1/1 Running 0 13m kube-system kube-proxy-jtxjl 1/1 Running 0 13m kube-system kube-scheduler-kodekloud-control-plane 1/1 Running 0 13m local-path-storage local-path-provisioner-6bc4bddd6b-54lws 1/1 Running 0 13m
4. Final Verification
The last step was to confirm that the new pods were indeed using the correct nginx:1.18
image. This was done by using the kubectl describe pod
command on one of the new pods, nginx-deployment-58cf54c7f6-hzwvn
. The output clearly showed that the nginx-container
's image had been updated to the desired version.
thor@jumphost ~$ kubectl describe pod nginx-deployment-58cf54c7f6-hzwvn Name: nginx-deployment-58cf54c7f6-hzwvn Namespace: default Priority: 0 Service Account: default Node: kodekloud-control-plane/172.17.0.2 Start Time: Tue, 23 Sep 2025 05:17:44 +0000 Labels: app=nginx-app pod-template-hash=58cf54c7f6 Annotations: <none> Status: Running IP: 10.244.0.9 IPs: IP: 10.244.0.9 Controlled By: ReplicaSet/nginx-deployment-58cf54c7f6 Containers: nginx-container: Container ID: containerd://df902a1d0ebdef8caad17cab31cddec1af4a4c5f6152b0933e6e460c8b7a9fbd Image: nginx:1.18 Image ID: docker.io/library/nginx@sha256:e90ac5331fe095cea01b121a3627174b2e33e06e83720e9a934c7b8ccc9c55a0 Port: <none> Host Port: <none> State: Running Started: Tue, 23 Sep 2025 05:17:45 +0000 Ready: True Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-smr26 (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: kube-api-access-smr26: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 7m41s default-scheduler Successfully assigned default/nginx-deployment-58cf54c7f6-hzwvn to kodekloud-control-plane Normal Pulled 7m41s kubelet Container image "nginx:1.18" already present on machine Normal Created 7m41s kubelet Created container nginx-container Normal Started 7m40s kubelet Started container nginx-container
The output confirms the successful update and shows that the new pods are running and healthy. This completes the rolling update process for the NGINX application.
Top comments (0)