k8sgpt-ai / k8sgpt-operator

Automatic SRE Superpowers within your Kubernetes cluster
https://k8sgpt.ai
Apache License 2.0
320 stars 92 forks source link

[Bug Report]: Service Monitor Missing Prometheus Release Lable #528

Open luisvieirajs opened 1 month ago

luisvieirajs commented 1 month ago

Checklist

Affected Components

K8sGPT Version

0.2.0

Kubernetes Version

0.0.26

Host OS and its Version

No response

Steps to reproduce

helm upgrade --install k8sgpt \ k8sgpt/k8sgpt-operator -n k8sgpt-operator-system \ --create-namespace \ --set serviceMonitor.enabled=true \ --set grafanaDashboard.enabled=true \ --wait

Expected behaviour

Deploy k8sgtp service monitor without prometheus label "release: prometheus" required by the prometheus service discovery

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
meta.helm.sh/release-name: k8sgpt
meta.helm.sh/release-namespace: k8sgpt-operator-system
creationTimestamp: "2024-10-01T21:46:19Z"
generation: 1
labels:
app.kubernetes.io/component: metrics
app.kubernetes.io/created-by: k8sgpt-operator
app.kubernetes.io/instance: k8sgpt
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: k8sgpt-operator
app.kubernetes.io/part-of: k8sgpt-operator
app.kubernetes.io/version: 0.0.26
control-plane: controller-manager
helm.sh/chart: k8sgpt-operator-0.2.0

name: k8sgpt-k8sgpt-operator-controller-manager-metrics-monitor ### Actual behaviour _No response_ ### Additional Information _No response_
angelaaaaaaaw commented 1 month ago

I manage to use below as workaround

kubectl -n k8sgpt-operator-system patch serviceMonitor release-k8sgpt-operator-controller-manager-metrics-monitor -p '{"metadata":{"labels":{"release":"prometheus"}}}' --type=merge

luisvieirajs commented 1 month ago

This is an known workaround. Please don't respond This Bug Report with such solution. I am not looking for workarounds. I won't propose to a Enterprise client to automate their processes running command line stuff.

nlamirault commented 4 days ago

@luisvieirajs you could use additionalLabels for that: https://github.com/k8sgpt-ai/k8sgpt-operator/blob/main/chart/operator/values.yaml#L8

serviceMonitor:
  enabled: true
  additionalLabels:
    release: prometheus