Skip to content

[K8S][HELM] Support additional labels for PrometheusRule #7105

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

Closed
wants to merge 1 commit into from

Conversation

dnskr
Copy link
Contributor

@dnskr dnskr commented Jun 17, 2025

Why are the changes needed?

The change is needed to be able to add additional labels to PrometheusRule similar to podMonitor and serviceMonitor.
The PR also includes minor identation fixes.

How was this patch tested?

helm template kyuubi charts/kyuubi --set metrics.prometheusRule.enabled=true --set metrics.prometheusRule.labels.test-label=true -s templates/kyuubi-alert.yaml
---
# Source: kyuubi/templates/kyuubi-alert.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: kyuubi
  labels:
    helm.sh/chart: kyuubi-0.1.0
    app.kubernetes.io/name: kyuubi
    app.kubernetes.io/instance: kyuubi
    app.kubernetes.io/version: "1.10.0"
    app.kubernetes.io/managed-by: Helm
    test-label: true
spec:
  groups:
    []

Was this patch authored or co-authored using generative AI tooling?

No

Signed-off-by: dnskr <dnskrv88@gmail.com>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (5237227) to head (234d99d).

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #7105   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         697     697           
  Lines       43214   43214           
  Branches     5855    5855           
======================================
  Misses      43214   43214           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -23,7 +23,7 @@ metadata:
labels:
{{- include "kyuubi.labels" . | nindent 4 }}
{{- if .Values.metrics.podMonitor.labels }}
{{- toYaml .Values.metrics.podMonitor.labels | nindent 4 }}
{{- toYaml .Values.metrics.podMonitor.labels | nindent 4 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... why keep 6 leading spaces but | nindent 4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is quite a common pattern to use indentation for blocks to improve the readability of templates and it is mentioned in Best Practices for templates.

For instance, if we add common labels to all metric resources, the template without indentation looks as follows:

metadata:
  name: {{ .Release.Name }}
  labels:
    {{- include "kyuubi.labels" . | nindent 4 }}
    {{- if .Values.metrics.labels }}
    {{- toYaml .Values.metrics.labels | nindent 4 }}
    {{- end }}
    {{- if .Values.metrics.podMonitor.labels }}
    {{- toYaml .Values.metrics.podMonitor.labels | nindent 4 }}
    {{- end }}

but with indentation, it would be clearer that we have three sources for labels:

metadata:
  name: {{ .Release.Name }}
  labels:
    {{- include "kyuubi.labels" . | nindent 4 }}
    {{- if .Values.metrics.labels }}
      {{- toYaml .Values.metrics.labels | nindent 4 }}
    {{- end }}
    {{- if .Values.metrics.podMonitor.labels }}
      {{- toYaml .Values.metrics.podMonitor.labels | nindent 4 }}
    {{- end }}

@pan3793 pan3793 added this to the v1.11.0 milestone Jun 23, 2025
@pan3793 pan3793 closed this in 2021574 Jun 23, 2025
@pan3793
Copy link
Member

pan3793 commented Jun 23, 2025

Thanks, merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants