metricsQuery is the actual Prometheus query that needs to be performed to calculate the actual values.Ĥ. resources tells which Kubernetes resources each metric is associated with or which labels does the metric include, e.g., namespace, pod etc.ģ. seriesQuery tells the Prometheus Metric name to the adapter Ģ. The adapter considers metrics defined with the parameters below:ġ. Understanding Prometheus Adapter Configuration You can see the metrics value of all the replicas in the output.ī. Once the charts are deployed, verify the metrics are exposed at 8s.io: By defining our own metrics through the adapter’s configuration, we can let HPA perform scaling based on our custom metrics.Ĭreate prometheus-adapter.yaml with the content below: We will use the prometheus-adapter resource to expose custom application metrics to /v1beta1, which are retrieved by HPA. So, the replicas are scaled up to 6 in this case.
NOTE: It’s recommended not to use HPA and VPA on the same pods or deployments. In this blog post, I have used the config below to create a deployment of 3 replicas, with some memory load defined by “ -vm-bytes", "850M”. Setup: Create a Deployment and HPA resource It compares the current metric value with the target metric value specified in the HPA spec and produces a ratio used to scale the number of desired replicas.Ī.
HPA fetches per-pod resource metrics (like CPU, memory) from the resource metrics API and calculates the current metric value based on the mean values of all targeted pods. Verify that the metrics-server is already deployed and running using the command below, or deploy it using instructions here.ĬODE: HPA using Multiple Resource Metrics Fig:- Horizontal Pod Autoscaling Prerequisite