-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
#!/bin/bash
# 获取所有 HPA,检查其 ScaleTargetRef 是否存在
kubectl get hpa -A -o json | jq -r '.items[] | "\(.metadata.namespace) \(.metadata.name) \(.spec.scaleTargetRef.kind) \(.spec.scaleTargetRef.name)"' | while read ns hpa kind target; do
if ! kubectl -n $ns get $kind $target &>/dev/null; then
echo "Deleting orphan HPA $hpa in namespace $ns (target $kind/$target not found)"
kubectl -n $ns delete hpa $hpa
fi
done
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels