Kubernetes: How to apply Horizontal Pod (HPA) autoscaling for a RC which contains multiple containers? Kubernetes: How to apply Horizontal Pod (HPA) autoscaling for a RC which contains multiple containers? kubernetes kubernetes

Kubernetes: How to apply Horizontal Pod (HPA) autoscaling for a RC which contains multiple containers?


By all means it is possible to set a HPA for an RC/Deployment/Replica-set with multiple containers. In my case the problem was the format of resource limit request. I figured out from this link, that if the pod's containers do not have the relevant resource request set, CPU utilization for the pod will not be defined and the HPA will not take any action for that metric. In my case I was using the resource request as below, which caused the error(But please note that the following resource request format works absolutely fine when I use it with deployments, replication controllers etc. It is only when, in addition I wanted to implement HPA that caused the problem mentioned in the question.)

    resources:      limits:        cpu: 2        memory: 200M      requests:        cpu: 1        memory: 100Mi

But after changing it like below(i.e., with a relevant resource request set that HPA can understand), it works fine.

    resources:      limits:        cpu: 2        memory: 200Mi      requests:        cpu: 1        memory: 100Mi