maksim-paskal / aks-node-termination-handler

Gracefully handle Azure Virtual Machines shutdown within Kubernetes
Apache License 2.0
38 stars 6 forks source link

Issue with metric scrapping via PodMonitor #58

Closed lrybak closed 11 months ago

lrybak commented 11 months ago

First of all thank you for your work on this project!

I wanted to enable metric scrapping for Prometheus using a PodMonitor. However, I encountered an issue with the PodMonitor in the following configuration

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  namespace: kube-system
  name: podmonitor-aks-node-termination-handler
  labels:
    release: prometheus
spec:
  selector:
    matchLabels:
      app: aks-node-termination-handler
  podMetricsEndpoints:
  - port: 17923
    path: /metrics
    interval: 15s

The problem is that a properly defined PodMonitor should point to the port by name rather than by number - https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#podmetricsendpoint

Could you please add the port definition for the container in DaemonSet so that the appropriate port with a name is created for the container in the pod? I'm attaching an example patch for the DaemonSet below:

kubectl patch daemonset aks-node-termination-handler --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/ports", "value": [{"containerPort": 17923, "name": "metrics", "protocol": "TCP"}]}]'

Thank you

maksim-paskal commented 11 months ago

@lrybak Thanks for raising this issue. It make sense. I will add name http to port 17923 in container