Skip to content

Commit

Permalink
[prometheus-node-exporter] Fix sidecars containers volumeMounts merge (
Browse files Browse the repository at this point in the history
…#4177)

* [node-exporter] Fix sidecars containers volumeMounts merge

Signed-off-by: Thomas Decaux <[email protected]>

* bump chart version

Signed-off-by: Thomas Decaux <[email protected]>

* bump chart version

Signed-off-by: Thomas Decaux <[email protected]>

* Patch version

Co-authored-by: MH <[email protected]>
Signed-off-by: Thomas Decaux <[email protected]>

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

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Thomas Decaux <[email protected]>

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

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Thomas Decaux <[email protected]>

* fix lint

Signed-off-by: Thomas Decaux <[email protected]>

---------

Signed-off-by: Thomas Decaux <[email protected]>
Signed-off-by: Thomas Decaux <[email protected]>
Co-authored-by: MH <[email protected]>
Co-authored-by: zeritti <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2024
1 parent 4a10962 commit 38e4131
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-node-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- prometheus
- exporter
type: application
version: 4.26.0
version: 4.26.1
appVersion: 1.7.0
home: https://github.com/prometheus/node_exporter/
sources:
Expand Down
17 changes: 17 additions & 0 deletions charts/prometheus-node-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,20 @@ labelNameLengthLimit: {{ . }}
labelValueLengthLimit: {{ . }}
{{- end }}
{{- end }}

{{/* Sets sidecar volumeMounts */}}
{{- define "prometheus-node-exporter.sidecarVolumeMounts" -}}
{{- range $_, $mount := $.Values.sidecarVolumeMount }}
- name: {{ $mount.name }}
mountPath: {{ $mount.mountPath }}
readOnly: {{ $mount.readOnly }}
{{- end }}
{{- range $_, $mount := $.Values.sidecarHostVolumeMounts }}
- name: {{ $mount.name }}
mountPath: {{ $mount.mountPath }}
readOnly: {{ $mount.readOnly }}
{{- if $mount.mountPropagation }}
mountPropagation: {{ $mount.mountPropagation }}
{{- end }}
{{- end }}
{{- end }}
28 changes: 10 additions & 18 deletions charts/prometheus-node-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,16 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
{{- with .Values.sidecars }}
{{- toYaml . | nindent 8 }}
{{- if or $.Values.sidecarVolumeMount $.Values.sidecarHostVolumeMounts }}
volumeMounts:
{{- range $_, $mount := $.Values.sidecarVolumeMount }}
- name: {{ $mount.name }}
mountPath: {{ $mount.mountPath }}
readOnly: {{ $mount.readOnly }}
{{- end }}
{{- range $_, $mount := $.Values.sidecarHostVolumeMounts }}
- name: {{ $mount.name }}
mountPath: {{ $mount.mountPath }}
readOnly: {{ $mount.readOnly }}
{{- if $mount.mountPropagation }}
mountPropagation: {{ $mount.mountPropagation }}
{{- end }}
{{- end }}
{{- end }}
{{- range .Values.sidecars }}
{{- $overwrites := dict
"volumeMounts" (concat (include "prometheus-node-exporter.sidecarVolumeMounts" $ | fromYamlArray) (.volumeMounts | default list) | default list)
}}
{{- $defaults := dict
"image" (include "prometheus-node-exporter.image" $)
"securityContext" $.Values.containerSecurityContext
"imagePullPolicy" $.Values.image.pullPolicy
}}
- {{- toYaml (merge $overwrites . $defaults) | nindent 10 }}
{{- end }}
{{- if .Values.kubeRBACProxy.enabled }}
- name: kube-rbac-proxy
Expand Down
15 changes: 9 additions & 6 deletions charts/prometheus-node-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,21 @@ secrets: []
##
namespaceOverride: ""

## Additional containers for export metrics to text file
## Additional containers for export metrics to text file; fields image,imagePullPolicy,securityContext take default value from main container
##
sidecars: []
## - name: nvidia-dcgm-exporter
## image: nvidia/dcgm-exporter:1.4.3
# - name: nvidia-dcgm-exporter
# image: nvidia/dcgm-exporter:1.4.3
# volumeMounts:
# - name: tmp
# mountPath: /tmp

## Volume for sidecar containers
##
sidecarVolumeMount: []
## - name: collector-textfiles
## mountPath: /run/prometheus
## readOnly: false
# - name: collector-textfiles
# mountPath: /run/prometheus
# readOnly: false

## Additional mounts from the host to sidecar containers
##
Expand Down

0 comments on commit 38e4131

Please sign in to comment.