From 603771ff144b43c7f551679c526fe4f5c256cd14 Mon Sep 17 00:00:00 2001 From: Max Leonard Inden <IndenML@gmail.com> Date: Thu, 14 Jun 2018 15:09:08 +0200 Subject: [PATCH] kube-prometheus: Run node-exporter in host network Node exporter needs to run in the host network, not in the pod network in order to pick up network metrics of the node. --- .../kube-prometheus/node-exporter/node-exporter.libsonnet | 6 ++++-- manifests/grafana-dashboardDatasources.yaml | 3 ++- manifests/node-exporter-daemonset.yaml | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet index 2d012110..a3e8d7a7 100644 --- a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet +++ b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet @@ -90,7 +90,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; '--secure-listen-address=:9100', '--upstream=http://127.0.0.1:9101/', ]) + - container.withPorts(containerPort.newNamed('https', 9100)) + + container.withPorts(containerPort.new(9100) + containerPort.withHostPort(9100) + containerPort.withName('https')) + container.mixin.resources.withRequests({ cpu: '10m', memory: '20Mi' }) + container.mixin.resources.withLimits({ cpu: '20m', memory: '40Mi' }); @@ -108,7 +108,9 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; daemonset.mixin.spec.template.spec.withVolumes([procVolume, sysVolume]) + daemonset.mixin.spec.template.spec.securityContext.withRunAsNonRoot(true) + daemonset.mixin.spec.template.spec.securityContext.withRunAsUser(65534) + - daemonset.mixin.spec.template.spec.withServiceAccountName('node-exporter'), + daemonset.mixin.spec.template.spec.withServiceAccountName('node-exporter') + + daemonset.mixin.spec.template.spec.withHostPid(true) + + daemonset.mixin.spec.template.spec.withHostNetwork(true), serviceAccount: local serviceAccount = k.core.v1.serviceAccount; diff --git a/manifests/grafana-dashboardDatasources.yaml b/manifests/grafana-dashboardDatasources.yaml index 70872c84..5585057c 100644 --- a/manifests/grafana-dashboardDatasources.yaml +++ b/manifests/grafana-dashboardDatasources.yaml @@ -2,12 +2,13 @@ apiVersion: v1 data: prometheus.yaml: |- { + "apiVersion": 1, "datasources": [ { "access": "proxy", "editable": false, "name": "prometheus", - "org_id": 1, + "orgId": 1, "type": "prometheus", "url": "http://prometheus-k8s.monitoring.svc:9090", "version": 1 diff --git a/manifests/node-exporter-daemonset.yaml b/manifests/node-exporter-daemonset.yaml index 8488735c..92182e05 100644 --- a/manifests/node-exporter-daemonset.yaml +++ b/manifests/node-exporter-daemonset.yaml @@ -42,6 +42,7 @@ spec: name: kube-rbac-proxy ports: - containerPort: 9100 + hostPort: 9100 name: https resources: limits: @@ -50,6 +51,8 @@ spec: requests: cpu: 10m memory: 20Mi + hostNetwork: true + hostPID: true nodeSelector: beta.kubernetes.io/os: linux securityContext: -- GitLab