'How to turn off autoscaling in Kubernetes with the kubectl command?

If I set to autoscale a deployment using the kubectl autoscale command (http://kubernetes.io/docs/user-guide/kubectl/kubectl_autoscale/), how can I turn it off and go back to manual scaling?



Solution 1:[1]

When you autoscale, it creates a HorizontalPodScaler.

You can delete it by:

kubectl delete hpa NAME-OF-HPA.

You can get NAME-OF-HPA from:

kubectl get hpa.

Solution 2:[2]

kubectl delete hpa ${name of hpa}

Horizontal Pod Autoscaler, like every API resource, is supported in a
standard way by kubectl. We can create a new autoscaler using kubectl create command. We can list autoscalers by kubectl get hpa and get detailed description by kubectl describe hpa. Finally, we can delete an autoscaler using kubectl delete hpa.

from official docs

Solution 3:[3]

kubectl delete horizontalpodautoscaler name_autoscaler_deployment -n namespace

Solution 4:[4]

instead of deleting the auto-scalar, if possible set min and max value nodes to same value(equal to current pods count). So that autoscaler won't do anything. if you want autoscaler feature agian then just update the min and max nodes.

Solution 5:[5]

Delete all of the HPAs within a namespace using the following command:

kubectl --namespace=MY_NAMESPACE get hpa | awk '{print $1}' | xargs kubectl --namespace=MY_NAMESPACE delete hpa

Solution 6:[6]

If you follow this example and if you are not able to terminate your load generator from the terminal (by typing Ctrl+C) then deleting only hpa doesn't actually terminate your deployment. In that case, you have to delete your deployments as well. In this example, you have two deployments:

$ kubectl get deployment (run this command to see deployments)

NAME -------- DESIRED -- CURRENT -- UP-TO-DATE - AVAILABLE - AGE

load-generator      1                1                1                 1                 1           d

php-apache      1                1                1                 1                 1           d

Then execute following commands to delete your deployments:

$ kubectl delete deployment load-generator

$ kubectl delete deployment php-apache

Solution 7:[7]

If you want to disable the effect of cluster Autoscaler temporarily then try the following method. you can enable and disable the effect of cluster Autoscaler(node level).

kubectl get deploy -n kube-system -> it will list the kube-system deployments. update the coredns-autoscaler or autoscaler replica from 1 to 0. So, the pod which is responsible for autoscaling will be terminated which means you have turned off the effect of Autoscaler. but the deployment is still there, and you can update the replica back to 1 to enable the Autoscaler effect on your cluster.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony
Solution 2 Ralf Stubner
Solution 3
Solution 4 Jawahar_GCT
Solution 5 Montoya
Solution 6
Solution 7 Jawahar_GCT