Kubernetes Rollouts & Autoscaling (HPA)
Manage deployment rollouts, zero-downtime updates, revision histories, manual scaling, and dynamic Horizontal Pod Autoscaling (HPA).
Kubernetes Rollouts & Autoscaling (HPA)
Managing production application lifecycles requires coordinating software updates and scaling replicas dynamically based on user demand.
1. Rollout Management Commands
# Check rollout progress
kubectl rollout status deployment/web-app
# Pause a rollout midway (e.g. for canary testing)
kubectl rollout pause deployment/web-app
# Resume paused rollout
kubectl rollout resume deployment/web-app
# View revision history
kubectl rollout history deployment/web-app
# Roll back to immediate previous version
kubectl rollout undo deployment/web-app
# Restart all pods gracefully without changing image (rolling restart)
kubectl rollout restart deployment/web-app2. Manual Scaling
Scale replica counts instantly:
kubectl scale deployment web-app --replicas=103. Horizontal Pod Autoscaler (HPA)
The Horizontal Pod Autoscaler automatically increases or decreases the number of Pod replicas based on observed CPU utilization, memory consumption, or custom application metrics.
[!IMPORTANT] HPA requires
metrics-serverinstalled in the cluster and explicitresources.requests.cpuconfigured in the Deployment PodSpec.
3.1 Declarative HPA Manifest
# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web-app-hpa
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 803.2 Monitoring Autoscaling
kubectl get hpaOutput:
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
web-app-hpa Deployment/web-app 42%/75%, 65%/80% 2 10 3 4dKubernetes Logs, Exec & Debugging
Stream container logs, debug previous crashed containers, open interactive shells with kubectl exec, copy files, and port-forward to local ports.
Kubernetes Troubleshooting & Diagnostics Guide
A systematic troubleshooting methodology and decision tree for debugging CrashLoopBackOff, ImagePullBackOff, Pending pods, and Service routing failures.