Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have Kubernetes cluster hosted in Google Cloud. I created a deployment and defined a hpa rule for it:

kubectl autoscale deployment my_deployment --min 6 --max 30 --cpu-percent 80

I want to run a command that editing the --min value, without remove and re-create a new hpa rule. Something like:

$ kubectl autoscale deployment my_deployment --min 1 --max 30
Error from server (AlreadyExists): horizontalpodautoscalers.autoscaling "my_deployment" already exists

Is this possible to edit hpa (min, max, cpu-percent, ...) on command line?

They are editable just as any other resource is, though either kubectl edit hpa $the_hpa_name for an interactive edit, or kubectl patch hpa $the_hpa_name -p '{"spec":{"minReplicas": 1}}' for doing so in a "batch" setting.

If you don't know the $the_hpa_name, you can get a list of them like any other resource: kubectl get hpa, and similarly you can view the current settings and status with kubectl get -o yaml hpa $the_hpa_name (or even omit $the_hpa_name to see them all, but that might be a lot of text, depending on your cluster setup).

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.