Skip to content

Commit 4ac1bcb

Browse files
authored
node-exporter: disable host network (#204)
1 parent cbf797a commit 4ac1bcb

File tree

7 files changed

+7
-49
lines changed

7 files changed

+7
-49
lines changed

charts/sourcegraph/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Sourcegraph 4.1.0 is now available!
2828
🚨 **WARNING**: Similarly to cadvisor, `node-exporter`:
2929
- runs as a daemonset
3030
- needs to mount various read-only directories from the host machine (`/`, `/proc`, and `/sys`)
31-
- ideally shares the machine's PID and Network namespaces
31+
- ideally shares the machine's PID namespaces
3232

3333
If necessary, node-exporter can be disabled by setting `nodeExporter.enabled: false` in your `override.yaml` configuration file.
3434

charts/sourcegraph/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ In addition to the documented values, all services also support the following va
184184
| nodeExporter.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":65534,"runAsUser":65534}` | Security context for the `node-exporter` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
185185
| nodeExporter.enabled | bool | `true` | Enable `node-exporter` |
186186
| nodeExporter.extraArgs | list | `[]` | |
187-
| nodeExporter.hostNetwork | bool | `true` | |
188187
| nodeExporter.hostPID | bool | `true` | |
189188
| nodeExporter.image.defaultTag | string | `"179720_2022-10-25_4d925e87cfb8@sha256:2d9dcdf0b2226f0c3d550a64d2667710265462350a3ba9ebe37d0302bc64af0f"` | Docker image tag for the `node-exporter` image |
190189
| nodeExporter.image.name | string | `"node-exporter"` | Docker image name for the `node-exporter` image |

charts/sourcegraph/templates/NOTES.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,3 @@ If you would like to bring your own infrastructure monitoring & alerting solutio
5151
you may want to disable the `node-exporter` DaemonSet completely by setting `nodeExporter.enabled=false` in your override file.
5252

5353
{{- end }}
54-
55-
{{- if not .Values.nodeExporter.hostNetwork }}
56-
57-
🚧 Warning 🚧
58-
59-
You have set 'nodeExporter.hostNetwork' to 'false' which greatly limits the metrics that node-exporter is able to provide. Many of the
60-
metrics that Sourcegraph uses to help you scale your deployment might be broken as a result.
61-
62-
If you would like to bring your own infrastructure monitoring & alerting solution,
63-
you may want to disable the `node-exporter` DaemonSet completely by setting `nodeExporter.enabled=false` in your override file.
64-
65-
{{- end }}

charts/sourcegraph/templates/node-exporter/node-exporter.DaemonSet.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ spec:
125125
imagePullSecrets:
126126
{{- toYaml . | nindent 8 }}
127127
{{- end }}
128-
hostNetwork: {{ .Values.nodeExporter.hostNetwork }}
129128
hostPID: {{ .Values.nodeExporter.hostPID }}
130129
volumes:
131130
- name: rootfs

charts/sourcegraph/templates/node-exporter/node-exporter.PodSecurityPolicy.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ metadata:
1515
spec:
1616
privileged: false
1717
hostIPC: false
18-
hostNetwork: {{ .Values.nodeExporter.hostNetwork }}
1918
hostPID: {{ .Values.nodeExporter.hostPID }}
2019
seLinux:
2120
rule: RunAsAny

charts/sourcegraph/tests/nodeExporter_test.yaml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -143,55 +143,38 @@ tests:
143143
value: "my-test-namespace"
144144
template: node-exporter/node-exporter.ClusterRoleBinding.yaml
145145

146-
- it: should have host Network and PID enabled by default
146+
- it: should have hostPID enabled by default
147147
set:
148148
nodeExporter:
149-
# (these settings are unrelated to host network/pid defaults, they're just for ensuring that PodSecurityPolicy gets rendered so that we can check them in same test)
149+
# (these settings are unrelated to host pid defaults, they're just for ensuring that PodSecurityPolicy gets rendered so that we can check them in same test)
150150
serviceAccount:
151151
create: true
152152
podSecurityPolicy:
153153
enabled: true
154154
asserts:
155-
- equal:
156-
path: spec.template.spec.hostNetwork
157-
value: true
158-
template: node-exporter/node-exporter.DaemonSet.yaml
159155
- equal:
160156
path: spec.template.spec.hostPID
161157
value: true
162158
template: node-exporter/node-exporter.DaemonSet.yaml
163-
- equal:
164-
path: spec.hostNetwork
165-
value: true
166-
template: node-exporter/node-exporter.PodSecurityPolicy.yaml
167159
- equal:
168160
path: spec.hostPID
169161
value: true
170162
template: node-exporter/node-exporter.PodSecurityPolicy.yaml
171163

172-
- it: should propagate host PID/network settings to both the daemonset and podSecurityPolicy
164+
- it: should propagate host PID settings to both the daemonset and podSecurityPolicy
173165
set:
174166
nodeExporter:
175-
hostNetwork: false
176167
hostPID: false
177-
# (these settings are unrelated to host network/pid defaults, they're just for ensuring that PodSecurityPolicy gets rendered so that we can check them in same test)
168+
# (these settings are unrelated to host pid defaults, they're just for ensuring that PodSecurityPolicy gets rendered so that we can check them in same test)
178169
serviceAccount:
179170
create: true
180171
podSecurityPolicy:
181172
enabled: true
182173
asserts:
183-
- equal:
184-
path: spec.template.spec.hostNetwork
185-
value: false
186-
template: node-exporter/node-exporter.DaemonSet.yaml
187174
- equal:
188175
path: spec.template.spec.hostPID
189176
value: false
190177
template: node-exporter/node-exporter.DaemonSet.yaml
191-
- equal:
192-
path: spec.hostNetwork
193-
value: false
194-
template: node-exporter/node-exporter.PodSecurityPolicy.yaml
195178
- equal:
196179
path: spec.hostPID
197180
value: false
@@ -215,28 +198,20 @@ tests:
215198
pattern: You have set 'nodeExporter.enabled' to 'false'
216199
template: NOTES.txt
217200

218-
- it: should not generate warnings if hostPID or hostNetwork are true
201+
- it: should not generate warnings if hostPID is true
219202
set:
220203
nodeExporter:
221-
hostNetwork: true
222204
hostPID: true
223205
asserts:
224206
- notMatchRegexRaw:
225207
pattern: You have set 'nodeExporter.hostPID' to 'false'
226208
template: NOTES.txt
227-
- notMatchRegexRaw:
228-
pattern: You have set 'nodeExporter.hostNetwork' to 'false'
229-
template: NOTES.txt
230209

231-
- it: should generate warnings if hostPID or hostNetwork are false
210+
- it: should generate warnings if hostPID is false
232211
set:
233212
nodeExporter:
234-
hostNetwork: false
235213
hostPID: false
236214
asserts:
237215
- matchRegexRaw:
238216
pattern: You have set 'nodeExporter.hostPID' to 'false'
239217
template: NOTES.txt
240-
- matchRegexRaw:
241-
pattern: You have set 'nodeExporter.hostNetwork' to 'false'
242-
template: NOTES.txt

charts/sourcegraph/values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,6 @@ nodeExporter:
691691
name: node-exporter
692692
# Share the host process ID namespace.
693693
hostPID: true
694-
# Expose the service to the host network
695-
hostNetwork: true
696694
## Additional container arguments for the node-exporter container
697695
extraArgs: []
698696
# - --collector.diskstats.ignored-devices=^(ram|loop|fd|(h|s|v)d[a-z]|nvme\\d+n\\d+p)\\d+$

0 commit comments

Comments
 (0)