Horizontal Pod AutoscalerAdvanced
1Question 1 of 1
yamlHow does the Horizontal Pod Autoscaler (HPA) scale workloads automatically?
Explanation & Concept
The HPA automatically scales the number of Pod replicas in a Deployment based on observed metrics such as CPU utilization, memory, or custom Prometheus metrics.
Code Example
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web-deployment
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70How It Works & Key Takeaways
When average CPU exceeds 70%, HPA automatically spins up additional Pod replicas up to the configured `maxReplicas` threshold.
Mock Test · 1 Questions · Optional
Ready for RBAC (Role-Based Access Control)?
Take a quick test to evaluate yourself, or move straight to the next module.
Advanced1 questions