kuberneteskubectlhpahorizontal-pod-autoscaling

Need a way to temporarily disable HPA


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?


Solution

  • 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.