설명
HPA의 Object 메트릭에서 describedObject는 측정할 객체를, scaleTargetRef는 복제본 수를 조절할 워크로드를 지정합니다.
잠재적 영향
객체 참조가 불완전하거나 어댑터가 메트릭을 제공하지 않으면 부하가 늘어도 확장되지 않을 수 있습니다. 목표값이 부적절하면 복제본이 너무 많거나 적어질 수 있습니다.
해결 방법
- 측정할 객체의 이름, 종류와 API 버전을 확인하세요. 메트릭 이름과 목표 유형·값·단위가 어댑터에서 제공하는 지표와 맞아야 합니다.
- 확장할 워크로드의
scaleTargetRef와 최소·최대 복제본 수를 정하세요. 부하 시험에서 HPA 상태 조건, 이벤트와 실제 복제본 수를 확인하세요.
예시
Deployment, Ingress와 requests-per-second를 제공하는 어댑터를 준비하세요. 목표값 10k와 복제본 1~10개는 실제 부하에 맞게 조정하세요.
변경 전
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metric:
name: requests-per-second
target:
type: Value
value: 10k
describedObject:
apiVersion: networking.k8s.io/v1
kind: Ingress
측정할 Ingress의 이름이 빠져 있습니다.
변경 후
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metric:
name: requests-per-second
describedObject:
apiVersion: networking.k8s.io/v1
kind: Ingress
name: main-route
target:
type: Value
value: 10k
HPA는 main-route를 측정하고 php-apache Deployment의 복제본 수를 조절합니다.