Skip to content

Commit 86f3dbd

Browse files
authored
add node exporter daemonset (sourcegraph#4197)
1 parent 4923add commit 86f3dbd

File tree

7 files changed

+154
-1
lines changed

7 files changed

+154
-1
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
annotations:
5+
description: DaemonSet to ensure all nodes run a node-exporter pod.
6+
seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
7+
labels:
8+
deploy: sourcegraph
9+
app: node-exporter
10+
app.kubernetes.io/component: node-exporter
11+
name: node-exporter
12+
spec:
13+
selector:
14+
matchLabels:
15+
app: node-exporter
16+
template:
17+
metadata:
18+
annotations:
19+
description: Collects and exports machine metrics.
20+
kubectl.kubernetes.io/default-container: node-exporter
21+
labels:
22+
deploy: sourcegraph
23+
app: node-exporter
24+
spec:
25+
containers:
26+
- name: node-exporter
27+
image: index.docker.io/sourcegraph/node-exporter:179720_2022-10-25_4d925e87cfb8@sha256:2d9dcdf0b2226f0c3d550a64d2667710265462350a3ba9ebe37d0302bc64af0f
28+
imagePullPolicy: IfNotPresent
29+
resources:
30+
limits:
31+
cpu: '1'
32+
memory: 1Gi
33+
requests:
34+
cpu: 200m
35+
memory: 100Mi
36+
args:
37+
- --web.listen-address=:9100
38+
- --path.sysfs=/host/sys
39+
- --path.rootfs=/host/root
40+
- --path.procfs=/host/proc
41+
- --no-collector.wifi
42+
- --no-collector.hwmon
43+
- --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
44+
- --collector.netclass.ignored-devices=^(veth.*)$
45+
- --collector.netdev.device-exclude=^(veth.*)$
46+
env:
47+
securityContext:
48+
allowPrivilegeEscalation: false
49+
readOnlyRootFilesystem: true
50+
runAsGroup: 65534
51+
runAsUser: 65534
52+
volumeMounts:
53+
- name: rootfs
54+
mountPath: /host/root
55+
mountPropagation: HostToContainer
56+
readOnly: true
57+
- name: sys
58+
mountPath: /host/sys
59+
mountPropagation: HostToContainer
60+
readOnly: true
61+
- name: proc
62+
mountPath: /host/proc
63+
mountPropagation: HostToContainer
64+
readOnly: true
65+
ports:
66+
- name: metrics
67+
containerPort: 9100
68+
protocol: TCP
69+
readinessProbe:
70+
failureThreshold: 3
71+
httpGet:
72+
scheme: HTTP
73+
port: metrics
74+
initialDelaySeconds: 0
75+
periodSeconds: 10
76+
successThreshold: 1
77+
timeoutSeconds: 1
78+
livenessProbe:
79+
failureThreshold: 3
80+
httpGet:
81+
scheme: HTTP
82+
port: metrics
83+
initialDelaySeconds: 0
84+
periodSeconds: 10
85+
successThreshold: 1
86+
timeoutSeconds: 1
87+
terminationMessagePolicy: FallbackToLogsOnError
88+
automountServiceAccountToken: false
89+
terminationGracePeriodSeconds: 30
90+
securityContext:
91+
fsGroup: 65534
92+
runAsGroup: 65534
93+
runAsNonRoot: true
94+
runAsUser: 65534
95+
nodeSelector:
96+
affinity:
97+
tolerations:
98+
hostPID: true
99+
volumes:
100+
- name: rootfs
101+
hostPath:
102+
path: /
103+
- name: sys
104+
hostPath:
105+
path: /sys
106+
- name: proc
107+
hostPath:
108+
path: /proc
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
annotations:
5+
description: Prometheus exporter for hardware and OS metrics.
6+
url: https://github.com/prometheus/node_exporter
7+
prometheus.io/port: "9100"
8+
sourcegraph.prometheus/scrape: "true"
9+
labels:
10+
app.kubernetes.io/component: node-exporter
11+
app: node-exporter
12+
deploy: sourcegraph
13+
sourcegraph-resource-requires: no-cluster-admin
14+
name: node-exporter
15+
spec:
16+
ports:
17+
- name: metrics
18+
port: 9100
19+
targetPort: metrics
20+
selector:
21+
app: node-exporter
22+
type: ClusterIP

base/prometheus/prometheus.ConfigMap.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ data:
163163
- source_labels: [__meta_kubernetes_pod_name]
164164
action: replace
165165
target_label: instance
166+
# Sourcegraph specific customization. We want to add a label to every
167+
# metric that indicates the node it came from.
168+
- source_labels: [__meta_kubernetes_endpoint_node_name]
169+
action: replace
170+
target_label: nodename
166171
167172
# Example scrape config for probing services via the Blackbox Exporter.
168173
#
@@ -235,6 +240,11 @@ data:
235240
- source_labels: [__meta_kubernetes_namespace]
236241
action: replace
237242
target_label: ns
243+
# Sourcegraph specific customization. We want to add a label to every
244+
# metric that indicates the node it came from.
245+
- source_labels: [__meta_kubernetes_endpoint_node_name]
246+
action: replace
247+
target_label: nodename
238248
239249
metric_relabel_configs:
240250
# cAdvisor-specific customization. Drop container metrics exported by cAdvisor

overlays/bases/deployments/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ resources:
5454
- base/otel-collector/otel-collector.ConfigMap.yaml
5555
- base/otel-collector/otel-collector.Deployment.yaml
5656
- base/otel-collector/otel-collector.Service.yaml
57+
- base/node-exporter/node-exporter.DaemonSet.yaml
58+
- base/node-exporter/node-exporter.Service.yaml

overlays/low-resource/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,6 @@ patchesStrategicMerge:
453453
- cadvisor/delete-ClusterRoleBinding.yaml
454454
- cadvisor/delete-ServiceAccount.yaml
455455
- cadvisor/delete-PodSecurityPolicy.yaml
456-
456+
- node-exporter/delete-Daemonset.yaml
457+
- node-exporter/delete-Service.yaml
457458

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$patch: delete
2+
apiVersion: apps/v1
3+
kind: DaemonSet
4+
metadata:
5+
name: node-exporter
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$patch: delete
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: node-exporter

0 commit comments

Comments
 (0)