Should I use a Prometheus Kubernetes SD config of Pod or Endpoint?

Viewed 350

Prometheus supports multiple roles in its Kubernetes SD config

I'm confused about whether I should use a Pod config or a endpoints role for my Deployment + Service.

The service I am monitoring is a Deployment

apiVersion: apps/v1
kind: Deployment
spec:
 replicas: ~10
 strategy:
    rollingUpdate:
      maxSurge: 5
      maxUnavailable: 0
    type: RollingUpdate
 template:
  containers: 
  - name: web-app
    ports: 
    - containerPort: 3182
      name: http
    - containerPort: 6060
      name: metrics
apiVersion: v1
kind: Service
metadata:
  name: web-app
spec:
  ports:
  - name: http
    port: 3182
    targetPort: http
  selector:
    app: web-app
  type: ClusterIP

The number of pods can vary in the deployment. The deployment is continuously being updated with new images.

I can add annotations or labels as needed to either of these YAML files.

Is there a reason to prefer either a Pod role or an Endpoints role?

1 Answers

In short, there are two major differences:

  • an endpoints role gives you more data in labels (to which service a pod belongs, for example);
  • a pod role targets any pod out there and not just those belonging to a service.

What's best for you is for you to decide, but I suppose that an endpoints role would fit well for your production applications (all these usually have a corresponding service), and a pod role for everything else. Or you may do with just one pod role job for everything and bring that extra information with the kube-state-metrics exporter.

Related