diff --git a/pkg/controller/ehpa/predict.go b/pkg/controller/ehpa/predict.go index 8a8232d8c..3cacb8556 100644 --- a/pkg/controller/ehpa/predict.go +++ b/pkg/controller/ehpa/predict.go @@ -110,6 +110,9 @@ func (c *EffectiveHPAController) NewPredictionObject(ehpa *autoscalingapi.Effect "app.kubernetes.io/name": name, "app.kubernetes.io/part-of": ehpa.Name, "app.kubernetes.io/managed-by": known.EffectiveHorizontalPodAutoscalerManagedBy, + "app.kubernetes.io/target-kind": ehpa.Spec.ScaleTargetRef.Kind, + "app.kubernetes.io/target-namespace": ehpa.Namespace, + "app.kubernetes.io/target-name": ehpa.Spec.ScaleTargetRef.Name, known.EffectiveHorizontalPodAutoscalerUidLabel: string(ehpa.UID), }, }, diff --git a/pkg/metricprovider/custom_metric_provider.go b/pkg/metricprovider/custom_metric_provider.go index 22067eaa8..88f98665b 100644 --- a/pkg/metricprovider/custom_metric_provider.go +++ b/pkg/metricprovider/custom_metric_provider.go @@ -235,8 +235,13 @@ func GetPredictions(ctx context.Context, kubeclient client.Client, namespace str matchingLabels := client.MatchingLabels(map[string]string{"app.kubernetes.io/managed-by": known.EffectiveHorizontalPodAutoscalerManagedBy}) // merge metric selectors for key, value := range labelSelector { - if key == "targetName" { - matchingLabels["app.kubernetes.io/part-of"] = value + switch key { + case "targetKind": + matchingLabels["app.kubernetes.io/target-kind"] = value + case "targetNamespace": + matchingLabels["app.kubernetes.io/target-namespace"] = value + case "targetName": + matchingLabels["app.kubernetes.io/target-name"] = value } }