Skip to main content

KA-X008: HPA targets non-existent resource

Warning Cross-Resource

Why This Matters

A HorizontalPodAutoscaler references a scaleTargetRef that is not defined in the manifest. The HPA will be unable to scale the target and will report "unable to get metrics" errors. Custom resource types (CRDs) are skipped since they cannot be validated from the manifest alone.

How to Fix

Add the HPA target resource to the manifest or correct the scaleTargetRef

Before (incorrect)

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: missing-deploy

After (correct)

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-deploy
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deploy

Rule Details

Rule Code
KA-X008
Severity
Warning
Category
Cross-Resource

Related Rules