I can't find any examples as to where the behavior section should be specified in Kind: HorizontalPodAutoscaler
.
In the docs they have this section but I couldn't find any examples as where it should fit in?
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 100
periodSeconds: 15
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
- type: Pods
value: 4
periodSeconds: 15
selectPolicy: Max
Here is a sample auto-scaler.yml
without the behavior section
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: nginx
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: 100Mi
Talking specifically about your example you will need to paste your
.behavior
definition part under the.spec
like below:Please remember that this feature is available from Kubernetes v1.18.
Earlier version of Kubernetes will show following error:
As for a side note you can also take a look on:
$ kubectl autoscale
$ kubectl autoscale deployment nginx --min=1 --max=10 --cpu-percent=80
<- exampleAdditional reference: