From 666faeb72add0a5af2a632c9487a0113ff187aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Unai=20Arr=C3=ADen?= Date: Mon, 1 Mar 2021 17:26:43 +0100 Subject: [PATCH] build(helm): making customizable components Docker images (#209) --- charts/capsule/Chart.yaml | 2 +- charts/capsule/templates/_helpers.tpl | 18 ++++++++++++++++-- charts/capsule/templates/deployment.yaml | 6 +++--- charts/capsule/templates/post-install-job.yaml | 3 ++- charts/capsule/templates/pre-delete-job.yaml | 3 ++- charts/capsule/values.yaml | 5 +++++ 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/charts/capsule/Chart.yaml b/charts/capsule/Chart.yaml index 22b00505..583ed8db 100644 --- a/charts/capsule/Chart.yaml +++ b/charts/capsule/Chart.yaml @@ -21,7 +21,7 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.0.11 +version: 0.0.12 # This is the version number of the application being deployed. # This version number should be incremented each time you make changes to the application. diff --git a/charts/capsule/templates/_helpers.tpl b/charts/capsule/templates/_helpers.tpl index 0faa5694..2d1e7fee 100644 --- a/charts/capsule/templates/_helpers.tpl +++ b/charts/capsule/templates/_helpers.tpl @@ -62,12 +62,26 @@ Create the name of the service account to use {{- end }} {{/* -Create the fully-qualified Docker image to use +Create the manager fully-qualified Docker image to use */}} -{{- define "capsule.fullyQualifiedDockerImage" -}} +{{- define "capsule.managerFullyQualifiedDockerImage" -}} {{- printf "%s:%s" .Values.manager.image.repository ( .Values.manager.image.tag | default (printf "v%s" .Chart.AppVersion) ) -}} {{- end }} +{{/* +Create the proxy fully-qualified Docker image to use +*/}} +{{- define "capsule.proxyFullyQualifiedDockerImage" -}} +{{- printf "%s:%s" .Values.proxy.image.repository .Values.proxy.image.tag -}} +{{- end }} + +{{/* +Create the jobs fully-qualified Docker image to use +*/}} +{{- define "capsule.jobsFullyQualifiedDockerImage" -}} +{{- printf "%s:%s" .Values.jobs.image.repository .Values.jobs.image.tag -}} +{{- end }} + {{/* Create the Capsule Deployment name to use */}} diff --git a/charts/capsule/templates/deployment.yaml b/charts/capsule/templates/deployment.yaml index bfc1bebe..cffee105 100644 --- a/charts/capsule/templates/deployment.yaml +++ b/charts/capsule/templates/deployment.yaml @@ -52,7 +52,7 @@ spec: {{ if .Values.manager.options.forceTenantPrefix }}- --force-tenant-prefix={{ .Values.manager.options.forceTenantPrefix }}{{ end }} {{ if .Values.manager.options.capsuleUserGroup }}- --capsule-user-group={{ .Values.manager.options.capsuleUserGroup }}{{ end }} {{ if .Values.manager.options.protectedNamespaceRegex }}- --protected-namespace-regex={{ .Values.manager.options.protectedNamespaceRegex }}{{ end }} - image: {{ include "capsule.fullyQualifiedDockerImage" . }} + image: {{ include "capsule.managerFullyQualifiedDockerImage" . }} imagePullPolicy: {{ .Values.manager.image.pullPolicy }} env: - name: NAMESPACE @@ -80,8 +80,8 @@ spec: securityContext: allowPrivilegeEscalation: false - name: kube-rbac-proxy - image: {{ .Values.proxy.image.repository }}:{{ .Values.proxy.image.tag }} - imagePullPolicy: IfNotPresent + image: {{ include "capsule.proxyFullyQualifiedDockerImage" . }} + imagePullPolicy: {{ .Values.proxy.image.pullPolicy }} args: - --secure-listen-address=0.0.0.0:8443 - --upstream=http://127.0.0.1:8080/ diff --git a/charts/capsule/templates/post-install-job.yaml b/charts/capsule/templates/post-install-job.yaml index 3027b23f..9a0a6ffd 100644 --- a/charts/capsule/templates/post-install-job.yaml +++ b/charts/capsule/templates/post-install-job.yaml @@ -28,7 +28,8 @@ spec: restartPolicy: Never containers: - name: post-install-job - image: "bitnami/kubectl:1.18" + image: {{ include "capsule.jobsFullyQualifiedDockerImage" . }} + imagePullPolicy: {{ .Values.jobs.image.pullPolicy }} command: ["sh", "-c", "{{ $cmd }}"] env: - name: NAMESPACE diff --git a/charts/capsule/templates/pre-delete-job.yaml b/charts/capsule/templates/pre-delete-job.yaml index fd50639d..327c3d17 100644 --- a/charts/capsule/templates/pre-delete-job.yaml +++ b/charts/capsule/templates/pre-delete-job.yaml @@ -29,7 +29,8 @@ spec: restartPolicy: Never containers: - name: pre-delete-job - image: "bitnami/kubectl:1.18" + image: {{ include "capsule.jobsFullyQualifiedDockerImage" . }} + imagePullPolicy: {{ .Values.jobs.image.pullPolicy }} command: [ "sh", "-c", "{{ $cmd }}"] env: - name: NAMESPACE diff --git a/charts/capsule/values.yaml b/charts/capsule/values.yaml index fe7dbdac..6d176953 100644 --- a/charts/capsule/values.yaml +++ b/charts/capsule/values.yaml @@ -32,6 +32,11 @@ proxy: requests: cpu: 10m memory: 64Mi +jobs: + image: + repository: bitnami/kubectl + pullPolicy: IfNotPresent + tag: "1.18" mutatingWebhooksTimeoutSeconds: 30 validatingWebhooksTimeoutSeconds: 30 imagePullSecrets: []