Day 33 of 90 Days of Challenge: Kubernetes Deployment & Rollback Essentials


On Day 32, I manually set up my own Kubernetes cluster using kubeadm
, gaining hands-on experience beyond Minikube. From initializing the cluster to applying the Calico CNI plugin and inspecting system pods with kubectl
, I finally understood what happens under the hood.
Today, I explored one of Kubernetes' core features Deployments. They allow you to declaratively manage your application’s lifecycle, ensuring consistent rollout, automatic updates, and rollbacks with just a few commands. It's this combination of control and automation that makes Deployments a key resource in production-grade Kubernetes setups.
What Is a Deployment in Kubernetes?
A Deployment is a higher-level abstraction that manages ReplicaSets and Pods. Instead of creating Pods directly, we define a Deployment manifest that describes:
The container image version to deploy
The number of replicas
The update strategy
Labels and selectors
Pod specs (ports, environment variables, etc.)
Once applied, Kubernetes ensures the cluster matches your desired state spinning up Pods, managing health checks, and scaling as needed.
Rolling Updates in Action
The most powerful feature of Deployments is the rolling update strategy. Instead of killing all Pods at once and deploying new ones (which causes downtime), rolling updates:
Gradually spin up new Pods with the updated version
Wait for readiness probes to pass
Gradually terminate old Pods
This ensures zero downtime deployments, a cornerstone of modern DevOps practices.
YAML Example of a Deployment:
Version: apps/v1
kind: Deployment
metadata:
name: webapp-deployment
spec:
replicas: 3
selector:
matchLabels:
app: mywebapp
template:
metadata:
labels:
app: mywebapp
spec:
containers:
- name: mywebapp-container
image: zerotoroot/mywebapp:v1
ports:
- containerPort: 80
Key Fields:
replicas: Number of desired Pods.
selector: Defines how the Deployment finds which Pods to manage.
template: Blueprint for the Pods including labels and container spec.
Apply the deployment using:
kubectl apply -f deployment.yaml
kubectl get deployments
kubectl get pods
This will spin up 3 pods of your app. Now let’s say we want to update the version of the container image:
image: zerotoroot/mywebapp:v2
Re-applying the updated YAML triggers a rolling update automatically.
Rolling back to previous version
If something goes wrong during the update, Kubernetes makes it easy to roll back:
kubectl rollout undo deployment/webapp-deployment
You can even rollback to a specific revision:
kubectl rollout undo deployment/nginx-deployment --to-revision=2
To see the history of revisions:
kubectl rollout history deployment/nginx-deployment
Monitoring Deployment Status
To keep an eye on how the update is progressing:
kubectl rollout status deployment/demo
kubectl get rs # Shows underlying ReplicaSets
kubectl describe deployment demo
Kubernetes keeps track of previous revisions and lets you revert with a single command.
Scaling Made Easy
Need to scale your application to handle more traffic use:
kubectl scale deployment webapp-deployment --replicas=5
Kubernetes will automatically spin up 2 more Pods to meet the new replica count. And you can scale down just as easily.
Complete Lifecycle Management
A Kubernetes Deployment offers end-to-end control over your application:
Declarative updates: describe the desired state once; K8s handles the rest
Version history & rollbacks: revert to any previous revision in seconds
Effortless scaling: Adjust replica counts on demand
Built-in health checks: liveness/readiness probes keep traffic flowing only to healthy Pods
Self-healing: crashed Pods are automatically replaced to maintain availability
Final Thoughts
Learning about Deployments and Rollbacks helped me understand how Kubernetes manages applications with precision from rolling updates and version control to self-healing and scaling. It’s a game-changer for reliable, zero-downtime deployments.
With hands-on practice, I now feel more confident managing app lifecycles in a cluster. Up next, I’ll explore ReplicaSets and StatefulSets to dive deeper into workload management in Kubernetes.
Stay Tuned!!
Subscribe to my newsletter
Read articles from Vaishnavi D directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
