prometheus-operator / kube-prometheus

Use Prometheus to monitor Kubernetes and applications running on Kubernetes
https://prometheus-operator.dev/
Apache License 2.0
6.77k stars 1.94k forks source link

[KOPS-COREDNS platform] kube-dns-prometheus-discovery is not using the right label selector #1523

Open luarx opened 2 years ago

luarx commented 2 years ago

What happened? kube-dns-prometheus-discovery is not using the right label selector when using kops_coredns as platform

Did you expect to see some different? Instead of using 'app.kubernetes.io/name': 'kube-dns', I expected to see k8s-app: kube-dns

How to reproduce it (as minimally and precisely as possible):

Environment

core-dns

apiVersion: v1
kind: Pod
metadata:
  labels:
    k8s-app: kube-dns  <--------------------------------
  name: coredns-5489b75945-29f9d
  namespace: kube-system
spec:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: k8s-app
              operator: In
              values:
              - kube-dns
          topologyKey: kubernetes.io/hostname
        weight: 1
  containers:
  - args:
    - -conf
    - /etc/coredns/Corefile
    image: k8s.gcr.io/coredns:1.7.0
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 5
      httpGet:
        path: /health
        port: 8080
        scheme: HTTP
      initialDelaySeconds: 60
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 5
    name: coredns
    ports:
    - containerPort: 53
      name: dns
      protocol: UDP
    - containerPort: 53
      name: dns-tcp
      protocol: TCP
    - containerPort: 9153
      name: metrics
      protocol: TCP
    readinessProbe:
      failureThreshold: 3
      httpGet:
        path: /health
        port: 8080
        scheme: HTTP
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 1
    resources:
      limits:
        memory: 170Mi
      requests:
        cpu: 100m
        memory: 70Mi
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        add:
        - NET_BIND_SERVICE
        drop:
        - all
      readOnlyRootFilesystem: true
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
  dnsPolicy: Default
  phase: Running

kube-dns-prometheus-discovery

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: kube-dns
  name: kube-dns-prometheus-discovery
  namespace: kube-system
spec:
  clusterIP: None
  ports:
  - name: metrics
    port: 9153
    targetPort: 9153
  selector:
    app.kubernetes.io/name: kube-dns  <--------------------------------

Anything else we need to know?:

Platform used

    values+:: {
      common+: {
        namespace: 'monitoring',
      },
      kubePrometheus+: {
        platform: 'kops_coredns',   <--------------------------------
      },
paulfantom commented 2 years ago

What are the labels on this Service when using kops 1.21+?

Bear in mind main branch is not supporting kubernetes 1.20 and earlier - https://github.com/prometheus-operator/kube-prometheus#kubernetes-compatibility-matrix

luarx commented 2 years ago

Yeah! Right now I am using kops 1.20 and kube-prometheus release-0.8 branch

Do you mean that maybe it is fixed in the main branch?