sloth icon indicating copy to clipboard operation
sloth copied to clipboard

Add extra labels to prometheusRule object

Open Typositoire opened this issue 2 years ago • 1 comments

Why?

In our case, PrometheusRule requires labels to be picked up.

Disclaimer

I think I did it right? It works (tested on my clusters), but Golang development is a hobby for me xD I'm a system administrator. Let me know if you want me to change something

Typositoire avatar May 16 '22 15:05 Typositoire

Hi @Typositoire

The Kubernetes CR labels will be set on the resulting generated Prometheus operator CRs automatically. E.g:

apiVersion: sloth.slok.dev/v1
kind: PrometheusServiceLevel
metadata:
  name: test
  labels:
    prometheus: custom-prometheus-instance

->

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    app.kubernetes.io/component: SLO
    app.kubernetes.io/managed-by: sloth
    prometheus: custom-prometheus-instance
  name: test

The resulting generated k8s resources will have prometheus: custom-prometheus-instance.

slok avatar Jun 19 '22 07:06 slok

Can this be merged?

ayushghosh avatar Aug 15 '22 17:08 ayushghosh

Doesn't this work for you? https://github.com/slok/sloth/pull/315#issuecomment-1159643273

slok avatar Aug 15 '22 17:08 slok

Works!

ayushghosh avatar Aug 15 '22 17:08 ayushghosh

Closing so people don't get confused that without this PR, can't be achieved the extra-labels on generated prometheus-operator rules. Use https://github.com/slok/sloth/pull/315#issuecomment-1159643273

Thanks @Typositoire!

slok avatar Aug 15 '22 18:08 slok