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 Horizontal Pod Autoscaler changes the shape of your Kubernetes workload by automatically increasing or decreasing the number of Pods in response to the workload's CPU or memory consumption, or in response to custom metrics reported from within Kubernetes or external metrics from sources outside of your cluster.
HPA is a form of autoscaling that increases or decreases the number of pods in a replication controller, deployment, replica set, or stateful set based on CPU utilization—the scaling is horizontal because it affects the number of instances rather than the resources allocated to a single container.
In Kubernetes, a HorizontalPodAutoscaler automatically updates a workload resource (such as a Deployment or StatefulSet), with the aim of automatically scaling the workload to match demand. Horizontal scaling means that the response to increased load is to deploy more Pods.
HPA calculates pod utilization as total usage of all containers in the pod divided by total request. It looks at all containers individually and returns if container doesn't have request.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With