If you want to choose an image based on a condition, you can do it with the following example:
image:
repository: my-docker-repo/my-image
tag: "latest"
pullPolicy: Always
app:
db: mongodb://foo:bar@0.0.0.0:1234/mydb
apiVersion: apps/v1beta2
kind: Deployment
metadata:
...
spec:
...
template:
...
spec:
imagePullSecrets:
- name: {{ .Values.app.pullSecret }}
containers:
- name: {{ .Chart.Name }}
{{ if hasPrefix "db2" .Values.app.db }}
image: "{{ .Values.image.repository }}-custom:{{ .Values.image.tag }}"
{{ else }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
{{ end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
** Notice that I've used the golang function hasPrefix to verify if the image name starts with db2.
When execute with default value, it will generate the default image:
helm install --dry-run --debug my-helm-chart | grep "image: "
Result: image: "my-docker-repo/my-image:latest"
When execute with custom value, it will generate the custom image:
helm install \
--set "app.db=db2://foo:bar@0.0.0.0:1234,0.0.0.1:2345/mydb?foo=bar" \
--dry-run --debug my-helm-chart | grep "image: "
Result: image: "my-docker-repo/my-image-custom:latest"