Skip to content

[kube-prometheus-stack] RuleSelector and defaultRules.additionalRuleGroupLabels missmatch #5008

Open
@Tehacz

Description

@Tehacz

Describe the bug a clear and concise description of what the bug is.

If we add custom label to defaulRules.additionalRuleGroupLabels.:
and then we configure prometheus.prometheusSpec.ruleSelector to match this label,

Prometheus config-reloader will not be able to pick up the rule based on the label, because it tries to fetch by prometheusRule.metadata.label instead of prometheusRule.spec.groups.rule.labels

What's your helm version?

3.16

What's your kubectl version?

1.31.0

Which chart?

kube-prometheus-stack

What's the chart version?

66.2.1

What happened?

In my values file i've used:

prometheus:
  prometheusSpec:
    ruleSelector:
      matchExpressions:
        - key: role
          operator: In
          values:
            - local-rules

and

defaultRules:
  create: true
  additionalRuleGroupLabels:
    k8sContainerCpuUsageSecondsTotal:
      role: local-rules

However configmap prometheus-rulefiles-0 had no data in it.

What you expected to happen?

It should only contain the k8sContainerCpuUsageSecondsTotal rules.

How to reproduce it?

Try to use my values and apply, prometheus-rulefiles-0 configmap will be empty, after that manualy add label to k8s resource PrometheusRule.metadata.labels and you will see that it gets loaded correctly

Enter the changed values of values.yaml?

No response

Enter the command that you execute and failing/misfunctioning.

--

Anything else we need to know?

On the other hand, when i looked into k8s.rule template in helm, it seems:

      labels:
        {{- with .Values.defaultRules.additionalRuleLabels }}
          {{- toYaml . | nindent 8 }}
        {{- end }}
        {{- with .Values.defaultRules.additionalRuleGroupLabels.k8sContainerCpuUsageSecondsTotal }}
          {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- end }}

addiotnalRuleLabels maybe should be moved up to metadata.labels instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions