From 75c0d521feefce5d91491be231378816ddf7069a Mon Sep 17 00:00:00 2001 From: Michael 81877 Date: Wed, 1 Feb 2023 11:46:59 +0000 Subject: [PATCH 1/3] add ability to deploy extra k8s yamls with helm chart --- helm/templates/_helpers.tpl | 13 +++++++++++++ helm/templates/extra-deploy.yaml | 4 ++++ helm/values.yaml | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 helm/templates/extra-deploy.yaml diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 05c02b15de44f..6e1598c66e187 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -177,3 +177,16 @@ Deprecated value coder.tls.secretName must not be used. {{ fail "coder.tls.secretName is deprecated, use coder.tls.secretNames instead." }} {{- end }} {{- end }} + +{{/* +Renders a value that contains template. +Usage: +{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "common.tplvalues.render" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} diff --git a/helm/templates/extra-deploy.yaml b/helm/templates/extra-deploy.yaml new file mode 100644 index 0000000000000..9ac65f9e16f4b --- /dev/null +++ b/helm/templates/extra-deploy.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraDeploy }} +--- +{{ include "common.tplvalues.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index b6ef1aa1a125e..6255ccb128dbb 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -198,3 +198,13 @@ coder: # coder.ingress.tls.wildcardSecretName -- The name of the TLS secret to # use for the wildcard host. wildcardSecretName: "" + +# extraDeploy -- Array of extra objects to deploy with the release (evaluated as a template) +extraDeploy: + [] + # - apiVersion: v1 + # kind: ConfigMap + # metadata: + # name: my-configmap + # data: + # key: value From dad39d3fafd54baf683f4714cf1fe1cf4347d7f4 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Sat, 4 Feb 2023 03:10:36 +1000 Subject: [PATCH 2/3] Apply suggestions from code review --- helm/templates/_helpers.tpl | 6 +++--- helm/templates/extra-deploy.yaml | 4 ++-- helm/values.yaml | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 6e1598c66e187..d884b28402000 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -179,11 +179,11 @@ Deprecated value coder.tls.secretName must not be used. {{- end }} {{/* -Renders a value that contains template. +Renders a value that contains a template. Usage: -{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }} +{{ include "coder.renderTemplate" ( dict "value" .Values.path.to.the.Value "context" $) }} */}} -{{- define "common.tplvalues.render" -}} +{{- define "coder.renderTemplate" -}} {{- if typeIs "string" .value }} {{- tpl .value .context }} {{- else }} diff --git a/helm/templates/extra-deploy.yaml b/helm/templates/extra-deploy.yaml index 9ac65f9e16f4b..e04765810055a 100644 --- a/helm/templates/extra-deploy.yaml +++ b/helm/templates/extra-deploy.yaml @@ -1,4 +1,4 @@ -{{- range .Values.extraDeploy }} +{{- range .Values.extraTemplates }} --- -{{ include "common.tplvalues.render" (dict "value" . "context" $) }} +{{ include "coder.renderTemplate" (dict "value" . "context" $) }} {{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 6255ccb128dbb..123618d8660d5 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -199,12 +199,14 @@ coder: # use for the wildcard host. wildcardSecretName: "" -# extraDeploy -- Array of extra objects to deploy with the release (evaluated as a template) -extraDeploy: +# extraTemplates -- Array of extra objects to deploy with the release. These +# are evaluated as a template and can use template expansions and functions. +# Strings are used as is, and all other objects are used as yaml. +extraTemplates: [] # - apiVersion: v1 # kind: ConfigMap # metadata: # name: my-configmap # data: - # key: value + # key: {{ .Values.myCustomvalue | quote }} From bdd7ef3770bb69fb75f57b7c121a1031e946fe99 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Fri, 3 Feb 2023 17:16:47 +0000 Subject: [PATCH 3/3] chore: correct example --- ...extra-deploy.yaml => extra-templates.yaml} | 0 helm/values.yaml | 20 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) rename helm/templates/{extra-deploy.yaml => extra-templates.yaml} (100%) diff --git a/helm/templates/extra-deploy.yaml b/helm/templates/extra-templates.yaml similarity index 100% rename from helm/templates/extra-deploy.yaml rename to helm/templates/extra-templates.yaml diff --git a/helm/values.yaml b/helm/values.yaml index 123618d8660d5..45bfad2558aa5 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -199,14 +199,14 @@ coder: # use for the wildcard host. wildcardSecretName: "" -# extraTemplates -- Array of extra objects to deploy with the release. These -# are evaluated as a template and can use template expansions and functions. -# Strings are used as is, and all other objects are used as yaml. +# extraTemplates -- Array of extra objects to deploy with the release. Strings +# are evaluated as a template and can use template expansions and functions. All +# other objects are used as yaml. extraTemplates: - [] - # - apiVersion: v1 - # kind: ConfigMap - # metadata: - # name: my-configmap - # data: - # key: {{ .Values.myCustomvalue | quote }} + #- | + # apiVersion: v1 + # kind: ConfigMap + # metadata: + # name: my-configmap + # data: + # key: {{ .Values.myCustomValue | quote }}