This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
{{/* Renders the certificate objects required by the chart */}}
|
||||
{{- define "tc.v1.common.spawner.certificate" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Generate named certs as required */}}
|
||||
{{- range $name, $cert := .Values.cert -}}
|
||||
{{- if $cert.enabled -}}
|
||||
{{- $certValues := $cert -}}
|
||||
{{- $certName := $fullname -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if and (not $certValues.nameOverride) (ne $name (include "tc.v1.common.lib.util.cert.primary" $)) -}}
|
||||
{{- $_ := set $certValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $certValues.nameOverride -}}
|
||||
{{- $certName = printf "%v-%v" $certName $certValues.nameOverride -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $certValues.secretTemplate -}}
|
||||
{{- $certName = printf "%v-%v" "clusterissuer-templated" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- include "tc.v1.common.class.certificate" (dict "root" $ "name" $certName "certificateIssuer" $cert.certificateIssuer "hosts" $cert.hosts "secretTemplate" $cert.secretTemplate ) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
102
helm-charts/dashy/charts/common/templates/spawner/_cnpg.tpl
Normal file
102
helm-charts/dashy/charts/common/templates/spawner/_cnpg.tpl
Normal file
@@ -0,0 +1,102 @@
|
||||
{{/* Renders the cnpg objects required by the chart */}}
|
||||
{{- define "tc.v1.common.spawner.cnpg" -}}
|
||||
{{/* Generate named cnpges as required */}}
|
||||
{{- range $name, $cnpg := $.Values.cnpg }}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $cnpg "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $cnpg.enabled) -}}
|
||||
{{- $enabled = $cnpg.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "cnpg - Expected the defined key [enabled] in <cnpg.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
{{/* After tpl it becomes a string, not a bool */}}
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- $enabled = true -}}
|
||||
{{- else if eq $enabled "false" -}}
|
||||
{{- $enabled = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- $cnpgValues := $cnpg }}
|
||||
{{- $cnpgName := include "tc.v1.common.lib.chart.names.fullname" $ }}
|
||||
{{- $_ := set $cnpgValues "shortName" $name }}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- $_ := set $cnpgValues "nameOverride" ( printf "cnpg-%v" $name ) }}
|
||||
|
||||
{{- $cnpgName := printf "%v-%v" $cnpgName $cnpgValues.nameOverride }}
|
||||
|
||||
{{- $_ := set $cnpgValues "name" $cnpgName }}
|
||||
|
||||
{{- if $enabled -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "cnpg" $cnpgValues) }}
|
||||
{{- include "tc.v1.common.class.cnpg.cluster" $ }}
|
||||
|
||||
{{- $_ := set $cnpgValues.pooler "type" "rw" }}
|
||||
{{- if not $cnpgValues.acceptRO }}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" $ }}
|
||||
{{- else }}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" $ }}
|
||||
{{- $_ := set $cnpgValues.pooler "type" "ro" }}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" $ }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- $dbPass := "" }}
|
||||
{{- $dbprevious := lookup "v1" "Secret" $.Release.Namespace ( printf "%s-user" $cnpgValues.name ) }}
|
||||
{{- if or $enabled $dbprevious -}}
|
||||
{{/* Inject the required secrets */}}
|
||||
|
||||
{{- if $dbprevious }}
|
||||
{{- $dbPass = ( index $dbprevious.data "password" ) | b64dec }}
|
||||
{{- else }}
|
||||
{{- $dbPass = $cnpgValues.password | default ( randAlphaNum 62 ) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $std := ( ( printf "postgresql://%v:%v@%v-rw:5432/%v" $cnpgValues.user $dbPass $cnpgValues.name $cnpgValues.database ) | quote ) }}
|
||||
{{- $nossl := ( ( printf "postgresql://%v:%v@%v-rw:5432/%v?sslmode=disable" $cnpgValues.user $dbPass $cnpgValues.name $cnpgValues.database ) | quote ) }}
|
||||
{{- $porthost := ( ( printf "%s-rw:5432" $cnpgValues.name ) | quote ) }}
|
||||
{{- $host := ( ( printf "%s-rw" $cnpgValues.name ) | quote ) }}
|
||||
{{- $jdbc := ( ( printf "jdbc:postgresql://%v-rw:5432/%v" $cnpgValues.name $cnpgValues.database ) | quote ) }}
|
||||
|
||||
{{- $userSecret := include "tc.v1.common.lib.cnpg.secret.user" (dict "values" $cnpgValues "dbPass" $dbPass ) | fromYaml }}
|
||||
{{- if $userSecret }}
|
||||
{{- $_ := set $.Values.secret ( printf "cnpg-%s-user" $cnpgValues.shortName ) $userSecret }}
|
||||
{{- end }}
|
||||
|
||||
{{- $urlSecret := include "tc.v1.common.lib.cnpg.secret.urls" (dict "std" $std "nossl" $nossl "porthost" $porthost "host" $host "jdbc" $jdbc) | fromYaml }}
|
||||
{{- if $urlSecret }}
|
||||
{{- $_ := set $.Values.secret ( printf "cnpg-%s-urls" $cnpgValues.shortName ) $urlSecret }}
|
||||
{{- end }}
|
||||
|
||||
{{- $_ := set $cnpgValues.creds "password" ( $dbPass | quote ) }}
|
||||
{{- $_ := set $cnpgValues.creds "std" $std }}
|
||||
{{- $_ := set $cnpgValues.creds "nossl" $nossl }}
|
||||
{{- $_ := set $cnpgValues.creds "porthost" $porthost }}
|
||||
{{- $_ := set $cnpgValues.creds "host" $host }}
|
||||
{{- $_ := set $cnpgValues.creds "jdbc" $jdbc }}
|
||||
|
||||
{{- if $cnpgValues.monitoring }}
|
||||
{{- if $cnpgValues.monitoring.enablePodMonitor }}
|
||||
{{- $poolermetrics := include "tc.v1.common.lib.cnpg.metrics.pooler" (dict "poolerName" ( printf "%s-rw" $cnpgValues.name) ) | fromYaml }}
|
||||
|
||||
{{- $_ := set $.Values.metrics ( printf "cnpg-%s-rw" $cnpgValues.shortName ) $poolermetrics }}
|
||||
{{- if $cnpgValues.acceptRO }}
|
||||
{{- $poolermetricsRO := include "tc.v1.common.lib.cnpg.metrics.pooler" (dict "poolerName" ( printf "%s-ro" $cnpgValues.name) ) | fromYaml }}
|
||||
{{- $_ := set $.Values.metrics ( printf "cnpg-%s-ro" $cnpgValues.shortName ) $poolermetricsRO }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,60 @@
|
||||
{{/* Configmap Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.configmap" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.configmap" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $configmap := .Values.configmap -}}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $configmap "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $configmap.enabled) -}}
|
||||
{{- $enabled = $configmap.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "ConfigMap - Expected the defined key [enabled] in <configmap.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
{{/* After tpl it becomes a string, not a bool */}}
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- $enabled = true -}}
|
||||
{{- else if eq $enabled "false" -}}
|
||||
{{- $enabled = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $enabled -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $configmap) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.configmap.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "ConfigMap") -}}
|
||||
|
||||
{{/* Set the name of the configmap */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.configmap" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,32 @@
|
||||
{{/* External Interface Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.externalInterface" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.externalInterface" -}}
|
||||
|
||||
{{- range $iface := .Values.scaleExternalInterface -}}
|
||||
{{- include "tc.v1.common.lib.externalInterface.validation" (dict "objectData" $iface) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Now we have validated interfaces, render the objects */}}
|
||||
|
||||
{{- range $index, $interface := .Values.ixExternalInterfacesConfiguration -}}
|
||||
|
||||
{{- $objectData := dict -}}
|
||||
{{/* Create a copy of the interface and put it in objectData.config */}}
|
||||
{{- $_ := set $objectData "config" (mustDeepCopy $interface) -}}
|
||||
|
||||
{{- $objectName := (printf "ix-%s-%v" $.Release.Name $index) -}}
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
|
||||
{{/* Set the name of the object to objectData.name */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.networkAttachmentDefinition" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,13 @@
|
||||
{{- define "tc.v1.common.spawner.extraTpl" -}}
|
||||
{{- range $item := .Values.extraTpl }}
|
||||
{{- if not $item -}}
|
||||
{{- fail "Extra tpl - Expected non-empty <extraTpl> item" -}}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if kindIs "string" $item }}
|
||||
{{- tpl $item $ | nindent 0 }}
|
||||
{{- else }}
|
||||
{{- tpl ($item | toYaml) $ | nindent 0 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{/*
|
||||
Renders the configMap objects required by the chart.
|
||||
*/}}
|
||||
{{- define "tc.v1.common.spawner.hpa" -}}
|
||||
{{/* Generate named configMaps as required */}}
|
||||
{{- range $name, $hpa := .Values.horizontalPodAutoscaler -}}
|
||||
{{- if $hpa.enabled -}}
|
||||
{{- $hpaValues := $hpa -}}
|
||||
|
||||
{{/* set the default nameOverride to the hpa name */}}
|
||||
{{- if not $hpaValues.nameOverride -}}
|
||||
{{- $_ := set $hpaValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "hpa" $hpaValues) -}}
|
||||
{{- include "tc.v1.common.class.hpa" $ -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,41 @@
|
||||
{{/* Image Pull Secrets Spawner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.imagePullSecret" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.imagePullSecret" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $imgPullSecret := .Values.imagePullSecret -}}
|
||||
|
||||
{{- if $imgPullSecret.enabled -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $imgPullSecret) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
|
||||
{{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.imagePullSecret.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Image Pull Secret") -}}
|
||||
{{- $data := include "tc.v1.common.lib.imagePullSecret.createData" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{/* Update the data */}}
|
||||
{{- $_ := set $objectData "data" $data -}}
|
||||
|
||||
{{/* Set the type to Image Pull Secret */}}
|
||||
{{- $_ := set $objectData "type" "imagePullSecret" -}}
|
||||
|
||||
{{/* Set the name of the image pull secret */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,62 @@
|
||||
{{/* Renders the Ingress objects required by the chart */}}
|
||||
{{- define "tc.v1.common.spawner.ingress" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Generate named ingresses as required */}}
|
||||
{{- range $name, $ingress := .Values.ingress -}}
|
||||
{{- if $ingress.enabled -}}
|
||||
{{- $ingressValues := $ingress -}}
|
||||
{{- $ingressName := $fullname -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if and (not $ingressValues.nameOverride) (ne $name (include "tc.v1.common.lib.util.ingress.primary" $)) -}}
|
||||
{{- $_ := set $ingressValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $ingressValues.nameOverride -}}
|
||||
{{- $ingressName = printf "%v-%v" $ingressName $ingressValues.nameOverride -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ingressValues "name" $ingressName -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
|
||||
{{- include "tc.v1.common.class.ingress" $ -}}
|
||||
{{- if and ( $ingressValues.tls ) ( not $ingressValues.clusterIssuer ) -}}
|
||||
{{- range $index, $tlsValues := $ingressValues.tls -}}
|
||||
{{- $tlsName := ( printf "%v-%v" "tls" $index ) -}}
|
||||
{{- if $tlsValues.certificateIssuer -}}
|
||||
{{- include "tc.v1.common.class.certificate" (dict "root" $ "name" ( printf "%v-%v" $ingressName $tlsName ) "certificateIssuer" $tlsValues.certificateIssuer "hosts" $tlsValues.hosts ) -}}
|
||||
{{- else if and ( $tlsValues.scaleCert ) ( $.Values.global.ixChartContext ) -}}
|
||||
|
||||
{{/* Create certificate object and use it to construct a secret */}}
|
||||
{{- $objectData := dict -}}
|
||||
{{- $_ := set $objectData "id" .scaleCert -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $tlsName) -}}
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.scaleCertificate.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Certificate") -}}
|
||||
|
||||
{{/* Prepare data */}}
|
||||
{{- $data := fromJson (include "tc.v1.common.lib.scaleCertificate.getData" (dict "rootCtx" $ "objectData" $objectData)) -}}
|
||||
{{- $_ := set $objectData "data" $data -}}
|
||||
|
||||
{{/* Set the type to certificate */}}
|
||||
{{- $_ := set $objectData "type" "certificate" -}}
|
||||
|
||||
{{/* Set the name of the certificate */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else if $ingress.required -}}
|
||||
{{- fail (printf "Ingress - <ingress.%s> is set to be [required] and cannot be disabled" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,28 @@
|
||||
{{/* Renders the Ingress objects required by the chart */}}
|
||||
{{- define "tc.v1.common.spawner.metrics" -}}
|
||||
{{/* Generate named metricses as required */}}
|
||||
{{- range $name, $metrics := .Values.metrics -}}
|
||||
{{- if $metrics.enabled -}}
|
||||
{{- $metricsValues := $metrics -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if and (not $metricsValues.nameOverride) (ne $name (include "tc.v1.common.lib.util.metrics.primary" $)) -}}
|
||||
{{- $_ := set $metricsValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "metrics" $metricsValues) -}}
|
||||
{{- if eq $metricsValues.type "podmonitor" -}}
|
||||
{{- include "tc.v1.common.class.podmonitor" $ -}}
|
||||
{{- else if eq $metricsValues.type "servicemonitor" -}}
|
||||
{{- include "tc.v1.common.class.servicemonitor" $ -}}
|
||||
{{- else -}}
|
||||
{{/* TODO: Add Fail case */}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $metricsValues.PrometheusRule -}}
|
||||
{{- include "tc.v1.common.class.prometheusrule" $ -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{/*
|
||||
Renders the networkPolicy objects required by the chart.
|
||||
*/}}
|
||||
{{- define "tc.v1.common.spawner.networkpolicy" -}}
|
||||
{{/* Generate named networkpolicy as required */}}
|
||||
{{- range $name, $networkPolicy := .Values.networkPolicy -}}
|
||||
{{- if $networkPolicy.enabled -}}
|
||||
{{- $networkPolicyValues := $networkPolicy -}}
|
||||
|
||||
{{/* set the default nameOverride to the networkpolicy name */}}
|
||||
{{- if not $networkPolicyValues.nameOverride -}}
|
||||
{{- $_ := set $networkPolicyValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "networkPolicy" $networkPolicyValues) -}}
|
||||
{{- include "tc.v1.common.class.networkpolicy" $ -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,59 @@
|
||||
{{/* poddisruptionbudget Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.podDisruptionBudget" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.podDisruptionBudget" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $pdb := .Values.podDisruptionBudget -}}
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $pdb "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $pdb.enabled) -}}
|
||||
{{- $enabled = $pdb.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Pod Disruption Budget - Expected the defined key [enabled] in <podDisruptionBudget.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
{{/* After tpl it becomes a string, not a bool */}}
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- $enabled = true -}}
|
||||
{{- else if eq $enabled "false" -}}
|
||||
{{- $enabled = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $enabled -}}
|
||||
|
||||
{{/* Create a copy of the poddisruptionbudget */}}
|
||||
{{- $objectData := (mustDeepCopy $pdb) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Pod Disruption Budget") -}}
|
||||
|
||||
{{/* Set the name of the poddisruptionbudget */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.podDisruptionBudget.validation" (dict "objectData" $objectData "rootCtx" $) -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.podDisruptionBudget" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
176
helm-charts/dashy/charts/common/templates/spawner/_portal.tpl
Normal file
176
helm-charts/dashy/charts/common/templates/spawner/_portal.tpl
Normal file
@@ -0,0 +1,176 @@
|
||||
{{/* Portal Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.portal" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.portal" -}}
|
||||
{{- range $name, $portal := .Values.portal -}}
|
||||
{{- if $portal.enabled -}}
|
||||
|
||||
{{/* Create a copy of the portal */}}
|
||||
{{- $objectData := (mustDeepCopy $portal) -}}
|
||||
{{- $override := $objectData.override -}}
|
||||
{{- $targetSelector := $objectData.targetSelector -}}
|
||||
|
||||
{{/* Create defaults */}}
|
||||
{{- $protocol := "http" -}}
|
||||
{{- $host := "$node_ip" -}}
|
||||
{{- $port := "443" -}}
|
||||
{{- $path := $objectData.path | default "/" -}}
|
||||
{{- $url := "" -}}
|
||||
|
||||
|
||||
{{/* Get service, default to primary */}}
|
||||
{{- $serviceData := dict "targetSelector" $targetSelector.service -}}
|
||||
{{- $selectedService := fromYaml ( include "tc.v1.common.lib.helpers.getSelectedServiceValues" (dict "rootCtx" $ "objectData" $serviceData)) }}
|
||||
|
||||
{{/* read loadbalancer IPs for metallb */}}
|
||||
{{- if eq $selectedService.type "LoadBalancer" -}}
|
||||
{{- with $selectedService.loadBalancerIP -}}
|
||||
{{- $host = toString . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* set temporary storage for port name and port */}}
|
||||
{{- $targetPort := "" -}}
|
||||
{{- $selectedPort := "" -}}
|
||||
|
||||
{{/* Fetch port values */}}
|
||||
{{- if $targetSelector.port -}}
|
||||
{{- $targetPort = $targetSelector.port -}}
|
||||
{{- else -}}
|
||||
{{- $targetPort = include "tc.v1.common.lib.util.service.ports.primary" (dict "svcName" $selectedService.shortName "svcValues" $selectedService ) -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- $selectedPort = get $selectedService.ports $targetPort -}}
|
||||
|
||||
{{/* store port number */}}
|
||||
{{- $port = $selectedPort.port -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/* set temporary storage for ingress name and port */}}
|
||||
{{- $targetIngress := "" -}}
|
||||
{{- $selectedIngress := "" -}}
|
||||
|
||||
{{/* Fetch ingress values */}}
|
||||
{{- if $targetSelector.ingress -}}
|
||||
{{- $targetIngress = $targetSelector.ingress -}}
|
||||
{{- else -}}
|
||||
{{- $targetIngress = ( include "tc.v1.common.lib.util.ingress.primary" $ ) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $selectedIngress = get $.Values.ingress $targetIngress -}}
|
||||
|
||||
{{/* store host from ingress number */}}
|
||||
{{- if $selectedIngress -}}
|
||||
{{- if $selectedIngress.enabled -}}
|
||||
{{- with (index $selectedIngress.hosts 0) }}
|
||||
{{- $host = .host -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* Get the port for the ingress entrypoint */}}
|
||||
|
||||
|
||||
{{- $traefikNamespace := "tc-system" -}}
|
||||
{{- if $.Values.operator.traefik -}}
|
||||
{{- if $.Values.operator.traefik.namespace -}}
|
||||
{{- $traefikNamespace := $.Values.operator.traefik.namespace -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $selectedIngress.ingressClassName }}
|
||||
{{- if $.Values.global.ixChartContext -}}
|
||||
{{- $traefikNamespace = (printf "ix-%s" $selectedIngress.ingressClassName) -}}
|
||||
{{- else -}}
|
||||
{{- $traefikNamespace = $selectedIngress.ingressClassName -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $traefikportalhook := lookup "v1" "ConfigMap" $traefikNamespace "portalhook" }}
|
||||
|
||||
{{- $entrypoint := "websecure" }}
|
||||
{{- $protocol = "https" -}}
|
||||
{{- if $selectedIngress.entrypoint }}
|
||||
{{- $entrypoint = $selectedIngress.entrypoint }}
|
||||
{{- end }}
|
||||
|
||||
{{- if $traefikportalhook }}
|
||||
{{- if ( index $traefikportalhook.data $entrypoint ) }}
|
||||
{{- $port = ( index $traefikportalhook.data $entrypoint ) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- $port = ( toString $port ) -}}
|
||||
|
||||
{{/* Apply overrides */}}
|
||||
{{- if $override.protocol -}}
|
||||
{{- $protocol = $override.protocol -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $override.host -}}
|
||||
{{- $host = $override.host -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $override.port -}}
|
||||
{{- $port = $override.port -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* sanitise */}}
|
||||
{{- if eq $port "443" -}}
|
||||
{{- $protocol = "https" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq $port "80" -}}
|
||||
{{- $protocol = "http" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* TODO: Reenable when iX fixes bugs crashing GUI on empty port */}}
|
||||
{{/*
|
||||
{{- if or ( and ( eq $protocol "https" ) ( eq $port "443" ) ) ( and ( eq $protocol "http" ) ( eq $port "80" ) ) -}}
|
||||
{{- $port = "" -}}
|
||||
{{- end -}}
|
||||
*/}}
|
||||
|
||||
{{- $port = toString $port -}}
|
||||
|
||||
{{/* Construct URL*/}}
|
||||
{{- if $port -}}
|
||||
{{- $url = printf "%s://%s:%s%s" $protocol $host $port $path -}}
|
||||
{{- else -}}
|
||||
{{- $url = printf "%s://%s%s" $protocol $host $path -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* create configmap entry*/}}
|
||||
{{- $portalData := dict "protocol" $protocol "host" $host "port" $port "path" $path "url" $url -}}
|
||||
|
||||
{{/* construct configmap */}}
|
||||
{{- $objectName := ( printf "tcportal-%s" $name ) -}}
|
||||
{{- $configMap := dict "enabled" true "name" $objectName "shortName" $objectName "data" $portalData -}}
|
||||
|
||||
{{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.configmap.validation" (dict "objectData" $configMap) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $configMap "caller" "ConfigMap") -}}
|
||||
|
||||
{{- if $.Values.global.ixChartContext -}}
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.configmap" (dict "rootCtx" $ "objectData" $configMap) -}}
|
||||
|
||||
{{/* iXportals */}}
|
||||
{{- $useNodeIP := false -}}
|
||||
{{- if eq $host "$node_ip" -}}
|
||||
{{- $useNodeIP = true -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $iXPortalData := dict "portalName" $name "useNodeIP" $useNodeIP "protocol" $protocol "host" $host "port" $port "path" $path "url" $url -}}
|
||||
{{- $iXPortals := append $.Values.iXPortals $iXPortalData -}}
|
||||
{{- $_ := set $.Values "iXPortals" $iXPortals -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
41
helm-charts/dashy/charts/common/templates/spawner/_pvc.tpl
Normal file
41
helm-charts/dashy/charts/common/templates/spawner/_pvc.tpl
Normal file
@@ -0,0 +1,41 @@
|
||||
{{/* PVC Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.pvc" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.pvc" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $persistence := .Values.persistence -}}
|
||||
|
||||
{{- if $persistence.enabled -}}
|
||||
|
||||
{{/* Create a copy of the persistence */}}
|
||||
{{- $objectData := (mustDeepCopy $persistence) -}}
|
||||
|
||||
{{- $_ := set $objectData "type" ($objectData.type | default $.Values.fallbackDefaults.persistenceType) -}}
|
||||
|
||||
{{/* Perform general validations */}}
|
||||
{{- include "tc.v1.common.lib.persistence.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Persistence") -}}
|
||||
|
||||
{{/* Only spawn PVC if its enabled and type of "pvc" */}}
|
||||
{{- if and (eq "pvc" $objectData.type) (not $objectData.existingClaim) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
|
||||
{{/* Set the name of the secret */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.pvc" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
44
helm-charts/dashy/charts/common/templates/spawner/_rbac.tpl
Normal file
44
helm-charts/dashy/charts/common/templates/spawner/_rbac.tpl
Normal file
@@ -0,0 +1,44 @@
|
||||
{{/* RBAC Spawner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.rbac" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.rbac" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Primary validation for enabled rbacs. */}}
|
||||
{{- include "tc.v1.common.lib.rbac.primaryValidation" $ -}}
|
||||
|
||||
{{- range $name, $rbac := .Values.rbac -}}
|
||||
|
||||
{{- if $rbac.enabled -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $rbac) -}}
|
||||
|
||||
{{- $objectName := $fullname -}}
|
||||
{{- if not $objectData.primary -}}
|
||||
{{- $objectName = (printf "%s-%s" $fullname $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "RBAC") -}}
|
||||
|
||||
{{/* Set the name of the rbac */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* If clusteWide key does not exist, assume false */}}
|
||||
{{- if not (hasKey $objectData "clusterWide") -}}
|
||||
{{- $_ := set $objectData "clusterWide" false -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.rbac" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
18
helm-charts/dashy/charts/common/templates/spawner/_route.tpl
Normal file
18
helm-charts/dashy/charts/common/templates/spawner/_route.tpl
Normal file
@@ -0,0 +1,18 @@
|
||||
{{/* Renders the Route objects required by the chart */}}
|
||||
{{- define "tc.v1.common.spawner.routes" -}}
|
||||
{{- /* Generate named routes as required */ -}}
|
||||
{{- range $name, $route := .Values.route }}
|
||||
{{- if $route.enabled -}}
|
||||
{{- $routeValues := $route -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if and (not $routeValues.nameOverride) (ne $name (include "tc.v1.common.lib.util.route.primary" $)) -}}
|
||||
{{- $_ := set $routeValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "route" $routeValues) -}}
|
||||
{{- include "tc.v1.common.class.route" $ | nindent 0 -}}
|
||||
{{- $_ := unset $.ObjectValues "route" -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,40 @@
|
||||
{{/* Certificate Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.scaleCertificate" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.scaleCertificate" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $certificate := .Values.scaleCertificate -}}
|
||||
|
||||
{{- if $certificate.enabled -}}
|
||||
|
||||
{{/* Create a copy of the certificate */}}
|
||||
{{- $objectData := (mustDeepCopy $certificate) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.scaleCertificate.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Certificate") -}}
|
||||
|
||||
{{/* Prepare data */}}
|
||||
{{- $data := fromJson (include "tc.v1.common.lib.scaleCertificate.getData" (dict "rootCtx" $ "objectData" $objectData)) -}}
|
||||
{{- $_ := set $objectData "data" $data -}}
|
||||
|
||||
{{/* Set the type to certificate */}}
|
||||
{{- $_ := set $objectData "type" "certificate" -}}
|
||||
|
||||
{{/* Set the name of the certificate */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,59 @@
|
||||
{{/* Secret Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.secret" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.secret" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $secret := .Values.secret -}}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $secret "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $secret.enabled) -}}
|
||||
{{- $enabled = $secret.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Secret - Expected the defined key [enabled] in <secret.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
{{/* After tpl it becomes a string, not a bool */}}
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- $enabled = true -}}
|
||||
{{- else if eq $enabled "false" -}}
|
||||
{{- $enabled = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $enabled -}}
|
||||
|
||||
{{/* Create a copy of the secret */}}
|
||||
{{- $objectData := (mustDeepCopy $secret) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.secret.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Secret") -}}
|
||||
|
||||
{{/* Set the name of the secret */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,58 @@
|
||||
{{/* Service Spawner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.service" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.service" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Primary validation for enabled service. */}}
|
||||
{{- include "tc.v1.common.lib.service.primaryValidation" $ -}}
|
||||
|
||||
{{- range $name, $service := .Values.service -}}
|
||||
|
||||
{{- if $service.enabled -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $service) -}}
|
||||
|
||||
{{/* Init object name */}}
|
||||
{{- $objectName := $name -}}
|
||||
|
||||
{{/* Default expandName to true */}}
|
||||
{{- $expandName := true -}}
|
||||
{{- if (hasKey $objectData "expandObjectName") -}}
|
||||
{{- if not (kindIs "invalid" $objectData.expandObjectName) -}}
|
||||
{{- $expandName = $objectData.expandName -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Service - Expected the defined key [expandObjectName] in <secret.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $expandName -}}
|
||||
{{/* Expand the name of the service if expandName resolves to true */}}
|
||||
{{- $objectName = $fullname -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $expandName (not $objectData.primary) -}}
|
||||
{{/* If the service is not primary append its name to fullname */}}
|
||||
{{- $objectName = (printf "%s-%s" $fullname $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service") -}}
|
||||
{{- include "tc.v1.common.lib.service.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{/* Set the name of the service account */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.service" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,39 @@
|
||||
{{/* Service Account Spawner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.serviceAccount" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.serviceAccount" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Primary validation for enabled service accounts. */}}
|
||||
{{- include "tc.v1.common.lib.serviceAccount.primaryValidation" $ -}}
|
||||
|
||||
{{- range $name, $serviceAccount := .Values.serviceAccount -}}
|
||||
|
||||
{{- if $serviceAccount.enabled -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $serviceAccount) -}}
|
||||
|
||||
{{- $objectName := $fullname -}}
|
||||
{{- if not $objectData.primary -}}
|
||||
{{- $objectName = (printf "%s-%s" $fullname $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service Account") -}}
|
||||
|
||||
{{/* Set the name of the service account */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.serviceAccount" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,65 @@
|
||||
{{/* MutatingWebhookConfiguration Spawwner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.webhook" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.webhook" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $name, $mutatingWebhookConfiguration := .Values.webhook -}}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $mutatingWebhookConfiguration "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $mutatingWebhookConfiguration.enabled) -}}
|
||||
{{- $enabled = $mutatingWebhookConfiguration.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Webhook - Expected the defined key [enabled] in <webhook.%s> to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
{{/* After tpl it becomes a string, not a bool */}}
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- $enabled = true -}}
|
||||
{{- else if eq $enabled "false" -}}
|
||||
{{- $enabled = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $enabled -}}
|
||||
|
||||
{{/* Create a copy of the mutatingWebhookConfiguration */}}
|
||||
{{- $objectData := (mustDeepCopy $mutatingWebhookConfiguration) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Webhook") -}}
|
||||
|
||||
{{/* Set the name of the MutatingWebhookConfiguration */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.webhook.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{- $type := tpl $objectData.type $ -}}
|
||||
{{/* Call class to create the object */}}
|
||||
{{- if eq $type "validating" -}}
|
||||
{{- include "tc.v1.common.class.validatingWebhookconfiguration" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- else if eq $type "mutating" -}}
|
||||
{{- include "tc.v1.common.class.mutatingWebhookConfiguration" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,57 @@
|
||||
{{/* Workload Spawner */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.spawner.workload" $ -}}
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.spawner.workload" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{/* Primary validation for enabled workload. */}}
|
||||
{{- include "tc.v1.common.lib.workload.primaryValidation" $ -}}
|
||||
|
||||
{{- range $name, $workload := .Values.workload -}}
|
||||
|
||||
{{- if $workload.enabled -}}
|
||||
|
||||
{{/* Create a copy of the workload */}}
|
||||
{{- $objectData := (mustDeepCopy $workload) -}}
|
||||
|
||||
{{/* Generate the name of the workload */}}
|
||||
{{- $objectName := $fullname -}}
|
||||
{{- if not $objectData.primary -}}
|
||||
{{- $objectName = printf "%s-%s" $fullname $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Workload") -}}
|
||||
|
||||
{{/* Set the name of the workload */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
|
||||
{{/* Short name is the one that defined on the chart, used on selectors */}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Set the podSpec so it doesn't fail on nil pointer */}}
|
||||
{{- if not (hasKey $objectData "podSpec") -}}
|
||||
{{- fail "Workload - Expected <podSpec> key to exist" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- if eq $objectData.type "Deployment" -}}
|
||||
{{- include "tc.v1.common.class.deployment" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- else if eq $objectData.type "StatefulSet" -}}
|
||||
{{- include "tc.v1.common.class.statefulset" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- else if eq $objectData.type "DaemonSet" -}}
|
||||
{{- include "tc.v1.common.class.daemonset" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- else if eq $objectData.type "Job" -}}
|
||||
{{- include "tc.v1.common.class.job" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- else if eq $objectData.type "CronJob" -}}
|
||||
{{- include "tc.v1.common.class.cronjob" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user