Skip to content

Commit

Permalink
Merge pull request #2035 from maartengo/grafana-global-imagePullSecre…
Browse files Browse the repository at this point in the history
…t-values

[grafana] Add support for global imagePullSecrets values
  • Loading branch information
zanhsieh committed Dec 2, 2022
2 parents 340ceac + a87a5b3 commit 8a20c22
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/grafana/Chart.yaml
@@ -1,6 +1,6 @@
apiVersion: v2
name: grafana
version: 6.44.11
version: 6.45.0
appVersion: 9.3.0
kubeVersion: "^1.8.0-0"
description: The leading tool for querying and visualizing time series and metrics.
Expand Down
1 change: 1 addition & 0 deletions charts/grafana/README.md
Expand Up @@ -135,6 +135,7 @@ This version requires Helm >= 3.1.0.
| `dashboards` | Dashboards to import | `{}` |
| `dashboardsConfigMaps` | ConfigMaps reference that contains dashboards | `{}` |
| `grafana.ini` | Grafana's primary configuration | `{}` |
| `global.imagePullSecrets` | Global image pull secrets (can be templated). Allows either an array of {name: pullSecret} maps (k8s-style), or an array of strings (more common helm-style). | `[]` |
| `ldap.enabled` | Enable LDAP authentication | `false` |
| `ldap.existingSecret` | The name of an existing secret containing the `ldap.toml` file, this must have the key `ldap-toml`. | `""` |
| `ldap.config` | Grafana's LDAP configuration | `""` |
Expand Down
14 changes: 14 additions & 0 deletions charts/grafana/templates/_helpers.tpl
Expand Up @@ -172,3 +172,17 @@ Return if ingress supports pathType.
{{- define "grafana.ingress.supportsPathType" -}}
{{- or (eq (include "grafana.ingress.isStable" .) "true") (and (eq (include "grafana.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) }}
{{- end }}
{{/*
Formats imagePullSecrets. Input is (dict "root" . "imagePullSecrets" .{specific imagePullSecrets})
*/}}
{{- define "grafana.imagePullSecrets" -}}
{{- $root := .root }}
{{- range (concat .root.Values.global.imagePullSecrets .imagePullSecrets) }}
{{- if eq (typeOf .) "map[string]interface {}" }}
- {{ toYaml (dict "name" (tpl .name $root)) | trim }}
{{- else }}
- name: {{ tpl . $root }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/grafana/templates/_pod.tpl
Expand Up @@ -220,11 +220,9 @@ initContainers:
{{- with .Values.extraInitContainers }}
{{- tpl (toYaml .) $root | nindent 2 }}
{{- end }}
{{- with .Values.image.pullSecrets }}
{{- if or .Values.image.pullSecrets .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ tpl . $root }}
{{- end}}
{{- include "grafana.imagePullSecrets" (dict "root" $root "imagePullSecrets" .Values.image.pullSecrets) | nindent 2 }}
{{- end }}
{{- if not .Values.enableKubeBackwardCompatibility }}
enableServiceLinks: {{ .Values.enableServiceLinks }}
Expand Down
6 changes: 2 additions & 4 deletions charts/grafana/templates/tests/test.yaml
Expand Up @@ -16,11 +16,9 @@ spec:
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.image.pullSecrets }}
{{- if or .Values.image.pullSecrets .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ tpl . $root }}
{{- end}}
{{- include "grafana.imagePullSecrets" (dict "root" $root "imagePullSecrets" .Values.image.pullSecrets) | nindent 4 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
15 changes: 15 additions & 0 deletions charts/grafana/values.yaml
@@ -1,3 +1,18 @@
global:
# 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).
# Can be tempalted.
# global:
# imagePullSecrets:
# - name: pullSecret1
# - name: pullSecret2
# or
# global:
# imagePullSecrets:
# - pullSecret1
# - pullSecret2
imagePullSecrets: []

rbac:
create: true
## Use an existing ClusterRole/Role (depending on rbac.namespaced false/true)
Expand Down

0 comments on commit 8a20c22

Please sign in to comment.