How to isolate some Containers from Kubernetes Horizontal Pod Autoscaler

7/16/2019

With a Horizontal Pod Autoscaler implemented for the Deployment running a Pod with two different containers: Containers-A and Contaner-B, I want to make sure that it only scales the number of Containers-A. The number of Containers-B should always be the same and not being effected by the Pod's Autoscaler. I wonder if isolating the Container-B from Autoscaler would be possible. If so, how to achieve it?

kubectl autoscale my-deployment --min=10 --max=15 --cpu-percent=80
-- alphanumeric
containers
docker
eks
kubernetes

1 Answer

7/16/2019

As the name suggests "Horizontal Pod Autoscaler" scales pods, not containers.

However, I do not see a reason why you would want this behavior.

You should have more than one container in a Pod only if those containers are tightly coupled together and need to share resources. The fact that you want to scale container A and B independently, tells me that those containers are not tightly coupled.

I would suggest the following approach:

  1. Deployment A that manages Pods with container A. The Autoscaler will only scale the pods for this deployment.

  2. Deployment B that manages Pods with container B. This deployment will not be affected by the autoscaler.

-- cecunami
Source: StackOverflow