cAdvisor on kubernetes cannot scrape all the pods (identifies only one cadvisor pod not others)

  cadvisor, daemonset, docker, kubernetes, kubernetes-pod

I am new to kubernetes. I want to get container metrics from all the cAdvisor pods present in kubernetes cluster. I have deployed cAdvisor as daemonset on the cluster. Below is the yaml file.

cAdvisor daemonset yaml file for kubernetes:

apiVersion: apps/v1 # for versions before 1.8.0 use extensions/v1beta1 [apps/v1beta2]
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: kube-system
  labels:
    app: cadvisor
spec:
  selector:
    matchLabels:
      name: cadvisor
  template:
    metadata:
      labels:
        name: cadvisor
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: cadvisor
        image: google/cadvisor:latest
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: false
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker
          readOnly: true
        ports:
          - name: http
            containerPort: 8080
            protocol: TCP
        args:
          - --housekeeping_interval=10s
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/lib/docker

I can only see the container metrics being scraped from only one of the cAdvisor pod on grafana. How to get container metrics from other pods too?
Note: I can see cAdvisor deployed on each agentpools. But prometheus identifies only one.

Source: Docker Questions

LEAVE A COMMENT