kube-prometheus icon indicating copy to clipboard operation
kube-prometheus copied to clipboard

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

Open luarx opened this issue 3 years ago • 2 comments

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

  • Prometheus Operator version:

    quay.io/prometheus-operator/prometheus-operator:v0.47.0

  • Kubernetes cluster kind:

    kops. kops version was updated from 1.19 to 1.20. As you know, version 1.20 declared coredns as default (before was kube-dns) https://github.com/kubernetes/kops/releases/tag/v1.20.0

  • Manifests:

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',   <--------------------------------
      },

luarx avatar Nov 24 '21 16:11 luarx

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

paulfantom avatar Nov 25 '21 11:11 paulfantom

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?

luarx avatar Nov 26 '21 00:11 luarx