Need a way to temporarily disable HPA

999 views Asked by At

I am working on an STS based application and I want to temporarily disable HPA without deleting it. How can I achieve it?

I can't delete the HPA because if I delete it and again deploy the service then the HPA is created from STS and the name in STS and hpa.yaml is different. So, I don't want to delete it and I can't create using hpa.yaml using kubectl as per requirement.

So, is there any way I can disable and again enable it either using kubectl or make any changes to hpa.yaml file?

2

There are 2 answers

0
beingumang On BEST ANSWER

I deleted and Created Again using the same name:

kubectl autoscale statefulset <sts_name> --name=<hpa_name_deleted> --min=<min_replica> --max=<max_replica> --cpu-percent=<cpu_percent> --memory=<target_memory> -n <namespace>

I did not find any way to disable it temporarily.

0
David M. Karr On

The HPA will have a "target", being a deployment, statefulset, or whatever. If you change the name of that target to something that doesn't exist, it is effectively disabled. Use a convention of adding a suffix to the name, like "-disabled", or whatever works for you.