๐กLaunching Your Kubernetes Cluster with Deployment.
Deploy Smarter: Kubernetes Auto-Healing, Scaling & Rollbacks.

๐จโ๐ป Last-year student diving deep into DevOps, Cloud Engineering, and Infrastructure Automation. Passionate about building scalable, efficient, and secure systems. Letโs connect and build something amazing! ๐
๐ What is a Deployment in Kubernetes?
A Deployment helps manage application updates, scaling, and availability by ensuring the desired number of Pods are always running.
โ Key Features of Deployments
Auto-healing: Restarts crashed Pods automatically.
Auto-scaling: Adjusts the number of Pods based on load.
Rolling updates: Deploy new versions with zero downtime.
Rollback: Revert to a previous version if needed.
๐ก In simple terms: You define how many Pods you want, and Kubernetes ensures they are running and healthy at all times.
๐ Task 1: Deploying a Sample Todo-App with Auto-Healing, Auto-Scaling & Rolling Updates
Letโs deploy a Todo App using a Kubernetes Deployment.
๐ Step 1: Create a Deployment File (deployment.yml)
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-app
labels:
app: todo
spec:
replicas: 3 # Ensures 3 Pods run
strategy:
type: RollingUpdate # Enables rolling updates
rollingUpdate:
maxUnavailable: 1 # At most, 1 pod can be unavailable during the update
maxSurge: 1 # Allows 1 extra pod to start before stopping an old one
selector:
matchLabels:
app: todo
template:
metadata:
labels:
app: todo
spec:
containers:
- name: todo-container
image: your-todo-app-image:v1 # Initial version
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: todo-service
spec:
selector:
app: todo
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
๐น Step 2: Apply the Deployment to Minikube
kubectl apply -f deployment.yml
๐ Step 3: Verify Your Deployment
kubectl get pods
kubectl get deployments
kubectl get services
๐ How Auto-Healing, Auto-Scaling & Rolling Updates Work in This Deployment
๐น Auto-Healing
The Deployment Controller ensures at least 3 replicas are running. If a Pod crashes, it automatically replaces it.
spec:
replicas: 3 # Ensures 3 instances of the app run
๐ก Example: If one Pod fails, Kubernetes immediately creates a new one to replace it.
๐น Auto-Scaling
You can enable Horizontal Pod Autoscaler (HPA) to automatically adjust the number of Pods based on CPU usage.
Run this command to set up auto-scaling:
kubectl autoscale deployment todo-app --cpu-percent=50 --min=2 --max=5
๐ก Example: If CPU usage goes above 50%, Kubernetes adds more Pods (up to 5). If load decreases, it scales down (minimum 2 Pods).
๐น Rolling Updates (Zero Downtime Deployment)
The RollingUpdate strategy ensures new versions are deployed gradually without downtime.
To update your app from v1 to v2, modify the deployment:
containers:
- name: todo-container
image: your-todo-app-image:v2 # New version
Apply the update:
kubectl apply -f deployment.yml
๐ก How it works:
โ
Kubernetes gradually replaces old Pods with new ones.
โ
Ensures at least 2 Pods are always running during updates.
โ
Users donโt experience downtime while the update happens.
Check rollout status:
kubectl rollout status deployment/todo-app
๐น Rollback (Reverting to a Previous Version)
If the new version has issues, rollback to the last stable version with:
kubectl rollout undo deployment todo-app
๐ก How it works:
โ
Instantly reverts back to the last working version.
โ
Prevents users from experiencing a broken update.




