From fcc3501cfe54b972b6cf40fbf754d7b9a880d993 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 10 Nov 2018 22:49:58 -0500 Subject: [PATCH] parrot: private container repo as optional Signed-off-by: Mathieu Benoit --- parrot/charts/parrot/templates/_helpers.tpl | 7 +++++++ parrot/charts/parrot/templates/deployment.yaml | 4 ++++ parrot/charts/parrot/templates/secret.yaml | 9 +++++++++ parrot/charts/parrot/values.yaml | 1 + 4 files changed, 21 insertions(+) create mode 100644 parrot/charts/parrot/templates/secret.yaml diff --git a/parrot/charts/parrot/templates/_helpers.tpl b/parrot/charts/parrot/templates/_helpers.tpl index f0d83d2..eba3ee9 100755 --- a/parrot/charts/parrot/templates/_helpers.tpl +++ b/parrot/charts/parrot/templates/_helpers.tpl @@ -14,3 +14,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Generate the imagePullSecret for a private Container Registry. +*/}} +{{- define "imagePullSecret" }} +{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.image.repository (printf "%s:%s" .Values.image.username .Values.image.password | b64enc) | b64enc }} +{{- end }} \ No newline at end of file diff --git a/parrot/charts/parrot/templates/deployment.yaml b/parrot/charts/parrot/templates/deployment.yaml index 19b49f5..d4bf82e 100755 --- a/parrot/charts/parrot/templates/deployment.yaml +++ b/parrot/charts/parrot/templates/deployment.yaml @@ -17,6 +17,10 @@ spec: labels: app: {{ template "fullname" . }} spec: +{{ if .Values.image.private }} + imagePullSecrets: + - name: acr-secret +{{ end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" diff --git a/parrot/charts/parrot/templates/secret.yaml b/parrot/charts/parrot/templates/secret.yaml new file mode 100644 index 0000000..02c0073 --- /dev/null +++ b/parrot/charts/parrot/templates/secret.yaml @@ -0,0 +1,9 @@ +{{ if .Values.image.private }} +apiVersion: v1 +kind: Secret +metadata: + name: acr-secret +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "imagePullSecret" . }} +{{ end }} \ No newline at end of file diff --git a/parrot/charts/parrot/values.yaml b/parrot/charts/parrot/values.yaml index a579cba..12a3025 100755 --- a/parrot/charts/parrot/values.yaml +++ b/parrot/charts/parrot/values.yaml @@ -1,5 +1,6 @@ replicaCount: 1 image: + private: false pullPolicy: Always service: internalPort: 80