From 690d7a271136cccad1622ec455ceee73dbae425b Mon Sep 17 00:00:00 2001 From: zhangtao <111836083+sophon-zt@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:26:36 +0800 Subject: [PATCH] chore: update headless svc labels for the prometheus scrape job (#8088) --- pkg/constant/labels.go | 7 +++++++ pkg/controller/instanceset/object_builder.go | 1 + 2 files changed, 8 insertions(+) diff --git a/pkg/constant/labels.go b/pkg/constant/labels.go index d4ae2d50bbda..8fee18e22c4e 100644 --- a/pkg/constant/labels.go +++ b/pkg/constant/labels.go @@ -99,6 +99,13 @@ func GetClusterWellKnownLabels(clusterName string) map[string]string { } } +// GetKBKnownLabels returns the kb-known labels for the headless svc +func GetKBKnownLabels() map[string]string { + return map[string]string{ + AppManagedByLabelKey: AppName, + } +} + // GetComponentWellKnownLabels returns the well-known labels for Component API func GetComponentWellKnownLabels(clusterName, componentName string) map[string]string { return map[string]string{ diff --git a/pkg/controller/instanceset/object_builder.go b/pkg/controller/instanceset/object_builder.go index 097f5835f7a8..b1bd1fa2ce2d 100644 --- a/pkg/controller/instanceset/object_builder.go +++ b/pkg/controller/instanceset/object_builder.go @@ -54,6 +54,7 @@ func buildHeadlessSvc(its workloads.InstanceSet, labels, selectors map[string]st annotations := ParseAnnotationsOfScope(HeadlessServiceScope, its.Annotations) hdlBuilder := builder.NewHeadlessServiceBuilder(its.Namespace, getHeadlessSvcName(its.Name)). AddLabelsInMap(labels). + AddLabelsInMap(constant.GetKBKnownLabels()). AddSelectorsInMap(selectors). AddAnnotationsInMap(annotations). SetPublishNotReadyAddresses(true)