In this guide, weβll learn how to update Kubernetes Deployments in Google Kubernetes Engine (GKE) using two methods:
- kubectl set image (direct image update)
- kubectl edit deployment (manual YAML edit)
Weβll also verify rollout status, ReplicaSets, Pods, and rollout history step by step.
π Step 00: Introduction
Kubernetes supports updating Deployments in two ways:
- Set Image β Quick way to update the container image directly.
- Edit Deployment β Manual way to edit deployment YAML and change the image (or other fields).
By default, updates are performed using a rolling update strategy, ensuring zero downtime.
πΉ Step 01: Update Application (V1 β V2) using set image
1οΈβ£ Get Container Name from Deployment
kubectl get deployment my-first-deployment -o yaml
2οΈβ£ Update Deployment to V2
kubectl set image deployment/my-first-deployment \
kubenginx=ghcr.io/stacksimplify/kubenginx:2.0.0
π Verify Rollout
# Check rollout status
kubectl rollout status deployment/my-first-deployment
# Verify deployment details
kubectl get deploy
kubectl describe deployment my-first-deployment
β Kubernetes performs a rolling update, gradually replacing old Pods with new ones without downtime.
π Verify ReplicaSets & Pods
# Check ReplicaSets
kubectl get rs
# Check Pods
kubectl get po
π Observation: A new ReplicaSet is created for version 2.0.0, while old ReplicaSet is scaled down.
π Access Application
# Get LoadBalancer IP
kubectl get svc
# Access via browser or curl
http://<External-IP>
β You should now see Application Version: V2.
π Update Change-Cause for Rollout History
# View rollout history
kubectl rollout history deployment/my-first-deployment
# Annotate with change cause
kubectl annotate deployment/my-first-deployment \
kubernetes.io/change-cause="Deployment UPDATE - App Version 2.0.0 - SET IMAGE OPTION"
# Verify rollout history
kubectl rollout history deployment/my-first-deployment
πΉ Step 02: Update Application (V2 β V3) using edit deployment
1οΈβ£ Edit Deployment YAML
kubectl edit deployment/my-first-deployment
Change the image version:
# From
image: ghcr.io/stacksimplify/kubenginx:2.0.0
# To
image: ghcr.io/stacksimplify/kubenginx:3.0.0
π Verify Rollout
# Rollout status
kubectl rollout status deployment/my-first-deployment
# Deployment details
kubectl describe deployment/my-first-deployment
π Verify ReplicaSets & Pods
kubectl get rs
kubectl get po
π Observation: Now we should see 3 ReplicaSets (V1, V2, V3).
π Access Application
kubectl get svc
http://<External-IP>
β Application should now display Version: V3.
π Update Change-Cause for Rollout History
# Rollout history
kubectl rollout history deployment/my-first-deployment
# Annotate with change cause
kubectl annotate deployment/my-first-deployment \
kubernetes.io/change-cause="Deployment UPDATE - App Version 3.0.0 - EDIT DEPLOYMENT OPTION"
# Verify rollout history again
kubectl rollout history deployment/my-first-deployment
β Recap
In this tutorial, we:
- Updated a Deployment using kubectl set image
- Updated another version using kubectl edit deployment
- Verified rollout status, ReplicaSets, and Pods
- Annotated rollouts for better history tracking
π With Kubernetes in GCP, updates are seamless, zero-downtime, and fully auditable.
π Thanks for reading! If this post added value, a like β€οΈ, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
βοΈ AWS | GCP | βΈοΈ Kubernetes | π Security | β‘ Automation
π Sharing hands-on guides, best practices & real-world cloud solutions
Top comments (0)