Support for multiple images in templates.

See https://github.com/helm/helm/issues/7154 for more context

Signed-off-by: Konstantin Semenov <ksemenov@pivotal.io>
pull/7332/head
Konstantin Semenov 6 years ago
parent 8dddb18de7
commit 58a9e155b1

@ -90,13 +90,24 @@ const defaultValues = `# Default values for %s.
# This is a YAML-formatted file. # This is a YAML-formatted file.
# Declare variables to be passed into your templates. # Declare variables to be passed into your templates.
# Default values for images used in the chart; all these values can be overridden in the
# 'images' section for individual images
global:
imageRegistry: docker.io # Allows for easy re-location of all the images to a private registry
imagePullPolicy: IfNotPresent
imagePullSecrets: []
replicaCount: 1 replicaCount: 1
image: images:
repository: nginx nginx:
pullPolicy: IfNotPresent name: bitnami/nginx
tag: 1.16.1-debian-9-r105
digest: sha256:582aa10676417e79995989c0e06ffa8d48ced0cc2b9883669b0379ec9a7f45fb # Optional, to ensure image authenticity
metrics:
name: bitnami/nginx-exporter
tag: 0.4.2-debian-9-r129
imagePullSecrets: []
nameOverride: "" nameOverride: ""
fullnameOverride: "" fullnameOverride: ""
@ -238,10 +249,8 @@ spec:
labels: labels:
{{- include "<CHARTNAME>.selectorLabels" . | nindent 8 }} {{- include "<CHARTNAME>.selectorLabels" . | nindent 8 }}
spec: spec:
{{- with .Values.imagePullSecrets }} {{- $nginxImage := (dict "image" .Values.images.nginx "global" .Values.global) -}}
imagePullSecrets: {{- include "imagePullSecrets" $nginxImage | indent 6 }}
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "<CHARTNAME>.serviceAccountName" . }} serviceAccountName: {{ include "<CHARTNAME>.serviceAccountName" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
@ -249,8 +258,8 @@ spec:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
securityContext: securityContext:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" image: "{{ include "registryImage" $nginxImage }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ include "imagePullPolicy" $nginxImage }}
ports: ports:
- name: http - name: http
containerPort: 80 containerPort: 80
@ -392,7 +401,37 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }} {{ default "default" .Values.serviceAccount.name }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
`
{{/*
Create an image reference
*/}}
{{- define "registryImage" -}}
{{ $registry := default .global.imageRegistry .image.registry }}
{{- printf "%s/%s:%s" $registry .image.name .image.tag -}}
{{- if .image.digest -}}
{{- printf "@%s" .image.digest -}}
{{- end -}}
{{- end -}}
{{/*
Specify the image pull policy
*/}}
{{- define "imagePullPolicy" -}}
{{- printf "%s" (default .global.imagePullPolicy .image.pullPolicy) -}}
{{- end -}}
{{/*
Use the image pull secrets
*/}}
{{- define "imagePullSecrets" -}}
{{- $secrets := default .global.imagePullSecrets .image.pullSecrets -}}
{{- if $secrets -}}
imagePullSecrets:
{{- range $secrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}`
const defaultTestConnection = `apiVersion: v1 const defaultTestConnection = `apiVersion: v1
kind: Pod kind: Pod

Loading…
Cancel
Save