Home > Software engineering >  Kubernetes Horizontal and Vertical Pod autoscaling togather
Kubernetes Horizontal and Vertical Pod autoscaling togather

Time:07-28

We are trying out Kubernetes Autoscaling options. We have configured for Horizontal Pod Autoscaling but was wondering if it is possible to implement both horizontal and vertical auto scaling condition for a particular application ? to explain more I want to be able to increase resource of a pod if I don't want to increase the number of pods and if I don't want to increase the pod resources I will be able to increase the number of pods to scale for the same application.

CodePudding user response:

Yes, it is definitely possible to set both Horizontal and Vertical Pod Autoscaling options. You will have to just set the resource limits appropriately. Here's an example:

  1. You configure a pod resource request for 300m CPU and limit for 800m CPU. This will configure the VPA to allow the pod to have 300m->800m of CPU.
  2. Then you configure HPA to scale-out if pod CPU is 800m.

Now, what will happen is, the pod will scale vertically, for up to 0.8 vCPU cores, and once it reaches that point, the horizontal auto scaler will kick in and spawn a new pod, and the existing pod will be limited to 0.8vCPU.

Here is a good resource on understanding a VPA setup and getting started with one.

Of course if you want your scaling to be driven by a custom metric, other than vCPU or memory, you will need a custom HPA or VPA controller in your cluster.

This is used a lot and is a very common design pattern :)

  • Related