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

[Feature]: Specify addtional labels for PodMonitor #4435

Open
2 tasks done
nlamirault opened this issue May 4, 2024 · 0 comments · May be fixed by #4438
Open
2 tasks done

[Feature]: Specify addtional labels for PodMonitor #4435

nlamirault opened this issue May 4, 2024 · 0 comments · May be fixed by #4438
Assignees
Labels
triage Pending triage

Comments

@nlamirault
Copy link

Is there an existing issue already for this feature request/idea?

  • I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.

What problem is this feature going to solve? Why should it be added?

I create a PG cluster with monitoring enabled. A PodMonitor resource is created:

---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  annotations:
    cnpg.io/operatorVersion: 1.23.1
  creationTimestamp: "2024-05-03T16:12:34Z"
  generation: 1
  labels:
    cnpg.io/cluster: authentik
  name: authentik
  namespace: identity
  ownerReferences:
  - apiVersion: postgresql.cnpg.io/v1
    controller: true
    kind: Cluster
    name: authentik
    uid: 54d94e3b-a590-4dc4-b8fd-7925ff3699e4
  resourceVersion: "117090107"
  uid: 00755fb7-c757-40ba-bb72-68472d98834a
spec:
  namespaceSelector: {}
  podMetricsEndpoints:
  - bearerTokenSecret:
      key: ""
    port: metrics
  selector:
    matchLabels:
      cnpg.io/cluster: authentik

My Prometheus Operator load only PodMonitor/ServiceMonitor with a specific label like monitoring: infra.
So this PodMonitor for my PG cluster isn't loaded and I've got no monitoring.

Describe the solution you'd like

Possibility to add additional labels to PodMonitor resource.

Describe alternatives you've considered

The cloudnative-pg chart is setup using these values:

cloudnative-pg:
  monitoring:
    podMonitorEnabled: true
    podMonitorAdditionalLabels:
      monitoring: infra

It is correctly monitoring:

➜ kubectl -n database get podmonitors.monitoring.coreos.com cloudnativepg-cloudnative-pg -o yaml
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  labels:
    app.kubernetes.io/instance: cloudnativepg
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: cloudnative-pg
    app.kubernetes.io/version: 1.23.1
    argocd.argoproj.io/instance: cloudnativepg
    helm.sh/chart: cloudnative-pg-0.21.2
    monitoring: infra
  name: cloudnativepg-cloudnative-pg
  namespace: database
spec:
  podMetricsEndpoints:
  - port: metrics
  selector:
    matchLabels:
      app.kubernetes.io/instance: cloudnativepg
      app.kubernetes.io/name: cloudnative-pg

It could be fixed with additionalLabels for the cluster. Like that:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: authentik
spec:
  ....
  monitoring:
    enablePodMonitor: true
    additionalLabels:
      monitoring: infra

Additional context

No.

Backport?

Yes

Are you willing to actively contribute to this feature?

No

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nlamirault nlamirault added the triage Pending triage label May 4, 2024
@ma-ts ma-ts linked a pull request May 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Pending triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants