Skip to content

Commit 9d47719

Browse files
[prometheus-node-exporter] prevent node exporter from being scheduled on fargate or virtual nodes (#4736)
* [prometheus-node-exporter] prevent node exporter from being scheduled on fargate or virtual nodes Signed-off-by: Marius Kimmina <[email protected]> * bump minor version instead of patch Signed-off-by: Marius Kimmina <[email protected]> * Add comment to affinity field Signed-off-by: Marius Kimmina <[email protected]> * Remove trailing spaces Signed-off-by: zeritti <[email protected]> --------- Signed-off-by: Marius Kimmina <[email protected]> Signed-off-by: zeritti <[email protected]> Co-authored-by: zeritti <[email protected]>
1 parent dbdf395 commit 9d47719

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

charts/prometheus-node-exporter/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords:
66
- prometheus
77
- exporter
88
type: application
9-
version: 4.42.0
9+
version: 4.43.0
1010
appVersion: 1.8.2
1111
home: https://github.com/prometheus/node_exporter/
1212
sources:

charts/prometheus-node-exporter/templates/_helpers.tpl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,38 @@ labelValueLengthLimit: {{ . }}
200200
{{- end }}
201201
{{- end }}
202202
{{- end }}
203+
204+
{{/*
205+
The default node affinity to exclude
206+
- AWS Fargate
207+
- Azure virtual nodes
208+
*/}}
209+
{{- define "prometheus-node-exporter.defaultAffinity" -}}
210+
nodeAffinity:
211+
requiredDuringSchedulingIgnoredDuringExecution:
212+
nodeSelectorTerms:
213+
- matchExpressions:
214+
- key: eks.amazonaws.com/compute-type
215+
operator: NotIn
216+
values:
217+
- fargate
218+
- key: type
219+
operator: NotIn
220+
values:
221+
- virtual-kubelet
222+
{{- end -}}
223+
{{- define "prometheus-node-exporter.mergedAffinities" -}}
224+
{{- $defaultAffinity := include "prometheus-node-exporter.defaultAffinity" . | fromYaml -}}
225+
{{- with .Values.affinity -}}
226+
{{- if .nodeAffinity -}}
227+
{{- $_ := set $defaultAffinity "nodeAffinity" (mergeOverwrite $defaultAffinity.nodeAffinity .nodeAffinity) -}}
228+
{{- end -}}
229+
{{- if .podAffinity -}}
230+
{{- $_ := set $defaultAffinity "podAffinity" .podAffinity -}}
231+
{{- end -}}
232+
{{- if .podAntiAffinity -}}
233+
{{- $_ := set $defaultAffinity "podAntiAffinity" .podAntiAffinity -}}
234+
{{- end -}}
235+
{{- end -}}
236+
{{- toYaml $defaultAffinity -}}
237+
{{- end -}}

charts/prometheus-node-exporter/templates/daemonset.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ spec:
267267
hostNetwork: {{ .Values.hostNetwork }}
268268
hostPID: {{ .Values.hostPID }}
269269
hostIPC: {{ .Values.hostIPC }}
270-
{{- with .Values.affinity }}
271270
affinity:
272-
{{- toYaml . | nindent 8 }}
273-
{{- end }}
271+
{{- include "prometheus-node-exporter.mergedAffinities" . | nindent 8 }}
274272
{{- with .Values.dnsConfig }}
275273
dnsConfig:
276274
{{- toYaml . | nindent 8 }}

charts/prometheus-node-exporter/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ hostSysFsMount:
408408
mountPropagation: ""
409409

410410
## Assign a group of affinity scheduling rules
411-
##
411+
## The default nodeAffinity excludes Fargate nodes and virtual kubelets from scheduling
412+
## unless overriden by hard node affinity set in the field.
412413
affinity: {}
413414
# nodeAffinity:
414415
# requiredDuringSchedulingIgnoredDuringExecution:

0 commit comments

Comments
 (0)