Skip to content

HPA metric types (Resource/Pods/Object/External)

Horizontal Pod Autoscaler (HPA) supports four primary metric types to determine scaling behavior, defined under the spec.metrics field. These allow scaling based on standard resources, pod-specific statistics, Kubernetes objects, or external systems.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

Metric Types

Resource

The Resource metric type refers to known Kubernetes resources, specifically CPU and memory.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

  • Target Type: Typically Utilization, setting a target as a percentage of the resource request (e.g., averageUtilization: 50).^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]
  • Usage: It describes Metrics for each Pod in the scaling target and averages them across all relevant Pods.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

Pods

The Pods metric type refers to Metrics that originate from each Pod in the scaling target.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

  • Target Type: Uses AverageValue, which targets a specific numeric quantity averaged across all Pods.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]
  • Selector: Can utilize a selector (acting as a labelSelector) to specify the exact metric scope; if unset, it defaults to the metricName.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

Object

The Object metric type refers to a single Kubernetes object (e.g., an Ingress) rather than the Pods being scaled.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

  • Target Type: Uses Value or AverageValue to target a specific numeric quantity.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]
  • Configuration: Requires describedObject to identify the referenced resource (e.g., kind: Ingress) and may use a selector to constrain the metric collection scope.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

External

The External metric type allows scaling based on Metrics outside of the Kubernetes cluster, such as those from a monitoring system or a Message Queue.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

  • Target Type: Typically uses AverageValue (e.g., scaling based on the number of messages in a queue).^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]
  • Configuration: Requires a metric block with name and optionally matchLabels to identify the specific metric.^[400-devops-06-kubernetes-k8s-ithelp-day26-readme.md]

Sources

  • 400-devops-06-kubernetes-k8s-ithelp-day26-readme.md