Skip to content
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

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

Open
Tehacz opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Tehacz
Copy link

Tehacz commented Nov 21, 2024

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?

@Tehacz Tehacz added the bug Something isn't working label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant