From d1aca6c482b7ada21ce069278d18469b621264da Mon Sep 17 00:00:00 2001 From: QuentinBisson Date: Thu, 5 Oct 2023 21:06:14 +0200 Subject: [PATCH] [grafana] add global image registry support Signed-off-by: QuentinBisson --- charts/grafana/Chart.yaml | 2 +- charts/grafana/README.md | 15 ++++-- charts/grafana/templates/_pod.tpl | 50 +++++++++++-------- .../templates/image-renderer-deployment.yaml | 5 +- charts/grafana/templates/tests/test.yaml | 2 +- charts/grafana/values.yaml | 32 +++++++++--- 6 files changed, 71 insertions(+), 35 deletions(-) diff --git a/charts/grafana/Chart.yaml b/charts/grafana/Chart.yaml index d8687cce6d..6bce2968fd 100644 --- a/charts/grafana/Chart.yaml +++ b/charts/grafana/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: grafana -version: 6.60.2 +version: 6.61.0 appVersion: 10.1.2 kubeVersion: "^1.8.0-0" description: The leading tool for querying and visualizing time series and metrics. diff --git a/charts/grafana/README.md b/charts/grafana/README.md index bb630b0073..85770c0a49 100644 --- a/charts/grafana/README.md +++ b/charts/grafana/README.md @@ -59,6 +59,7 @@ This version requires Helm >= 3.1.0. | `readinessProbe` | Readiness Probe settings | `{ "httpGet": { "path": "/api/health", "port": 3000 } }`| | `securityContext` | Deployment securityContext | `{"runAsUser": 472, "runAsGroup": 472, "fsGroup": 472}` | | `priorityClassName` | Name of Priority Class to assign pods | `nil` | +| `image.registry` | Image registry | `docker.io` | | `image.repository` | Image repository | `grafana/grafana` | | `image.tag` | Overrides the Grafana image tag whose default is the chart appVersion (`Must be >= 5.0.0`) | `` | | `image.sha` | Image sha (optional) | `` | @@ -111,6 +112,7 @@ This version requires Helm >= 3.1.0. | `persistence.inMemory.enabled` | If persistence is not enabled, whether to mount the local storage in-memory to improve performance | `false` | | `persistence.inMemory.sizeLimit` | SizeLimit for the in-memory local storage | `nil` | | `initChownData.enabled` | If false, don't reset data ownership at startup | true | +| `initChownData.image.registry` | init-chown-data container image registry | `docker.io` | | `initChownData.image.repository` | init-chown-data container image repository | `busybox` | | `initChownData.image.tag` | init-chown-data container image tag | `1.31.1` | | `initChownData.image.sha` | init-chown-data container image sha (optional)| `""` | @@ -137,6 +139,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.image.registry` | Global image pull registry for all images. | `null` | | `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`. | `""` | @@ -147,7 +150,8 @@ This version requires Helm >= 3.1.0. | `podLabels` | Pod labels | `{}` | | `podPortName` | Name of the grafana port on the pod | `grafana` | | `lifecycleHooks` | Lifecycle hooks for podStart and preStop [Example](https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers) | `{}` | -| `sidecar.image.repository` | Sidecar image repository | `quay.io/kiwigrid/k8s-sidecar` | +| `sidecar.image.registry` | Sidecar image registry | `quay.io` | +| `sidecar.image.repository` | Sidecar image repository | `kiwigrid/k8s-sidecar` | | `sidecar.image.tag` | Sidecar image tag | `1.24.6` | | `sidecar.image.sha` | Sidecar image sha (optional) | `""` | | `sidecar.imagePullPolicy` | Sidecar image pull policy | `IfNotPresent` | @@ -226,14 +230,16 @@ This version requires Helm >= 3.1.0. | `command` | Define command to be executed by grafana container at startup | `nil` | | `args` | Define additional args if command is used | `nil` | | `testFramework.enabled` | Whether to create test-related resources | `true` | -| `testFramework.image` | `test-framework` image repository. | `bats/bats` | -| `testFramework.tag` | `test-framework` image tag. | `v1.4.1` | +| `testFramework.image.registry` | `test-framework` image registry. | `docker.io` | +| `testFramework.image.repository` | `test-framework` image repository. | `bats/bats` | +| `testFramework.image.tag` | `test-framework` image tag. | `v1.4.1` | | `testFramework.imagePullPolicy` | `test-framework` image pull policy. | `IfNotPresent` | | `testFramework.securityContext` | `test-framework` securityContext | `{}` | | `downloadDashboards.env` | Environment variables to be passed to the `download-dashboards` container | `{}` | | `downloadDashboards.envFromSecret` | Name of a Kubernetes secret (must be manually created in the same namespace) containing values to be added to the environment. Can be templated | `""` | | `downloadDashboards.resources` | Resources of `download-dashboards` container | `{}` | -| `downloadDashboardsImage.repository` | Curl docker image repo | `curlimages/curl` | +| `downloadDashboardsImage.registry` | Curl docker image registry | `docker.io` | +| `downloadDashboardsImage.repository` | Curl docker image repository | `curlimages/curl` | | `downloadDashboardsImage.tag` | Curl docker image tag | `7.73.0` | | `downloadDashboardsImage.sha` | Curl docker image sha (optional) | `""` | | `downloadDashboardsImage.pullPolicy` | Curl docker image pull policy | `IfNotPresent` | @@ -250,6 +256,7 @@ This version requires Helm >= 3.1.0. | `serviceMonitor.metricRelabelings` | MetricRelabelConfigs to apply to samples before ingestion. | `[]` | | `revisionHistoryLimit` | Number of old ReplicaSets to retain | `10` | | `imageRenderer.enabled` | Enable the image-renderer deployment & service | `false` | +| `imageRenderer.image.registry` | image-renderer Image registry | `docker.io` | | `imageRenderer.image.repository` | image-renderer Image repository | `grafana/grafana-image-renderer` | | `imageRenderer.image.tag` | image-renderer Image tag | `latest` | | `imageRenderer.image.sha` | image-renderer Image sha (optional) | `""` | diff --git a/charts/grafana/templates/_pod.tpl b/charts/grafana/templates/_pod.tpl index 23be2ca69a..81dec6c14b 100644 --- a/charts/grafana/templates/_pod.tpl +++ b/charts/grafana/templates/_pod.tpl @@ -22,10 +22,11 @@ initContainers: {{- end }} {{- if ( and .Values.persistence.enabled .Values.initChownData.enabled ) }} - name: init-chown-data + {{- $registry := .Values.global.image.registry | default .Values.initChownData.image.registry -}} {{- if .Values.initChownData.image.sha }} - image: "{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}@sha256:{{ .Values.initChownData.image.sha }}" + image: "{{ $registry }}/{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}@sha256:{{ .Values.initChownData.image.sha }}" {{- else }} - image: "{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}" + image: "{{ $registry }}/{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.initChownData.image.pullPolicy }} {{- with .Values.initChownData.securityContext }} @@ -50,10 +51,11 @@ initContainers: {{- end }} {{- if .Values.dashboards }} - name: download-dashboards + {{- $registry := .Values.global.image.registry | default .Values.downloadDashboardsImage.registry -}} {{- if .Values.downloadDashboardsImage.sha }} - image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}@sha256:{{ .Values.downloadDashboardsImage.sha }}" + image: "{{ $registry }}/{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}@sha256:{{ .Values.downloadDashboardsImage.sha }}" {{- else }} - image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}" + image: "{{ $registry }}/{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}" {{- end }} imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }} command: ["/bin/sh"] @@ -98,10 +100,11 @@ initContainers: {{- end }} {{- if and .Values.sidecar.datasources.enabled .Values.sidecar.datasources.initDatasources }} - name: {{ include "grafana.name" . }}-init-sc-datasources + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -155,10 +158,11 @@ initContainers: {{- end }} {{- if and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers }} - name: {{ include "grafana.name" . }}-init-sc-notifiers + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -231,10 +235,11 @@ enableServiceLinks: {{ .Values.enableServiceLinks }} containers: {{- if .Values.sidecar.alerts.enabled }} - name: {{ include "grafana.name" . }}-sc-alerts + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -337,10 +342,11 @@ containers: {{- end}} {{- if .Values.sidecar.dashboards.enabled }} - name: {{ include "grafana.name" . }}-sc-dashboard + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -447,10 +453,11 @@ containers: {{- end}} {{- if .Values.sidecar.datasources.enabled }} - name: {{ include "grafana.name" . }}-sc-datasources + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -550,10 +557,11 @@ containers: {{- end}} {{- if .Values.sidecar.notifiers.enabled }} - name: {{ include "grafana.name" . }}-sc-notifiers + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -653,10 +661,11 @@ containers: {{- end}} {{- if .Values.sidecar.plugins.enabled }} - name: {{ include "grafana.name" . }}-sc-plugins + {{- $registry := .Values.global.image.registry | default .Values.sidecar.image.registry -}} {{- if .Values.sidecar.image.sha }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}" {{- else }} - image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" + image: "{{ $registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }} env: @@ -755,10 +764,11 @@ containers: mountPath: "/etc/grafana/provisioning/plugins" {{- end}} - name: {{ .Chart.Name }} + {{- $registry := .Values.global.image.registry | default .Values.image.registry -}} {{- if .Values.image.sha }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}@sha256:{{ .Values.image.sha }}" + image: "{{ $registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}@sha256:{{ .Values.image.sha }}" {{- else }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{ $registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.command }} diff --git a/charts/grafana/templates/image-renderer-deployment.yaml b/charts/grafana/templates/image-renderer-deployment.yaml index 93d20e8e72..21ae1c63b4 100644 --- a/charts/grafana/templates/image-renderer-deployment.yaml +++ b/charts/grafana/templates/image-renderer-deployment.yaml @@ -65,10 +65,11 @@ spec: {{- end }} containers: - name: {{ .Chart.Name }}-image-renderer + {{- $registry := .Values.global.image.registry | default .Values.imageRenderer.image.registry -}} {{- if .Values.imageRenderer.image.sha }} - image: "{{ .Values.imageRenderer.image.repository }}:{{ .Values.imageRenderer.image.tag }}@sha256:{{ .Values.imageRenderer.image.sha }}" + image: "{{ $registry }}/{{ .Values.imageRenderer.image.repository }}:{{ .Values.imageRenderer.image.tag }}@sha256:{{ .Values.imageRenderer.image.sha }}" {{- else }} - image: "{{ .Values.imageRenderer.image.repository }}:{{ .Values.imageRenderer.image.tag }}" + image: "{{ $registry }}/{{ .Values.imageRenderer.image.repository }}:{{ .Values.imageRenderer.image.tag }}" {{- end }} imagePullPolicy: {{ .Values.imageRenderer.image.pullPolicy }} {{- if .Values.imageRenderer.command }} diff --git a/charts/grafana/templates/tests/test.yaml b/charts/grafana/templates/tests/test.yaml index 9fb884261e..460ae2079a 100644 --- a/charts/grafana/templates/tests/test.yaml +++ b/charts/grafana/templates/tests/test.yaml @@ -34,7 +34,7 @@ spec: {{- end }} containers: - name: {{ .Release.Name }}-test - image: "{{ .Values.testFramework.image}}:{{ .Values.testFramework.tag }}" + image: "{{ .Values.global.image.registry | default .Values.testFramework.image.registry }}/{{ .Values.testFramework.image.repository }}:{{ .Values.testFramework.image.tag }}" imagePullPolicy: "{{ .Values.testFramework.imagePullPolicy}}" command: ["/opt/bats/bin/bats", "-t", "/tests/run.sh"] volumeMounts: diff --git a/charts/grafana/values.yaml b/charts/grafana/values.yaml index 1093b59e26..fd1f11957d 100644 --- a/charts/grafana/values.yaml +++ b/charts/grafana/values.yaml @@ -1,4 +1,8 @@ global: + image: + # -- Overrides the Docker registry globally for all images + registry: null + # 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. @@ -86,7 +90,10 @@ livenessProbe: # schedulerName: "default-scheduler" image: - repository: docker.io/grafana/grafana + # -- The Docker registry + registry: docker.io + # -- Docker image repository + repository: grafana/grafana # Overrides the Grafana image tag whose default is the chart appVersion tag: "" sha: "" @@ -102,8 +109,11 @@ image: testFramework: enabled: true - image: docker.io/bats/bats - tag: "v1.4.1" + image: + # -- The Docker registry + registry: docker.io + repository: bats/bats + tag: "v1.4.1" imagePullPolicy: IfNotPresent securityContext: {} @@ -146,7 +156,9 @@ extraLabels: {} # priorityClassName: downloadDashboardsImage: - repository: docker.io/curlimages/curl + # -- The Docker registry + registry: docker.io + repository: curlimages/curl tag: 7.85.0 sha: "" pullPolicy: IfNotPresent @@ -361,7 +373,9 @@ initChownData: ## initChownData container image ## image: - repository: docker.io/library/busybox + # -- The Docker registry + registry: docker.io + repository: library/busybox tag: "1.31.1" sha: "" pullPolicy: IfNotPresent @@ -795,7 +809,9 @@ smtp: ## Requires at least Grafana 5 to work and can't be used together with parameters dashboardProviders, datasources and dashboards sidecar: image: - repository: quay.io/kiwigrid/k8s-sidecar + # -- The Docker registry + registry: quay.io + repository: kiwigrid/k8s-sidecar tag: 1.25.1 sha: "" imagePullPolicy: IfNotPresent @@ -1066,8 +1082,10 @@ imageRenderer: targetMemory: "" behavior: {} image: + # -- The Docker registry + registry: docker.io # image-renderer Image repository - repository: docker.io/grafana/grafana-image-renderer + repository: grafana/grafana-image-renderer # image-renderer Image tag tag: latest # image-renderer Image sha (optional)