Skip to content

Commit

Permalink
Allow imagePullSecrets to be added via Helm.
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonshatch authored and gamingrobot committed May 30, 2023
1 parent ff94e1d commit c05d331
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/helm/build/templates/overlays/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
spec:
template:
spec:
imagePullSecrets:
- name: '{{ .Values.imageCredentials.pullSecretName }}'
containers:
- name: contrast-agent-operator
env:
Expand Down
16 changes: 16 additions & 0 deletions manifests/helm/templates/image-pull-secrets.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- define "imagePullSecret" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}
{{ if .Values.imageCredentials.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.imageCredentials.pullSecretName }}
namespace: >-
{{ .Values.namespace }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
{{ end }}
10 changes: 10 additions & 0 deletions manifests/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ image:
# Defaults to the version specified in Chart.AppVersion.
tag:

imageCredentials:
# Name of the registry credential secret that should be used to pull the above image.
pullSecretName: image-credentials
# If enabled, a registry credential secret will be created using the above name and below credentials.
enabled: false
registry: contrast
username:
password:
email:

operator:
# The default registry to use, defaults to docker.io/contrast.
defaultRegistry: contrast
Expand Down

0 comments on commit c05d331

Please sign in to comment.