From 63472a09bdd171b8d3ec0014fd19bb927742eab9 Mon Sep 17 00:00:00 2001 From: Martino Dell'Ambrogio Date: Mon, 23 Nov 2026 08:59:10 +0100 Subject: [PATCH] Add image.pullSecrets for private registries The chart had no way to set imagePullSecrets, so pulling the image from a private registry (a mirror, or a rebuilt image) meant creating a separate ServiceAccount carrying the secret and setting serviceAccount.create=false. image.pullSecrets is rendered as the pod's imagePullSecrets, so it covers every container, the metrics exporter included. The default, an empty list, renders nothing, so existing releases do not change. Tests: two cases in tests/deployment_test.yaml; snapshots unchanged. --- .../docker-mailserver/templates/deployment.yaml | 3 +++ .../docker-mailserver/tests/deployment_test.yaml | 16 +++++++++++++++- charts/docker-mailserver/values.yaml | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/charts/docker-mailserver/templates/deployment.yaml b/charts/docker-mailserver/templates/deployment.yaml index 8b9dce5..dcf6bb5 100644 --- a/charts/docker-mailserver/templates/deployment.yaml +++ b/charts/docker-mailserver/templates/deployment.yaml @@ -43,6 +43,9 @@ spec: priorityClassName: {{ .Values.deployment.priorityClassName }} restartPolicy: "Always" serviceAccountName: {{ template "dockermailserver.serviceAccountName" . }} + {{- with .Values.image.pullSecrets }} + imagePullSecrets: {{- toYaml . | nindent 8 }} + {{- end }} securityContext: {{ toYaml (coalesce .Values.deployment.securityContext .Values.securityContext) | indent 8 }} {{- if .Values.deployment.tolerations }} diff --git a/charts/docker-mailserver/tests/deployment_test.yaml b/charts/docker-mailserver/tests/deployment_test.yaml index 44195da..ee3fabd 100644 --- a/charts/docker-mailserver/tests/deployment_test.yaml +++ b/charts/docker-mailserver/tests/deployment_test.yaml @@ -33,4 +33,18 @@ tests: - it: manifest should match snapshot asserts: - - matchSnapshot: { } \ No newline at end of file + - matchSnapshot: { } + - it: renders no imagePullSecrets by default + asserts: + - notExists: + path: spec.template.spec.imagePullSecrets + + - it: passes image.pullSecrets to the pod + set: + image.pullSecrets: + - name: registry-credentials + asserts: + - equal: + path: spec.template.spec.imagePullSecrets + value: + - name: registry-credentials diff --git a/charts/docker-mailserver/values.yaml b/charts/docker-mailserver/values.yaml index fe80f32..a0bf553 100644 --- a/charts/docker-mailserver/values.yaml +++ b/charts/docker-mailserver/values.yaml @@ -8,6 +8,11 @@ image: ## If image.tag is not defined it will default to `.Chart.appVersion` # tag: "latest" pullPolicy: "IfNotPresent" + ## image.pullSecrets lists Secrets of type kubernetes.io/dockerconfigjson for pulling from a private registry. + ## They apply to every container of the pod, including the metrics exporter. + # pullSecrets: + # - name: registry-credentials + pullSecrets: [] # Specify whether to create a serviceAccount for the pod. The name is generated from the # dockermailserver.serviceAccountName template