From 2285a5e8a010786d7180035e7cbb93e3e7268def Mon Sep 17 00:00:00 2001 From: mh013370 <86672176+mh013370@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:32:02 +0000 Subject: [PATCH] feat: add ability to deploy extra k8s yamls with helm chart (#5942) --- helm/templates/_helpers.tpl | 13 +++++++++++++ helm/templates/extra-templates.yaml | 4 ++++ helm/values.yaml | 12 ++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 helm/templates/extra-templates.yaml diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 05c02b15de..d884b28402 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 a template. +Usage: +{{ include "coder.renderTemplate" ( dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "coder.renderTemplate" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} diff --git a/helm/templates/extra-templates.yaml b/helm/templates/extra-templates.yaml new file mode 100644 index 0000000000..e047658100 --- /dev/null +++ b/helm/templates/extra-templates.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraTemplates }} +--- +{{ include "coder.renderTemplate" (dict "value" . "context" $) }} +{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index b6ef1aa1a1..45bfad2558 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -198,3 +198,15 @@ coder: # coder.ingress.tls.wildcardSecretName -- The name of the TLS secret to # use for the wildcard host. wildcardSecretName: "" + +# 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 }}