0

I tried to create a kubernetes horizontal pod autoscaler with specific name (ttt), but it didn't work as expected:

$ kubectl autoscale deployment hello-web --cpu-percent=50 --min=2 --max=10 --name=ttt
horizontalpodautoscaler.autoscaling/hello-web autoscaled
$ kubectl get hpa
NAME        REFERENCE              TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
hello-web   Deployment/hello-web   <unknown>/50%   2         10        0          5s
Everton
  • 113
  • 6

1 Answers1

1

I have tried many combinations of this --name option in autoscale and it did not work for me also.

There is an option to do this other way. If you already have hpa created from CLI you can obtain autoscale yaml file.

1) Obtain YAML file from your hpa

kubectl get hpa/<your_hpa_name> -o yaml --export > hpa.yaml

2) Open this file

vi hpa.yaml

3) Edit name in it (you can also edit or add here many HPA options)

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:    
  name: <your name>
...

and save file.

4) Delete old deployment

kubectl delete hpa <old_hpa_name>

5) Apply new hpa with new name

kubectl apply -f hpa.yaml

You can also create HPA directly from YAML file.

MWZ
  • 128
  • 5
PjoterS
  • 615
  • 3
  • 11