Rolling Update
Rolling Update
A deployment strategy that replaces instances sequentially. Zero downtime.
Rolling Update
A deployment strategy that replaces instances sequentially. Zero downtime.
Rolling Update is a zero-downtime deployment strategy that replaces existing instances one by one when deploying a new version of an application. It is the most basic yet reliable way to update gradually while maintaining service availability.
In Kubernetes, Rolling Update is the default deployment strategy, and the maxSurge and maxUnavailable parameters control how many Pods are created/deleted at once. For example, with 10 Pods, setting maxSurge=2 and maxUnavailable=1 means up to 12 Pods exist and at least 9 are always available. This lets you provide stable service even during traffic spikes.
# deployment-rolling.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 6
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # μ΅λ μΆκ° μμ± Pod μ
maxUnavailable: 1 # μ΅λ μ¬μ© λΆκ° Pod μ
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: web
image: myapp/web:v2.0.0
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /ready
port: 80
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
failureThreshold: 3
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
terminationGracePeriodSeconds: 30
#!/bin/bash
# rolling-update-monitor.sh
DEPLOYMENT="web-app"
NAMESPACE="production"
# νμ¬ λ²μ νμΈ
echo "=== νμ¬ λ°°ν¬ μν ==="
kubectl get deployment $DEPLOYMENT -n $NAMESPACE \
-o jsonpath='{.spec.template.spec.containers[0].image}'
echo ""
# μ λ²μ λ°°ν¬
echo "=== v2.0.0 λ‘€λ§ μ
λ°μ΄νΈ μμ ==="
kubectl set image deployment/$DEPLOYMENT \
web=myapp/web:v2.0.0 -n $NAMESPACE
# μ€μκ° μ§ν μν© νμΈ
echo "=== λ°°ν¬ μ§ν μν© ==="
kubectl rollout status deployment/$DEPLOYMENT -n $NAMESPACE -w
# μλ£ ν μν νμΈ
echo "=== μ΅μ’
μν ==="
kubectl get pods -n $NAMESPACE -l app=$DEPLOYMENT -o wide
# λ°°ν¬ νμ€ν 리
echo "=== λ°°ν¬ νμ€ν 리 ==="
kubectl rollout history deployment/$DEPLOYMENT -n $NAMESPACE