File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
pkg/plugins/optional/helm/v2alpha/scaffolds
internal/templates/chart-templates Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,20 @@ func (s *editKustomizeScaffolder) Scaffold() error {
150150 // provide one via kustomize (../prometheus). This avoids duplicate objects
151151 // with the same name within the Helm chart.
152152 if ! hasPrometheus {
153- chartFiles = append (chartFiles , & charttemplates.ServiceMonitor {OutputDir : s .outputDir , NamePrefix : namePrefix })
153+ // Find the metrics service name from parsed resources
154+ metricsServiceName := namePrefix + "-controller-manager-metrics-service"
155+ for _ , svc := range resources .Services {
156+ if strings .Contains (svc .GetName (), "metrics-service" ) {
157+ metricsServiceName = svc .GetName ()
158+ break
159+ }
160+ }
161+
162+ chartFiles = append (chartFiles , & charttemplates.ServiceMonitor {
163+ OutputDir : s .outputDir ,
164+ NamePrefix : namePrefix ,
165+ ServiceName : metricsServiceName ,
166+ })
154167 }
155168
156169 // Generate template files from kustomize output
Original file line number Diff line number Diff line change @@ -29,11 +29,13 @@ var _ machinery.Template = &ServiceMonitor{}
2929// ServiceMonitor scaffolds a ServiceMonitor for Prometheus monitoring in the Helm chart
3030type ServiceMonitor struct {
3131 machinery.TemplateMixin
32- machinery.ProjectNameMixin
3332
3433 // Prefix
3534 NamePrefix string
3635
36+ // ServiceName is the full name of the metrics service, derived from Kustomize
37+ ServiceName string
38+
3739 // OutputDir specifies the output directory for the chart
3840 OutputDir string
3941}
7274 bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
7375 tlsConfig:
7476 {{ "{{- if .Values.certManager.enable }}" }}
75- serverName: {{ .NamePrefix }}-controller-manager-metrics-service .{{ "{{ .Release.Namespace }}" }}.svc
77+ serverName: {{ .ServiceName }}.{{ "{{ .Release.Namespace }}" }}.svc
7678 # Apply secure TLS configuration with cert-manager
7779 insecureSkipVerify: false
7880 ca:
You can’t perform that action at this time.
0 commit comments