Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sysdig Tutorial: node-exporter-daemonset not working out of the box #1

Open
obitech opened this issue Aug 20, 2018 · 0 comments
Open

Comments

@obitech
Copy link

obitech commented Aug 20, 2018

Hey Mateo, I've just been following your (excellent) Kubernetes Monitoring with Prometheus tutorial and encountered an issue towards the end, where you deploy the node-exporter DaemonSet:

Here you mention to create a new namespace and pull a DaemonSet from another repo:

kubectl create ns monitoring 
kubectl create -f https://raw.githubusercontent.com/bakins/minikube-prometheus-demo/master/node-exporter-daemonset.yml

Unfortunately the repo is archived and seems to have some issues. In this case, the node-exporter pod created by the DaemonSet is not discoverable by Prometheus because of the seperate monitoring namespace (all previous resources have been launched in default).

For it to work, I had to create a headless Service for the pod:

kind: Service
apiVersion: v1
metadata:
  name: node-exporter
  namespace: monitoring
spec:
  selector:
    name: node-exporter
  ports:
  - port: 9100
    targetPort: 9100
  clusterIP: None
---

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: monitoring
  labels:
    name: node-exporter
spec:
  selector:
    matchLabels:
      name: node-exporter
  template:
    metadata:
      labels:
        name: node-exporter
      annotations:
         prometheus.io/scrape: "true"
         prometheus.io/port: "9100"
    spec:
      hostPID: true
      hostIPC: true
      hostNetwork: true
      containers:
        - ports:
            - containerPort: 9100
              protocol: TCP
          resources:
            requests:
              cpu: 0.15
          securityContext:
            privileged: true
          image: prom/node-exporter:v0.15.2
          args:
            - --path.procfs
            - /host/proc
            - --path.sysfs
            - /host/sys
            - --collector.filesystem.ignored-mount-points
            - '"^/(sys|proc|dev|host|etc)($|/)"'
          name: node-exporter
          volumeMounts:
            - name: dev
              mountPath: /host/dev
            - name: proc
              mountPath: /host/proc
            - name: sys
              mountPath: /host/sys
            - name: rootfs
              mountPath: /rootfs
      volumes:
        - name: proc
          hostPath:
            path: /proc
        - name: dev
          hostPath:
            path: /dev
        - name: sys
          hostPath:
            path: /sys
        - name: rootfs
          hostPath:
            path: /

which makes it discoverable via DNS in the prometheus.yml:

# ...
  - job_name: 'node-exporter'
    static_configs:
    - targets: ['node-exporter.monitoring.svc.cluster.local:9100']

You might want to consider including it in the tutorial :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant