Introduction
In modern cloud-native applications, deploying updates without affecting users is very important. No one wants their application to go down during a deployment. This is where Kubernetes Rolling Updates help.
Rolling updates in Kubernetes allow you to update your application gradually, without stopping the entire system. Instead of replacing all instances (pods) at once, Kubernetes replaces them step by step, ensuring that some pods are always running and serving users.
In this article, we will understand how rolling updates work in Kubernetes and how to implement them without downtime using simple words, real examples, and best practices.
What is a Rolling Update in Kubernetes?
A rolling update is a deployment strategy in Kubernetes where old pods are replaced by new pods gradually.
This means:
Some old pods are terminated
New pods are created at the same time
Traffic is always served by available pods
Because of this gradual replacement, users do not experience downtime.
Why Use Rolling Updates?
Rolling updates are widely used in production systems because they provide:
Zero downtime deployments
Continuous availability
Safe and controlled updates
Easy rollback if something goes wrong
This makes them ideal for microservices and large-scale applications.
How Rolling Updates Work Internally
When you update a deployment:
Kubernetes creates new pods with the updated version
It waits until the new pods are ready
Then it slowly removes old pods
This process continues until all pods are updated
Kubernetes ensures that a minimum number of pods are always available.
Step 1: Create a Deployment
First, create a basic deployment.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: nginx:1.21
ports:
- containerPort: 80
Apply it:
kubectl apply -f deployment.yaml
This creates 3 running pods.
Step 2: Understand Default Rolling Update Strategy
Kubernetes uses rolling update by default.
You can check it using:
kubectl get deployment my-app -o yaml
You will see:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
Join the conversation! Your thoughts help the community grow.