#💡 쿠버네티스 환경에선?
$ vi my-app.yaml
spec:
replicas: 1
<중략>…
spec:
containers:
- name: my-app
image: nginx
resources:
requests:
cpu: “250m”
limits:
cpu: “500m”
$ kubectl top pod my-app-pod // 리소스 사용량 모니터링
scale 커맨드로 파드를 추가한다$ kubectl scale deployment my-app —replicas=3
Observes metrics : 지속적인 모니터링Adds pods: replicaset, deployment, pod, statefulset 의 파드 수를 자동으로 늘리거나 줄인다.Balances thresholds : 임계값의 균형을 맞춘다.Tracks multiple metrics : 메트릭을 추가한다.# 명령적 방식
$ kubectl autoscale deployment my-app \
--cpu-percent=50 --min=1 --max=10
$ kubectl get hpa
$ kubectl delete hpa
# 선언적 방식
$ vi my-app-hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef: // metric server가 타겟하여 모니터링 하는 개체
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas:1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: env
target:
type: Utilization
averageUtilization: 50