What does "prometheus-operated" service do?

Viewed 866

Prometheus-operator seems to generate promethues-operated service which just points to Prometheus instance at port 9090.

What does this service do? We define other services to point at our Prometheus cluster.

What would be repercussions on removing prometheus-operated service?

1 Answers

Based on the documentation, prometheus-operated is a governing service for statefulsets, in other words it's Prometheus's service endpoint which is used for its functioning.

Below are some references:

What you are referring to is the governing service that point to the synthesized Prometheus statefulsets. In the case of a second Prometheus in the same namespace the same governing service will be referenced, which in turn will add the IPs of all pods of the separate Prometheus instances to the same governing service.

Taken from Rename Prometheus Operator Service #3805

Also another reference to the same idea:

The Prometheus Operator reconciles services called prometheus-operated and alertmanager-operated, which are used as governing Services for the StatefulSets. To perform this reconciliation

Taken from Prometheus operator/Documentation/readme

One more commit that confirms that prometheus-operated is a governing service:

pkg/prometheus: add Thanos service port to governing service Currently, for service discovery of Prometheus instances a separate headless service must be deployed.

This adds the Thanos grpc port to the existing Prometheus statefulset governing service if a Thanos sidecar is given in the Prometheus custom resource specification.

This way no additional service has to be deployed.

Taken from pkg/prometheus: add Thanos service port to governing service #2754


What would be repercussions on removing prometheus-operated service.

It's quite old answer, but since this is a part of Prometheus and Prometheus components will fail if the service is removed:

The prometheus-operated service is an implementation detail of the Prometheus Operator, it should not be touched, especially as all Prometheus instances will be registered in this service

Taken from kube-prometheus chart creates 3 different services pointing to the same pods #522


Code where this service is created

Taking into consideration that:

const (
    governingServiceName            = "prometheus-operated"
    ...
)
Related