Я настроил HPA в моем кластере AKS для определенной службы. Ниже приведен файл манифеста для моей службы:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
fluxcd.io/automated: "true"
creationTimestamp: null
labels:
io.kompose.service: productservice
name: productservice
spec:
selector:
matchLabels:
io.kompose.service: productservice
strategy: {}
template:
metadata:
annotations:
kompose.cmd: C:\ProgramData\chocolatey\lib\kubernetes-kompose\tools\kompose.exe
convert
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: productservice
spec:
imagePullSecrets:
- name: xxxxx
containers:
image: xxxxxx/productservice:9999
imagePullPolicy: ""
name: productservice
ports:
- containerPort: 80
resources:
requests:
cpu: "250m"
limits:
cpu: "500m"
restartPolicy: Always
serviceAccountName: ""
volumes: null
status: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: C:\ProgramData\chocolatey\lib\kubernetes-kompose\tools\kompose.exe
convert
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: productservice
name: productservice
spec:
type: LoadBalancer
ports:
- name: "5020"
port: 5020
targetPort: 80
selector:
io.kompose.service: productservice
status:
loadBalancer: {}
Ниже приведен мой файл HPA для службы продуктов:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: productservice-hpa
namespace: default
spec:
maxReplicas: 5 #define max replica counts
minReplicas: 2 #define min replica count
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: productservice
targetCPUUtilizationPercentage: 15
Обратите внимание, что даже когда трафик c сокращается, а загрузка ЦП становится 0%, значит, уменьшение также не происходит. Мы оставили кластер как есть без трафика c на ночь, реплики не уменьшились. Что мне здесь не хватает, что масштабирования не происходит?