12.2. Autoscaling#
An Autoscaler creates more instances of your pods when the need arises. In this lab we’ll adapt the steps in Kubernetes’ Horizontal Pod Autoscaling Walkthrough.
Add this resource to your deployment directory:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: django
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: django
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50