aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/common/common/templates
diff options
context:
space:
mode:
Diffstat (limited to 'kubernetes/common/common/templates')
-rw-r--r--kubernetes/common/common/templates/_createPassword.tpl3
-rw-r--r--kubernetes/common/common/templates/_ingress.tpl2
-rw-r--r--kubernetes/common/common/templates/_mariadb.tpl45
-rw-r--r--kubernetes/common/common/templates/_name.tpl14
-rw-r--r--kubernetes/common/common/templates/_secret.yaml22
5 files changed, 68 insertions, 18 deletions
diff --git a/kubernetes/common/common/templates/_createPassword.tpl b/kubernetes/common/common/templates/_createPassword.tpl
index 938b0ee514..8b2f1e274d 100644
--- a/kubernetes/common/common/templates/_createPassword.tpl
+++ b/kubernetes/common/common/templates/_createPassword.tpl
@@ -29,6 +29,9 @@
{{- printf "%d" .Values.global.masterPassword -}}
{{ else if .Values.masterPassword }}
{{- printf "%d" .Values.masterPassword -}}
+ {{ else if eq "testRelease" (include "common.release" .) }}
+ {{/* Special case for chart liniting. DON"T NAME YOUR PRODUCTION RELEASE testRelease */}}
+ {{- printf "testRelease" -}}
{{ else }}
{{ fail "masterPassword not provided" }}
{{ end }}
diff --git a/kubernetes/common/common/templates/_ingress.tpl b/kubernetes/common/common/templates/_ingress.tpl
index 935e318fc8..c3c744358c 100644
--- a/kubernetes/common/common/templates/_ingress.tpl
+++ b/kubernetes/common/common/templates/_ingress.tpl
@@ -87,7 +87,7 @@ metadata:
labels:
app: {{ .Chart.Name }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
- release: {{ .Release.Name }}
+ release: {{ include "common.release" . }}
heritage: {{ .Release.Service }}
spec:
rules:
diff --git a/kubernetes/common/common/templates/_mariadb.tpl b/kubernetes/common/common/templates/_mariadb.tpl
index 15fb5a4225..df0e6b41c9 100644
--- a/kubernetes/common/common/templates/_mariadb.tpl
+++ b/kubernetes/common/common/templates/_mariadb.tpl
@@ -15,6 +15,43 @@
*/}}
{{/*
+ UID of mariadb root password
+*/}}
+{{- define "common.mariadb.secret.rootPassUID" -}}
+ {{- printf "db-root-password" }}
+{{- end -}}
+
+{{/*
+ Name of mariadb secret
+*/}}
+{{- define "common.mariadb.secret._secretName" -}}
+ {{- $global := .dot }}
+ {{- $chartName := tpl .chartName $global -}}
+ {{- include "common.secret.genName" (dict "global" $global "uid" (include .uidTemplate $global) "chartName" $chartName) }}
+{{- end -}}
+
+{{/*
+ Name of mariadb root password secret
+*/}}
+{{- define "common.mariadb.secret.rootPassSecretName" -}}
+ {{- include "common.mariadb.secret._secretName" (set . "uidTemplate" "common.mariadb.secret.rootPassUID") }}
+{{- end -}}
+
+{{/*
+ UID of mariadb user credentials
+*/}}
+{{- define "common.mariadb.secret.userCredentialsUID" -}}
+ {{- printf "db-user-credentials" }}
+{{- end -}}
+
+{{/*
+ Name of mariadb user credentials secret
+*/}}
+{{- define "common.mariadb.secret.userCredentialsSecretName" -}}
+ {{- include "common.mariadb.secret._secretName" (set . "uidTemplate" "common.mariadb.secret.userCredentialsUID") }}
+{{- end -}}
+
+{{/*
Choose the name of the mariadb service to use.
*/}}
{{- define "common.mariadbService" -}}
@@ -43,7 +80,7 @@
{{- if .Values.global.mariadbGalera.localCluster -}}
{{ printf "%s-%s-db-user-credentials" (include "common.fullname" .) (index .Values "mariadb-galera" "nameOverride") -}}
{{- else -}}
- {{ printf "%s-%s" (.Release.Name) (index .Values "mariadb-init" "nameOverride") -}}
+ {{ printf "%s-%s-%s" ( include "common.release" .) (index .Values "mariadb-init" "nameOverride") (index .Values "mariadb-init" "config" "mysqlDatabase" ) -}}
{{- end -}}
{{- end -}}
@@ -51,9 +88,5 @@
Choose the value of secret param to retrieve user value.
*/}}
{{- define "common.mariadbSecretParam" -}}
- {{- if .Values.global.mariadbGalera.localCluster -}}
- {{ printf "password" -}}
- {{- else -}}
- {{ printf "db-user-password" -}}
- {{- end -}}
+ {{ printf "password" -}}
{{- end -}}
diff --git a/kubernetes/common/common/templates/_name.tpl b/kubernetes/common/common/templates/_name.tpl
index f84ca21f3a..7719cdbb9f 100644
--- a/kubernetes/common/common/templates/_name.tpl
+++ b/kubernetes/common/common/templates/_name.tpl
@@ -22,12 +22,22 @@
{{- end -}}
{{/*
+ The same as common.full name but based on passed dictionary instead of trying to figure
+ out chart name on its own.
+*/}}
+{{- define "common.fullnameExplicit" -}}
+ {{- $dot := .dot }}
+ {{- $name := .chartName }}
+ {{- printf "%s-%s" (include "common.release" $dot) $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
Create a default fully qualified application name.
Truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "common.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
- {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+ {{- include "common.fullnameExplicit" (dict "dot" . "chartName" $name) }}
{{- end -}}
{{/*
@@ -37,5 +47,5 @@
this function would answer back "toto".
*/}}
{{- define "common.release" -}}
- {{- regexReplaceAll "-[a-zA-Z0-9]*$" .Release.Name "" }}
+ {{- first (regexSplit "-" .Release.Name -1) }}
{{- end -}}
diff --git a/kubernetes/common/common/templates/_secret.yaml b/kubernetes/common/common/templates/_secret.yaml
index 523d7880f0..e24a2e4ba7 100644
--- a/kubernetes/common/common/templates/_secret.yaml
+++ b/kubernetes/common/common/templates/_secret.yaml
@@ -37,7 +37,7 @@ metadata:
labels:
app: {{ include "common.name" $global }}
chart: {{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}
- release: {{ $global.Release.Name }}
+ release: {{ include "common.release" $global }}
heritage: {{ $global.Release.Service }}
type: Opaque
{{- end -}}
@@ -76,8 +76,6 @@ type: Opaque
{{/*
- For internal use only!
-
Generate a secret name based on provided name or UID.
If UID is provided then the name is generated by appending this UID right after
the chart name. If name is provided, it overrides the name generation algorith
@@ -90,11 +88,12 @@ type: Opaque
- .name: string that can be used to override default name generation algorithm
and provide a custom name for the secret
*/}}
-{{- define "common.secret._genName" -}}
+{{- define "common.secret.genName" -}}
{{- $global := .global }}
{{- $uid := tpl (default "" .uid) $global }}
{{- $name := tpl (default "" .name) $global }}
- {{- default (printf "%s-%s" (include "common.fullname" $global) $uid) $name }}
+ {{- $fullname := ne (default "" .chartName) "" | ternary (include "common.fullnameExplicit" (dict "dot" $global "chartName" .chartName)) (include "common.fullname" $global) }}
+ {{- default (printf "%s-%s" $fullname $uid) $name }}
{{- end -}}
{{/*
@@ -115,10 +114,14 @@ type: Opaque
*/}}
{{- define "common.secret.getSecretName" -}}
{{- $global := .global }}
- {{- $targetName := include "common.secret._genName" (dict "global" $global "uid" .uid "name" .name) }}
+ {{- $name := tpl (default "" .name) $global }}
+ {{- $uid := tpl (default "" .uid) $global }}
+ {{- $targetName := default (include "common.secret.genName" (dict "global" $global "uid" $uid "name" .name)) $name}}
{{- range $secret := $global.Values.secrets }}
- {{- $currName := include "common.secret._genName" (dict "global" $global "uid" $secret.uid "name" $secret.name) }}
- {{- if eq $currName $targetName }}
+ {{- $givenName := tpl (default "" $secret.name) $global }}
+ {{- $currUID := tpl (default "" $secret.uid) $global }}
+ {{- $currName := default (include "common.secret.genName" (dict "global" $global "uid" $currUID "name" $secret.name)) $givenName }}
+ {{- if or (eq $uid $currUID) (eq $currName $targetName) }}
{{- $externalSecret := tpl (default "" $secret.externalSecret) $global }}
{{- default $currName $externalSecret }}
{{- end }}
@@ -234,7 +237,8 @@ valueFrom:
{{- define "common.secret" -}}
{{- $global := . }}
{{- range $secret := .Values.secrets }}
- {{- $name := include "common.secret._genName" (dict "global" $global "uid" $secret.uid "name" $secret.name) }}
+ {{- $uid := tpl (default "" $secret.uid) $global }}
+ {{- $name := include "common.secret.genName" (dict "global" $global "uid" $uid "name" $secret.name) }}
{{- $type := default "generic" $secret.type }}
{{- $externalSecret := tpl (default "" $secret.externalSecret) $global }}
{{- if not $externalSecret }}