I would like to know, if HPA considers the mean of CPU utilization of multiple containers in a pod, in order to scale up/down the no. of pods. For instance, if I specify a HPA like below for a deployment(pod) that has 2 containers. In order for the HPA to scale up, does it require the CPU utilization to be reached to 80% in both the containers? In other words, If container A has CPU utilization of 80% but container B has CPU utilization of only 60%. Does that mean that the pods will not be scaled up by HPA. As far as I have observed, this is the case. But I am not sure about this, since there is no explicit statement regarding this in the kubernetes documentation. And unfortunately, I am not the best of developers to figure this out from the source code. Any help & if possible with reference, would be greatly appreciated. Thank you so much.
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: blackbox-rc-hpa
namespace: monitoring
spec:
scaleTargetRef:
apiVersion: v1
kind: extensions/v1beta1
name: blackbox
minReplicas: 1
maxReplicas: 4
targetCPUUtilizationPercentage: 80
The controller calculates the utilization value as a percentage on the containers in each pod and then takes the mean. So in your scenerio mean will be 70% https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/