这是我的HPA。我想使用默认副本开始部署=3
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: backend-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: backend
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: 500Mi
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 1
periodSeconds: 100
scaleUp:
stabilizationWindowSeconds: 60
policies:
- type: Pods
value: 1
periodSeconds: 30
- type: Percent
value: 10
periodSeconds: 60
selectPolicy: Max
但它总是说:ScalingLimited True TooFewReplicas所需的副本计数小于最小副本计数我不明白为什么。
➜ kg hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
prod-backend-hpa-v1 Deployment/prod-backend-v1 145881770666m/500Mi, 2%/70% 3 20 3 7m16s
➜ kd hpa
Name: prod-backend-hpa-v1
Namespace: prod
Labels: argocd.argoproj.io/instance=backend-prod
Annotations: <none>
CreationTimestamp: Thu, 02 Jun 2022 19:34:30 -0500
Reference: Deployment/prod-backend-v1
Metrics: ( current / target )
resource memory on pods: 145596416 / 500Mi
resource cpu on pods (as a percentage of request): 1% (3m) / 70%
Min replicas: 3
Max replicas: 20
Behavior:
Scale Up:
Stabilization Window: 60 seconds
Select Policy: Max
Policies:
- Type: Pods Value: 1 Period: 30 seconds
- Type: Percent Value: 10 Period: 60 seconds
Scale Down:
Stabilization Window: 300 seconds
Select Policy: Max
Policies:
- Type: Pods Value: 1 Period: 100 seconds
Deployment pods: 3 current / 3 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True ReadyForNewScale recommended size matches current size
ScalingActive True ValidMetricFound the HPA was able to successfully calculate a replica count from memory resource
ScalingLimited True TooFewReplicas the desired replica count is less than the minimum replica count
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulRescale 9m22s horizontal-pod-autoscaler New size: 3; reason: Current number of replicas below Spec.MinReplicas
➜ kgpo
NAME READY STATUS RESTARTS AGE
prod-backend-v1-8dd687999-54mzp 1/1 Running 0 58m
prod-backend-v1-8dd687999-nn7c2 1/1 Running 0 2d17h
prod-backend-v1-8dd687999-rcxsw 1/1 Running 0 2d17h
➜ kg rs
NAME DESIRED CURRENT READY AGE
prod-backend-v1-566b9c8856 0 0 0 2d19h
prod-backend-v1-578d699c45 0 0 0 2d19h
prod-backend-v1-64859b74c9 0 0 0 2d18h
prod-backend-v1-6498b4b45c 0 0 0 2d19h
prod-backend-v1-656cccdc4b 0 0 0 2d19h
prod-backend-v1-66cc5cf44 0 0 0 2d19h
prod-backend-v1-698c7ddc7d 0 0 0 2d19h
prod-backend-v1-6bdbc77f5d 0 0 0 2d19h
prod-backend-v1-7486c95664 0 0 0 2d19h
prod-backend-v1-774cdbdcdc 0 0 0 2d19h
prod-backend-v1-8dd687999 3 3 3 2d17
水平pod自动缩放器,由HorizontalPodAutoscaler定义对象,指定系统应如何根据从属于该复制控制器或部署配置的pod收集的指标自动增加或减少复制控制器或部署配置的规模。
ScalingLimited指示不允许自动缩放,因为已达到最大或最小副本计数。
- 对condition指示您需要提高或降低最小或最大副本计数以进行缩放。
- 假条件表示允许请求的缩放。
根据您的用例,ScalingLimited显示状态为" True "消息"期望的副本计数小于最小副本计数"。因此,作为一种解决方案,您可以增加minReplicas或设置scaleDown策略与大周期来增加稳定周期。
更多信息请参考Pod自动缩放。