Is there any HPA like controller that can scale up/down pods on demand?

7/16/2019

So, in my use case i need to scale up an application when an event happens in the system.

HPA will not help here - as i don't want the pods to scale down when the metric is met, nor i don't want the pods to keep scaling up (as what HPA does - scales up until it meets its criteria, and then scale down).

The scale down should happen when another event happens, thus the logic is:

  1. Event is raised in the system
  2. Deployment is scaled by 1
  3. Work continues
  4. Another "scale down" event is raised from the system
  5. Deployment is scaled down by 1

Should i just write a different pod that accesses the k8s API and scales up/down the deployment? it feels to me that something like that already exists but i'm missing something

-- ArielB
horizontal-scaling
kubernetes
scale

1 Answer

7/22/2019

In this scenario I would look at admission Webhooks, a comprehensive way to interact with K8s API server that can modify the basic behavior of some Kubernetes features by representing a Dynamic admission control model.

It means that you can implement special controllers that can intercept Kubernetes API requests, and modify or reject them based on custom logic.Thus, you can create either ValidatingWebhookConfiguration or MutatingWebhookConfiguration admission webhooks; the only difference validating webhooks can reject a request, but they cannot modify the object they are receiving in the admission HTTP request, while mutating webhooks can modify objects by creating a patch that will be sent back in the admission HTTP response. I would propose to get more relevant information in this tutorial.

According to the above said, it might be feasible to scale up or down relevant deployment resource based on the mutating rules in MutatingWebhookConfiguration within AdmissionReview API object as described in the official K8s documentation.

-- mk_sta
Source: StackOverflow