Description
For an HPA Object metric, described_object identifies what to measure. scale_target_ref identifies the workload whose replica count changes. Resource or Pods metrics may suit other workloads.
Potential impact
The HPA cannot scale on a metric the adapter does not provide. Incorrect units or targets can produce too many or too few replicas.
Remediation
Check the measured object’s name, kind and API version alongside the metric name, target type and value. Set the scale target and replica bounds separately. Under load, check the HPA conditions, events and actual replica count.
Examples
The second excerpt measures latency on the main-route Ingress. The target 100 and 50–100 replicas are illustrative. For a current deployment, use kubernetes_horizontal_pod_autoscaler_v2, a supported Ingress API, a scale target and a metrics adapter.
Before
resource "kubernetes_horizontal_pod_autoscaler" "example" {
metadata {
name = "test"
}
spec {
min_replicas = 50
max_replicas = 100
metric {
type = "Object"
object {
target {
type = "Value"
value = "100"
}
}
}
}
}
After
resource "kubernetes_horizontal_pod_autoscaler" "example" {
metadata {
name = "test"
}
spec {
min_replicas = 50
max_replicas = 100
metric {
type = "Object"
object {
metric {
name = "latency"
}
described_object {
name = "main-route"
api_version = "networking.k8s.io/v1beta1"
kind = "Ingress"
}
target {
type = "Value"
value = "100"
}
}
}
}
}