Auto-scaling automatically adjusts compute resources based on demand, ensuring high availability and cost efficiency.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: webapp-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: webapp
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
Auto-scaling ensures resilient, cost-effective, and performance-optimized infrastructure, crucial for modern DevOps pipelines.