Portworx Monitoring. Fixed Node Exporter configuration when deploying Portworx on portworx namespace

Audience
Public
Content Type
Source Type
Knowledge Base

Portworx Monitoring. Fixed Node Exporter configuration when deploying Portworx on portworx namespace

KB0016122
Symptoms

Node Exporter seems to not be working fine on Portworx Prometheus when using portworx namespace.

Cause

ServiceMonitor labeling was incorrect.

Resolution

We need a privileged service account or at least one with sufficient privileges to create hostPath volumes. We are using the portworx-operator service account there.

Therefore this would work only on PX Operator installations.

 

apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app.kubernetes.io/component: exporter
    app.kubernetes.io/name: node-exporter
  name: node-exporter
  namespace: portworx
spec:
  selector:
    matchLabels:
      app.kubernetes.io/component: exporter
      app.kubernetes.io/name: node-exporter
  template:
    metadata:
      labels:
        app.kubernetes.io/component: exporter
        app.kubernetes.io/name: node-exporter
    spec:
      serviceAccountName: portworx-operator
      containers:
      - args:
        - --path.sysfs=/host/sys
        - --path.rootfs=/host/root
        - --no-collector.wifi
        - --no-collector.hwmon
        - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
        - --collector.netclass.ignored-devices=^(veth.*)$
        name: node-exporter
        image: prom/node-exporter
        ports:
          - containerPort: 9100
            protocol: TCP
        resources:
          limits:
            cpu: 250m
            memory: 180Mi
          requests:
            cpu: 102m
            memory: 180Mi
        volumeMounts:
        - mountPath: /host/sys
          mountPropagation: HostToContainer
          name: sys
          readOnly: true
        - mountPath: /host/root
          mountPropagation: HostToContainer
          name: root
          readOnly: true
      volumes:
      - hostPath:
          path: /sys
        name: sys
      - hostPath:
          path: /
        name: root
---
kind: Service
apiVersion: v1
metadata:
  name: node-exporter
  namespace: portworx
  labels:
    prometheus: portworx
spec:
  selector:
      app.kubernetes.io/component: exporter
      app.kubernetes.io/name: node-exporter
  ports:
  - name: node-exporter
    protocol: TCP
    port: 9100
    targetPort: 9100
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: node-exporter
  namespace: portworx  
  labels:
    prometheus: portworx
spec:
  selector:
    matchLabels:
    prometheus: portworx
  endpoints:
  - port: node-exporter