Skip to content

Commit

Permalink
[prometheus-elasticsearch-exporter] Correct imagepullsecrets for elas…
Browse files Browse the repository at this point in the history
…ticsearch exporter (#4589)

* Fix #4580 Updated imagepullsecrets for elasticsearch exporter

Signed-off-by: Jon Krehling <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/templates/deployment.yaml

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

* Update charts/prometheus-elasticsearch-exporter/templates/_helpers.tpl

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

* updated values comments for imagePullSecrets

Signed-off-by: Jon Krehling <[email protected]>

* updated charted version

Signed-off-by: Jon Krehling <[email protected]>

* Remove trailing spaces

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: Jon Krehling <[email protected]>
Signed-off-by: JKrehling <[email protected]>
Signed-off-by: zeritti <[email protected]>
Co-authored-by: Jon Krehling <[email protected]>
Co-authored-by: zeritti <[email protected]>
  • Loading branch information
3 people authored Jun 9, 2024
1 parent 0ce6914 commit dc5f3cc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-elasticsearch-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: Elasticsearch stats exporter for Prometheus
name: prometheus-elasticsearch-exporter
version: 5.8.0
version: 5.8.1
kubeVersion: ">=1.10.0-0"
appVersion: "v1.7.0"
home: https://github.com/prometheus-community/elasticsearch_exporter
Expand Down
41 changes: 19 additions & 22 deletions charts/prometheus-elasticsearch-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,28 @@ Usage:


{{/*
Return the proper Docker Image Registry Secret Names evaluating values as templates
{{ include "elasticsearch-exporter.image.pullSecret.name" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
*/}}
{{- define "elasticsearch-exporter.image.pullSecret.name" -}}
{{- $pullSecrets := list }}
{{- $context := .context }}
To help compatibility with other charts which use global.imagePullSecrets.
Allow either an array of {name: pullSecret} maps (k8s-style), or an array of strings (more common helm-style).
global:
imagePullSecrets:
- name: pullSecret1
- name: pullSecret2

{{- if $context.Values.global }}
{{- range $context.Values.global.imagePullSecrets -}}
{{/* Is plain array of strings, compatible with all bitnami charts */}}
{{- $pullSecrets = append $pullSecrets (include "elasticsearch-exporter.tplvalue.render" (dict "value" . "context" $context)) -}}
{{- end -}}
{{- end -}}
{{- range .images -}}
{{- if .pullSecret -}}
{{- $pullSecrets = append $pullSecrets (include "elasticsearch-exporter.tplvalue.render" (dict "value" .pullSecret "context" $context)) -}}
{{- end -}}
{{- end -}}
or

{{- if (not (empty $pullSecrets)) }}
imagePullSecrets:
{{- range $pullSecrets | uniq }}
- name: {{ . }}
{{- end }}
global:
imagePullSecrets:
- pullSecret1
- pullSecret2
*/}}
{{- define "elasticsearch-exporter.imagePullSecrets" -}}
{{- range .Values.global.imagePullSecrets }}
{{- if eq (typeOf .) "map[string]interface {}" }}
- {{ tpl (toYaml .) $ | trim }}
{{- else }}
- name: {{ tpl . $ }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ spec:
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- include "elasticsearch-exporter.image.pullSecret.name" (dict "images" (list .Values.image) "context" $) | nindent 6 }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- include "elasticsearch-exporter.imagePullSecrets" . | indent 8 }}
{{- end }}
restartPolicy: {{ .Values.restartPolicy }}
{{- with .Values.podSecurityContext }}
securityContext:
Expand Down
17 changes: 17 additions & 0 deletions charts/prometheus-elasticsearch-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
## This allows to set the same values for the imagePullSecrets, obviating the need
## to set the same values for each chart (and image) separately
global:
## Allow either an array of {name: pullSecret} maps (k8s-style), or an array of strings (more common helm-style).
## imagePullSecrets:
## - name: pullSecret1
## - name: pullSecret2
##
## or
##
## imagePullSecrets:
## - pullSecret1
## - pullSecret2
##
## or a templated value
##
## imagePullSecrets:
## - "{{ .Values.templateValue }}"
## templateValue: test

imagePullSecrets: []
imageRegistry: ""

Expand Down

0 comments on commit dc5f3cc

Please sign in to comment.