Skip to content

Commit ff11dee

Browse files
authored
Documents helper for image pull secrets
Addressing a question @grantmiller asked about whether we recommend using a Helper or not for image pull secrets.
1 parent 771dd44 commit ff11dee

File tree

1 file changed

+48
-7
lines changed

1 file changed

+48
-7
lines changed

docs/vendor/helm-image-registry.mdx

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,52 @@ To configure your application to use the proxy registry with Helm CLI installati
4646
.dockerconfigjson: {{ .Values.global.replicated.dockerconfigjson }}
4747
{{ end }}
4848
```
49-
50-
1. Add the image pull secret that you created to any manifests that reference the image.
49+
1. Add a Helm helper for the image pull secret to your `_helper.tpl`. This code will use your secret but allow your customer to override it for situations, like an airgapped installation, where they have moved the image to another regitsry:
50+
51+
```yam1
52+
{{/*
53+
Image pull secrets
54+
*/}}
55+
{{- define "replicated.imagePullSecrets" -}}
56+
{{- $pullSecrets := list }}
57+
58+
{{- with ((.Values.global).imagePullSecrets) -}}
59+
{{- range . -}}
60+
{{- if kindIs "map" . -}}
61+
{{- $pullSecrets = append $pullSecrets .name -}}
62+
{{- else -}}
63+
{{- $pullSecrets = append $pullSecrets . -}}
64+
{{- end }}
65+
{{- end -}}
66+
{{- end -}}
67+
68+
{{/* use image pull secrets provided as values */}}
69+
{{- with .Values.images -}}
70+
{{- range .pullSecrets -}}
71+
{{- if kindIs "map" . -}}
72+
{{- $pullSecrets = append $pullSecrets .name -}}
73+
{{- else -}}
74+
{{- $pullSecrets = append $pullSecrets . -}}
75+
{{- end -}}
76+
{{- end -}}
77+
{{- end -}}
78+
79+
{{/* use secret created with injected docker config */}}
80+
{{- if hasKey ((.Values.global).replicated) "dockerconfigjson" }}
81+
{{- $pullSecrets = append $pullSecrets "replicated-pull-secret" -}}
82+
{{- end -}}
83+
84+
85+
{{- if (not (empty $pullSecrets)) -}}
86+
imagePullSecrets:
87+
{{- range $pullSecrets | uniq }}
88+
- name: {{ . }}
89+
{{- end }}
90+
{{- end }}
91+
{{- end -}}
92+
```
93+
94+
1. Use your helper in any manifests that reference the image.
5195

5296
**Example:**
5397

@@ -59,11 +103,8 @@ To configure your application to use the proxy registry with Helm CLI installati
59103
- name: api
60104
# Access the registry, repository, and tag fields from the values file
61105
image: {{ .Values.images.api.registry }}/{{ .Values.images.api.repository }}:{{ .Values.images.api.tag }}
62-
# Add the pull secret
63-
{{ if .Values.global.replicated.dockerconfigjson }}
64-
imagePullSecrets:
65-
- name: replicated-pull-secret
66-
{{ end }}
106+
# Add the pull secret with your helper
107+
{{- include "replicated.imagePullSecrets" . | nindent 6 }}
67108
```
68109

69110
1. Package your Helm chart and add it to a release. Promote the release to a development channel. See [Managing Releases with Vendor Portal](releases-creating-releases).

0 commit comments

Comments
 (0)