Skip to content

Commit

Permalink
chagen matchlabels to kind/namespace/name
Browse files Browse the repository at this point in the history
  • Loading branch information
saikey0379 committed Sep 11, 2022
1 parent 91d0cc3 commit 01a528d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/ehpa/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
Expand Down
9 changes: 7 additions & 2 deletions pkg/metricprovider/custom_metric_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 01a528d

Please sign in to comment.