redhat-cop / cert-utils-operator

Set of functionalities around certificates packaged in a Kubernetes operator
Apache License 2.0
95 stars 35 forks source link

Add ServiceMonitor to allow Metrics to be sent to Prometheus #30

Closed OchiengEd closed 3 years ago

OchiengEd commented 5 years ago

Given the operator already exposes a metrics endpoint through a service, I recommend creating a ServiceMonitor to sink the metrics to Prometheus.

This will eliminate the need for manual intervention to accomplish this task.

raffaelespazzoli commented 5 years ago

should this be added to the helm chart or created by the operator when it starts?

OchiengEd commented 5 years ago

It should not matter where it is added. It however makes sense to create the ServiceMonitor after the metrics service.

An example would appear as shown below.

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: cert-utils-service-monitor
  labels:
    role: metrics-sink
spec:
  selector:
    matchLabels:
      name: cert-utils-operator
  endpoints:
  - port: http-metrics
silverbp commented 3 years ago

This should have been done in helm with a default of not installing it to follow other community standards that have already been set on this. The code is making an assumption that you are using Prometheus in your k8s cluster, if you are not, the code fails and is unusable. If you are going to do this in code even though this is largely done in the helm chart with a flag, it should at minimum be configurable.

raffaelespazzoli commented 3 years ago

I agree. @trevorbox would you be able to fix this?