-
Notifications
You must be signed in to change notification settings - Fork 0
feat: added service monitor for metrics #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and cobaltcore-dev contributors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| {{- if .Values.serviceMonitor.create }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "openstack-hypervisor-operator.fullname" . }}-metrics | ||
| labels: | ||
| control-plane: controller-manager | ||
| {{- include "openstack-hypervisor-operator.labels" . | nindent 4 }} | ||
| {{- with .Values.serviceMonitor.labels }} | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.serviceMonitor.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| jobLabel: control-plane | ||
| selector: | ||
| matchLabels: | ||
| control-plane: controller-manager | ||
| {{- include "openstack-hypervisor-operator.selectorLabels" . | nindent 6 }} | ||
| namespaceSelector: | ||
| matchNames: | ||
| - {{ .Release.Namespace }} | ||
| endpoints: | ||
| - port: https | ||
| scheme: https | ||
| tlsConfig: | ||
| insecureSkipVerify: true | ||
| bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
|
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether insecure TLS is currently hardcoded and if a value toggle already exists.
rg -n -C3 'insecureSkipVerify|tlsConfig|serviceMonitor\..*insecure|caFile|serverName' charts/openstack-hypervisor-operatorRepository: cobaltcore-dev/openstack-hypervisor-operator Length of output: 897 🏁 Script executed: find charts/openstack-hypervisor-operator -name "values*.yaml" -o -name "values*.yml" | head -20Repository: cobaltcore-dev/openstack-hypervisor-operator Length of output: 136 🏁 Script executed: cat -n charts/openstack-hypervisor-operator/templates/servicemonitor.yamlRepository: cobaltcore-dev/openstack-hypervisor-operator Length of output: 1941 🏁 Script executed: rg -A 10 "serviceMonitor:" charts/openstack-hypervisor-operator/values* | head -50Repository: cobaltcore-dev/openstack-hypervisor-operator Length of output: 272 Make TLS verification configurable with secure defaults. The Consider also adding optional support for 🤖 Prompt for AI Agents |
||
| {{- with .Values.serviceMonitor.interval }} | ||
| interval: {{ . }} | ||
| {{- end }} | ||
| {{- with .Values.serviceMonitor.scrapeTimeout }} | ||
| scrapeTimeout: {{ . }} | ||
| {{- end }} | ||
| {{- with .Values.serviceMonitor.metricRelabelings }} | ||
| metricRelabelings: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.serviceMonitor.relabelings }} | ||
| relabelings: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: cobaltcore-dev/openstack-hypervisor-operator
Length of output: 20446
🏁 Script executed:
Repository: cobaltcore-dev/openstack-hypervisor-operator
Length of output: 3296
🏁 Script executed:
Repository: cobaltcore-dev/openstack-hypervisor-operator
Length of output: 2317
🏁 Script executed:
Repository: cobaltcore-dev/openstack-hypervisor-operator
Length of output: 295
🏁 Script executed:
Repository: cobaltcore-dev/openstack-hypervisor-operator
Length of output: 1635
Update metrics RBAC binding to target the Prometheus scraper's ServiceAccount instead of the operator's.
The metrics endpoint has authentication and authorization enforced (via
--metrics-secure=trueand theWithAuthenticationAndAuthorizationfilter in cmd/main.go), but themetrics-readerrole is currently bound to the operator ServiceAccount. The ServiceMonitor scrapes using the bearer token from Prometheus's own ServiceAccount (line 33 of servicemonitor.yaml), creating a token-to-RBAC mismatch that will cause 403 errors.To fix this, the binding must target the Prometheus scraper's ServiceAccount. However, the suggested configuration path (
.Values.serviceMonitor.scrapeServiceAccount) does not exist in the values.yaml. Define this configuration in the values schema, then update the binding subjects to reference it:Additionally, ensure the Prometheus ServiceAccount exists and is correctly referenced by the ServiceMonitor.
🤖 Prompt for AI Agents