diff --git a/.tools/fixfolders.sh b/.tools/fixfolders.sh index e5f2ae89eda..b47476469ab 100755 --- a/.tools/fixfolders.sh +++ b/.tools/fixfolders.sh @@ -4,7 +4,7 @@ for chart in charts/*; do maxchartversion=$(cat ${chart}/${maxfolderversion}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }') chartname=$(basename ${chart}) echo "Processing: ${chart} - folder: ${maxfolderversion} - version: ${maxchartversion}" - helm dependency update ${chart}/${maxfolderversion} + helm dependency update --skip-refresh ${chart}/${maxfolderversion} if [ "${maxfolderversion}" != "${maxchartversion}" ]; then mv -f ${chart}/${maxfolderversion} ${chart}/${maxchartversion} echo "renamed ${chart}/${maxfolderversion} to ${chart}/${maxchartversion}" diff --git a/update_dependencies b/.tools/update_dependencies similarity index 100% rename from update_dependencies rename to .tools/update_dependencies diff --git a/features_capability.json b/features_capability.json index d5fc5074f06..6cb3eace1f2 100644 --- a/features_capability.json +++ b/features_capability.json @@ -22,5 +22,13 @@ "definitions/nodeIP": { "stable": {"min": "20.12-ALPHA"}, "nightlies": {"min": "20.12-MASTER"} + }, + "definitions/certificate": { + "stable": {"min": "21.02-ALPHA"}, + "nightlies": {"min": "21.02-MASTER"} + }, + "definitions/certificateAuthority": { + "stable": {"min": "21.02-ALPHA"}, + "nightlies": {"min": "21.02-MASTER"} } } diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 27606cb1568..e63273841cf 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 kubeVersion: ">=1.16.0-0" name: common -version: 1.3.2 -# upstream_version: +version: 1.4.0 +# upstream_version: 3.0.1 # appVersion: description: Function library for TrueCharts type: library diff --git a/library/common/templates/_all.tpl b/library/common/templates/_all.tpl index d896c3b8c14..7b66ceb7e41 100644 --- a/library/common/templates/_all.tpl +++ b/library/common/templates/_all.tpl @@ -31,10 +31,11 @@ Main entrypoint for the common library chart. It will render all underlying temp {{- end -}} {{- print "---" | nindent 0 -}} {{ include "common.service" . | nindent 0 }} - {{ include "common.custom.appService" . | nindent 0 }} + {{ include "common.appService" . | nindent 0 }} {{- print "---" | nindent 0 -}} {{ include "common.ingress" . | nindent 0 }} {{- print "---" | nindent 0 -}} - {{ include "common.custom.appIngress" . | nindent 0 }} - {{ include "common.custom.mountpermissions" . | nindent 0 }} + {{ include "common.appIngress" . | nindent 0 }} + {{ include "common.storage.permissions" . | nindent 0 }} + {{ include "common.resources.cert.secret" . | nindent 0 }} {{- end -}} diff --git a/library/common/templates/bitnami/_capabilities.tpl b/library/common/templates/bitnami/_capabilities.tpl deleted file mode 100644 index 90d459bbec4..00000000000 --- a/library/common/templates/bitnami/_capabilities.tpl +++ /dev/null @@ -1,73 +0,0 @@ -{{/* vim: set filetype=mustache: */}} - -{{/* -Return the target Kubernetes version -*/}} -{{- define "common.capabilities.kubeVersion" -}} -{{- if .Values.global }} - {{- if .Values.global.kubeVersion }} - {{- .Values.global.kubeVersion -}} - {{- else }} - {{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} - {{- end -}} -{{- else }} -{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} -{{- end -}} -{{- end -}} - -{{/* -Return the appropriate apiVersion for deployment. -*/}} -{{- define "common.capabilities.deployment.apiVersion" -}} -{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "extensions/v1beta1" -}} -{{- else -}} -{{- print "apps/v1" -}} -{{- end -}} -{{- end -}} - -{{/* -Return the appropriate apiVersion for statefulset. -*/}} -{{- define "common.capabilities.statefulset.apiVersion" -}} -{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "apps/v1beta1" -}} -{{- else -}} -{{- print "apps/v1" -}} -{{- end -}} -{{- end -}} - -{{/* -Return the appropriate apiVersion for ingress. -*/}} -{{- define "common.capabilities.ingress.apiVersion" -}} -{{- if .Values.ingress -}} -{{- if .Values.ingress.apiVersion -}} -{{- .Values.ingress.apiVersion -}} -{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "extensions/v1beta1" -}} -{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "networking.k8s.io/v1beta1" -}} -{{- else -}} -{{- print "networking.k8s.io/v1" -}} -{{- end }} -{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "extensions/v1beta1" -}} -{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "networking.k8s.io/v1beta1" -}} -{{- else -}} -{{- print "networking.k8s.io/v1" -}} -{{- end -}} -{{- end -}} - -{{/* -Returns true if the used Helm version is 3.3+. -A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure. -This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error. -**To be removed when the catalog's minimun Helm version is 3.3** -*/}} -{{- define "common.capabilities.supportsHelmVersion" -}} -{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }} - {{- true -}} -{{- end -}} -{{- end -}} diff --git a/library/common/templates/bitnami/_labels.tpl b/library/common/templates/bitnami/_labels.tpl deleted file mode 100644 index 252066c7e2b..00000000000 --- a/library/common/templates/bitnami/_labels.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Kubernetes standard labels -*/}} -{{- define "common.labels.standard" -}} -app.kubernetes.io/name: {{ include "common.names.name" . }} -helm.sh/chart: {{ include "common.names.chart" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector -*/}} -{{- define "common.labels.matchLabels" -}} -app.kubernetes.io/name: {{ include "common.names.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} diff --git a/library/common/templates/bitnami/_names.tpl b/library/common/templates/bitnami/_names.tpl deleted file mode 100644 index adf2a74f484..00000000000 --- a/library/common/templates/bitnami/_names.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "common.names.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "common.names.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "common.names.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} diff --git a/library/common/templates/classes/_pvc.tpl b/library/common/templates/classes/_pvc.tpl index 30840c9ad9c..5477935e1d5 100644 --- a/library/common/templates/classes/_pvc.tpl +++ b/library/common/templates/classes/_pvc.tpl @@ -35,6 +35,6 @@ spec: requests: storage: {{ required (printf "size is required for PVC %v" $pvcName) $values.size | quote }} {{- if $values.storageClass }} - storageClassName: {{ if (eq "-" $values.storageClass) }}""{{- else }}{{ $values.storageClass | quote }}{{- end }} + storageClassName: {{ include "common.storage.class" . }} {{- end }} {{- end -}} diff --git a/library/common/templates/custom/classes/_appAuthForward.tpl b/library/common/templates/classes/ingress/_appAuthForward.tpl similarity index 93% rename from library/common/templates/custom/classes/_appAuthForward.tpl rename to library/common/templates/classes/ingress/_appAuthForward.tpl index d7768c5d193..9353f7736c3 100644 --- a/library/common/templates/custom/classes/_appAuthForward.tpl +++ b/library/common/templates/classes/ingress/_appAuthForward.tpl @@ -1,7 +1,7 @@ {{/* Renders the additioanl authForward objects from appAuthForward */}} -{{- define "common.custom.classes.appAuthForward" -}} +{{- define "common.classes.appAuthForward" -}} {{- /* Generate TrueNAS SCALE app services as required v1 */ -}} {{- $values := .Values.appIngress -}} {{- if hasKey . "ObjectValues" -}} diff --git a/library/common/templates/custom/classes/_appIngressHTTP.tpl b/library/common/templates/classes/ingress/_appIngressHTTP.tpl similarity index 94% rename from library/common/templates/custom/classes/_appIngressHTTP.tpl rename to library/common/templates/classes/ingress/_appIngressHTTP.tpl index b7a21ff2810..51a6a51244c 100644 --- a/library/common/templates/custom/classes/_appIngressHTTP.tpl +++ b/library/common/templates/classes/ingress/_appIngressHTTP.tpl @@ -2,7 +2,7 @@ This template serves as a blueprint for all appIngress objects that are created within the common library. */}} -{{- define "common.custom.classes.appIngressHTTP" -}} +{{- define "common.classes.appIngressHTTP" -}} {{- $values := .Values.appIngress -}} {{- if hasKey . "ObjectValues" -}} {{- with .ObjectValues.appIngress -}} @@ -47,8 +47,11 @@ spec: - {{ .host | quote }} {{- end }} {{- if eq $values.certType "selfsigned" -}} + secretName: {{ else if eq $values.certType "existingcert" }} secretName: {{ $values.existingcert }} + {{ else if eq $values.certType "ixcert" }} + secretName: {{ include "common.names.fullname" . }}-ix-cert {{ else if eq $values.certType "wildcard" }} secretName: wildcardcert {{ else }} diff --git a/library/common/templates/custom/classes/_appIngressTCP.tpl b/library/common/templates/classes/ingress/_appIngressTCP.tpl similarity index 91% rename from library/common/templates/custom/classes/_appIngressTCP.tpl rename to library/common/templates/classes/ingress/_appIngressTCP.tpl index babeac598bb..f301ee782d6 100644 --- a/library/common/templates/custom/classes/_appIngressTCP.tpl +++ b/library/common/templates/classes/ingress/_appIngressTCP.tpl @@ -2,7 +2,7 @@ This template serves as a blueprint for all appIngressTCP objects that are created within the common library. */}} -{{- define "common.custom.classes.appIngressTCP" -}} +{{- define "common.classes.appIngressTCP" -}} {{- $values := .Values.appIngress -}} {{- if hasKey . "ObjectValues" -}} {{- with .ObjectValues.appIngress -}} @@ -48,8 +48,11 @@ spec: - {{ .host | quote }} {{- end }} {{- if eq $values.certType "selfsigned" -}} + secretName: {{ else if eq $values.certType "existingcert" }} secretName: {{ $values.existingcert }} + {{ else if eq $values.certType "ixcert" }} + secretName: {{ include "common.names.fullname" . }}-ix-cert {{ else if eq $values.certType "wildcard" }} secretName: wildcardcert {{ else }} diff --git a/library/common/templates/custom/classes/_appIngressUDP.tpl b/library/common/templates/classes/ingress/_appIngressUDP.tpl similarity index 95% rename from library/common/templates/custom/classes/_appIngressUDP.tpl rename to library/common/templates/classes/ingress/_appIngressUDP.tpl index 6906d9609c3..b8e73747b4f 100644 --- a/library/common/templates/custom/classes/_appIngressUDP.tpl +++ b/library/common/templates/classes/ingress/_appIngressUDP.tpl @@ -2,7 +2,7 @@ This template serves as a blueprint for all appIngressTCP objects that are created within the common library. */}} -{{- define "common.custom.classes.appIngressUDP" -}} +{{- define "common.classes.appIngressUDP" -}} {{- $values := .Values.appIngress -}} {{- if hasKey . "ObjectValues" -}} {{- with .ObjectValues.appIngress -}} diff --git a/library/common/templates/classes/_ingress.tpl b/library/common/templates/classes/ingress/_ingress.tpl similarity index 100% rename from library/common/templates/classes/_ingress.tpl rename to library/common/templates/classes/ingress/_ingress.tpl diff --git a/library/common/templates/bitnami/_affinities.tpl b/library/common/templates/lib/bitnamiCompat/_affinities.tpl similarity index 97% rename from library/common/templates/bitnami/_affinities.tpl rename to library/common/templates/lib/bitnamiCompat/_affinities.tpl index fa4bac62042..56c16c82f0b 100644 --- a/library/common/templates/bitnami/_affinities.tpl +++ b/library/common/templates/lib/bitnamiCompat/_affinities.tpl @@ -1,3 +1,5 @@ +## Currently only used as Bitnami Compatibility layer, may want to integrate more later + {{/* vim: set filetype=mustache: */}} {{/* diff --git a/library/common/templates/bitnami/_ingress.tpl b/library/common/templates/lib/bitnamiCompat/_ingressBackend.tpl similarity index 92% rename from library/common/templates/bitnami/_ingress.tpl rename to library/common/templates/lib/bitnamiCompat/_ingressBackend.tpl index 622ef50e3cd..ae31280a855 100644 --- a/library/common/templates/bitnami/_ingress.tpl +++ b/library/common/templates/lib/bitnamiCompat/_ingressBackend.tpl @@ -1,3 +1,6 @@ +## Currently only used as Bitnami compatibility Layer, needs more integration during the Ingress integration project. + + {{/* vim: set filetype=mustache: */}} {{/* diff --git a/library/common/templates/bitnami/_secrets.tpl b/library/common/templates/lib/bitnamiCompat/_secrets.tpl similarity index 98% rename from library/common/templates/bitnami/_secrets.tpl rename to library/common/templates/lib/bitnamiCompat/_secrets.tpl index 2de53f0077d..9cd9b349976 100644 --- a/library/common/templates/bitnami/_secrets.tpl +++ b/library/common/templates/lib/bitnamiCompat/_secrets.tpl @@ -1,3 +1,4 @@ +## Currently only used as Bitnami Compatibility layer, may want to integrate more later {{/* vim: set filetype=mustache: */}} {{/* Generate secret name. diff --git a/library/common/templates/bitnami/_tplvalues.tpl b/library/common/templates/lib/bitnamiCompat/_tplvalues.tpl similarity index 81% rename from library/common/templates/bitnami/_tplvalues.tpl rename to library/common/templates/lib/bitnamiCompat/_tplvalues.tpl index 2db166851bb..c9960dedaea 100644 --- a/library/common/templates/bitnami/_tplvalues.tpl +++ b/library/common/templates/lib/bitnamiCompat/_tplvalues.tpl @@ -1,3 +1,5 @@ +## Currently only used as Bitnami Compatibility layer, may want to integrate more later + {{/* vim: set filetype=mustache: */}} {{/* Renders a value that contains template. diff --git a/library/common/templates/lib/chart/_capabilities.tpl b/library/common/templates/lib/chart/_capabilities.tpl index 1db5849f50c..71489eef9c3 100644 --- a/library/common/templates/lib/chart/_capabilities.tpl +++ b/library/common/templates/lib/chart/_capabilities.tpl @@ -69,7 +69,9 @@ Return the appropriate apiVersion for Ingress objects. */}} {{- define "common.capabilities.ingress.apiVersion" -}} -{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if .Values.ingress.apiVersion -}} +{{- .Values.ingress.apiVersion -}} +{{- else if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} {{- print "extensions/v1beta1" -}} {{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}} {{- print "networking.k8s.io/v1beta1" -}} @@ -90,3 +92,37 @@ Waiting on https://github.com/helm/helm/pull/8608 {{- end }} {{- end -}} */}} + +{{/* +Return the appropriate apiVersion for RBAC resources. +*/}} +{{- define "common.capabilities.rbac.apiVersion" -}} +{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for CRDs. +*/}} +{{- define "common.capabilities.crd.apiVersion" -}} +{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} +{{- print "apiextensions.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "apiextensions.k8s.io/v1" -}} +{{- end -}} +{{- end -}} + +{{/* +Returns true if the used Helm version is 3.3+. +A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure. +This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error. +**To be removed when the catalog's minimun Helm version is 3.3** +*/}} +{{- define "common.capabilities.supportsHelmVersion" -}} +{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }} + {{- true -}} +{{- end -}} +{{- end -}} diff --git a/library/common/templates/bitnami/_errors.tpl b/library/common/templates/lib/chart/_errors.tpl similarity index 100% rename from library/common/templates/bitnami/_errors.tpl rename to library/common/templates/lib/chart/_errors.tpl diff --git a/library/common/templates/bitnami/_images.tpl b/library/common/templates/lib/chart/_images.tpl similarity index 93% rename from library/common/templates/bitnami/_images.tpl rename to library/common/templates/lib/chart/_images.tpl index aafde9f3bd1..60f04fd6e2f 100644 --- a/library/common/templates/bitnami/_images.tpl +++ b/library/common/templates/lib/chart/_images.tpl @@ -12,7 +12,11 @@ Return the proper image name {{- $registryName = .global.imageRegistry -}} {{- end -}} {{- end -}} +{{- if $registryName }} {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- else -}} +{{- printf "%s:%s" $repositoryName $tag -}} +{{- end -}} {{- end -}} {{/* diff --git a/library/common/templates/lib/chart/_labels.tpl b/library/common/templates/lib/chart/_labels.tpl index 10981d9b5a0..9e039adbb73 100644 --- a/library/common/templates/lib/chart/_labels.tpl +++ b/library/common/templates/lib/chart/_labels.tpl @@ -17,3 +17,21 @@ Selector labels shared across objects. app.kubernetes.io/name: {{ include "common.names.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} + + +## Bitnami Compatibility links + +{{/* vim: set filetype=mustache: */}} +{{/* +Kubernetes standard labels +*/}} +{{- define "common.labels.standard" -}} +{{ include "common.labels" . }} +{{- end -}} + +{{/* +Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector +*/}} +{{- define "common.labels.matchLabels" -}} +{{ include "common.labels.selectorLabels" . }} +{{- end -}} diff --git a/library/common/templates/lib/chart/_names.tpl b/library/common/templates/lib/chart/_names.tpl index 1dcd878a97d..f76111110ba 100644 --- a/library/common/templates/lib/chart/_names.tpl +++ b/library/common/templates/lib/chart/_names.tpl @@ -1,9 +1,10 @@ +{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "common.names.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} {{/* Create a default fully qualified app name. @@ -11,17 +12,18 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "common.names.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + {{/* Create chart name and version as used by the chart label. diff --git a/library/common/templates/bitnami/_utils.tpl b/library/common/templates/lib/chart/_utils.tpl similarity index 100% rename from library/common/templates/bitnami/_utils.tpl rename to library/common/templates/lib/chart/_utils.tpl diff --git a/library/common/templates/bitnami/_warnings.tpl b/library/common/templates/lib/chart/_warnings.tpl similarity index 78% rename from library/common/templates/bitnami/_warnings.tpl rename to library/common/templates/lib/chart/_warnings.tpl index ae10fa41ee7..aee4bbedd77 100644 --- a/library/common/templates/bitnami/_warnings.tpl +++ b/library/common/templates/lib/chart/_warnings.tpl @@ -1,3 +1,6 @@ +## We might want to include more repositories in this warnings +## This is mostly used to prevent chart maintainers using "latest" when version is available + {{/* vim: set filetype=mustache: */}} {{/* Warning about using rolling tag. diff --git a/library/common/templates/lib/controller/_container.tpl b/library/common/templates/lib/controller/_container.tpl index 003ffd68dbd..5cd6243ad41 100644 --- a/library/common/templates/lib/controller/_container.tpl +++ b/library/common/templates/lib/controller/_container.tpl @@ -3,7 +3,8 @@ The main container included in the controller. */ -}} {{- define "common.controller.mainContainer" -}} - name: {{ include "common.names.fullname" . }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}" + {{ include "common.warnings.rollingTag" .Values.image }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.command }} command: {{ . }} @@ -64,7 +65,7 @@ The main container included in the controller. {{- end }} {{- end }} {{- end }} - {{- include "common.custom.configuredAppVolumeMounts" . | indent 2 }} + {{- include "common.storage.configuredAppVolumeMounts" . | indent 2 }} {{- if .Values.additionalVolumeMounts }} {{- toYaml .Values.additionalVolumeMounts | nindent 2 }} {{- end }} diff --git a/library/common/templates/lib/controller/_volumes.tpl b/library/common/templates/lib/controller/_volumes.tpl index 991ef3a3a9d..cd10260ee45 100644 --- a/library/common/templates/lib/controller/_volumes.tpl +++ b/library/common/templates/lib/controller/_volumes.tpl @@ -25,7 +25,7 @@ Volumes included by the controller. {{- end }} {{- end }} {{- end }} -{{- include "common.custom.configuredAppVolumes" . }} +{{- include "common.storage.configuredAppVolumes" . }} {{- if .Values.additionalVolumes }} {{- toYaml .Values.additionalVolumes | nindent 0 }} {{- end }} diff --git a/library/common/templates/custom/_appService.tpl b/library/common/templates/lib/resources/_appService.tpl similarity index 94% rename from library/common/templates/custom/_appService.tpl rename to library/common/templates/lib/resources/_appService.tpl index 97a0994fad1..2ba32550c4c 100644 --- a/library/common/templates/custom/_appService.tpl +++ b/library/common/templates/lib/resources/_appService.tpl @@ -1,7 +1,7 @@ {{/* Renders the additioanl Service objects from appAdditionalServices */}} -{{- define "common.custom.appService" -}} +{{- define "common.appService" -}} {{- /* Generate TrueNAS SCALE app services as required v1 */ -}} {{- if and .Values.appAdditionalServicesEnabled .Values.appAdditionalServices -}} {{- range $name, $srv := .Values.appAdditionalServices }} diff --git a/library/common/templates/custom/_appingress.tpl b/library/common/templates/lib/resources/_appingress.tpl similarity index 68% rename from library/common/templates/custom/_appingress.tpl rename to library/common/templates/lib/resources/_appingress.tpl index 43a2983337b..7ad37560b08 100644 --- a/library/common/templates/custom/_appingress.tpl +++ b/library/common/templates/lib/resources/_appingress.tpl @@ -1,7 +1,7 @@ {{/* Renders the additional ingress objects from appIngress */}} -{{- define "common.custom.appIngress" -}} +{{- define "common.appIngress" -}} {{- /* Generate TrueNAS SCALE app services as required v1 */ -}} {{- if .Values.appIngress -}} {{- range $name, $ingr := .Values.appIngress }} @@ -14,19 +14,19 @@ Renders the additional ingress objects from appIngress {{- $_ := set $ "ObjectValues" (dict "appIngress" $ingressValues) -}} {{- if $ingressValues.type -}} {{- if eq $ingressValues.type "UDP" -}} - {{- include "common.custom.classes.appIngressUDP" $ }} + {{- include "common.classes.appIngressUDP" $ }} {{- else if eq $ingressValues.type "TCP" -}} - {{- include "common.custom.classes.appIngressTCP" $ }} + {{- include "common.classes.appIngressTCP" $ }} {{- else }} - {{- include "common.custom.classes.appIngressHTTP" $ }} + {{- include "common.classes.appIngressHTTP" $ }} {{- if $ingressValues.authForwardURL }} - {{- include "common.custom.classes.appAuthForward" $ }} + {{- include "common.classes.appAuthForward" $ }} {{- end }} {{- end }} {{- else }} - {{- include "common.custom.classes.appIngressHTTP" $ }} + {{- include "common.classes.appIngressHTTP" $ }} {{- if $ingressValues.authForwardURL }} - {{- include "common.custom.classes.appAuthForward" $ }} + {{- include "common.classes.appAuthForward" $ }} {{- end }} {{- end }} {{- end }} diff --git a/library/common/templates/lib/resources/_certHelpers.tpl b/library/common/templates/lib/resources/_certHelpers.tpl new file mode 100644 index 00000000000..b9ecaa6d536 --- /dev/null +++ b/library/common/templates/lib/resources/_certHelpers.tpl @@ -0,0 +1,32 @@ +{{/* +Retrieve true/false if certificate is configured +*/}} +{{- define "common.resources.cert.available" -}} +{{- if .Values.certificate -}} +{{- $values := (. | mustDeepCopy) -}} +{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}} +{{- template "common.resources.cert_present" $values -}} +{{- else -}} +{{- false -}} +{{- end -}} +{{- end -}} + + +{{/* +Retrieve public key of certificate +*/}} +{{- define "common.resources.cert.publicKey" -}} +{{- $values := (. | mustDeepCopy) -}} +{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate "publicKey" true) -}} +{{ include "common.resources.cert" $values }} +{{- end -}} + + +{{/* +Retrieve private key of certificate +*/}} +{{- define "common.resources.cert.privateKey" -}} +{{- $values := (. | mustDeepCopy) -}} +{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}} +{{ include "common.resources.cert" $values }} +{{- end -}} diff --git a/library/common/templates/lib/resources/_certSecret.yaml b/library/common/templates/lib/resources/_certSecret.yaml new file mode 100644 index 00000000000..3f09ac712c3 --- /dev/null +++ b/library/common/templates/lib/resources/_certSecret.yaml @@ -0,0 +1,14 @@ +{{- define "common.resources.cert.secret" -}} +{{ if eq (include "common.resources.cert.available" .) "true" }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.names.fullname" . }}-ix-cert + labels: {{ include "common.labels" . | nindent 4 }} +type: kubernetes.io/tls +data: + tls.crt: {{ (include "common.resources.cert.publicKey" .) | toString | b64enc | quote }} + tls.key: {{ (include "common.resources.cert.privateKey" .) | toString | b64enc | quote }} +{{ end }} +{{- end }} diff --git a/library/common/templates/lib/resources/_certs.tpl b/library/common/templates/lib/resources/_certs.tpl new file mode 100644 index 00000000000..91c525abd51 --- /dev/null +++ b/library/common/templates/lib/resources/_certs.tpl @@ -0,0 +1,24 @@ +{{/* +Retrieve true/false if certificate is available in ixCertificates +*/}} +{{- define "common.resources.cert_present" -}} +{{- $values := . -}} +{{- hasKey $values.Values.ixCertificates ($values.commonCertOptions.certKeyName | toString) -}} +{{- end -}} + + +{{/* +Retrieve certificate from variable name +*/}} +{{- define "common.resources.cert" -}} +{{- $values := . -}} +{{- $certKey := ($values.commonCertOptions.certKeyName | toString) -}} +{{- if hasKey $values.Values.ixCertificates $certKey -}} +{{- $cert := get $values.Values.ixCertificates $certKey -}} +{{- if $values.commonCertOptions.publicKey -}} +{{ $cert.certificate }} +{{- else -}} +{{ $cert.privatekey }} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/library/common/templates/custom/_appStorage.tpl b/library/common/templates/lib/storage/_appStorage.tpl similarity index 60% rename from library/common/templates/custom/_appStorage.tpl rename to library/common/templates/lib/storage/_appStorage.tpl index a0831d4aa20..75a08fb3a5f 100644 --- a/library/common/templates/custom/_appStorage.tpl +++ b/library/common/templates/lib/storage/_appStorage.tpl @@ -1,19 +1,7 @@ -{{/* -Retrieve host path from ix volumes based on dataset name -*/}} -{{- define "common.custom.retrieveHostPathFromiXVolume" -}} -{{- range $index, $hostPathConfiguration := $.ixVolumes }} -{{- $dsName := base $hostPathConfiguration.hostPath -}} -{{- if eq $.datasetName $dsName -}} -{{- $hostPathConfiguration.hostPath -}} -{{- end }} -{{- end }} -{{- end -}} - {{/* Define appVolumeMounts for container */}} -{{- define "common.custom.configuredAppVolumeMounts" -}} +{{- define "common.storage.configuredAppVolumeMounts" -}} {{- if .Values.appVolumeMounts }} {{- range $name, $avm := .Values.appVolumeMounts -}} {{- if $avm.enabled }} @@ -30,7 +18,7 @@ Define appVolumeMounts for container {{/* Define hostPath for appVolumes */}} -{{- define "common.custom.configuredAppVolumes" -}} +{{- define "common.storage.configuredAppVolumes" -}} {{- if .Values.appVolumeMounts }} {{- range $name, $av := .Values.appVolumeMounts -}} {{- if $av.enabled }} @@ -43,7 +31,7 @@ Define hostPath for appVolumes path: {{ required "hostPath not set" $av.hostPath }} {{- else }} {{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $.Values.ixVolumes -}} - path: {{ include "common.custom.retrieveHostPathFromiXVolume" $volDict }} + path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }} {{- end }} {{- end }} {{- end }} diff --git a/library/common/templates/lib/storage/_ixVolumes.tpl b/library/common/templates/lib/storage/_ixVolumes.tpl new file mode 100644 index 00000000000..b2dd66be3d5 --- /dev/null +++ b/library/common/templates/lib/storage/_ixVolumes.tpl @@ -0,0 +1,11 @@ +{{/* +Retrieve host path from ix volumes based on dataset name +*/}} +{{- define "common.storage.retrieveHostPathFromiXVolume" -}} +{{- range $index, $hostPathConfiguration := $.ixVolumes }} +{{- $dsName := base $hostPathConfiguration.hostPath -}} +{{- if eq $.datasetName $dsName -}} +{{- $hostPathConfiguration.hostPath -}} +{{- end }} +{{- end }} +{{- end -}} diff --git a/library/common/templates/custom/_mountPermissions.yaml b/library/common/templates/lib/storage/_mountPermissions.tpl similarity index 82% rename from library/common/templates/custom/_mountPermissions.yaml rename to library/common/templates/lib/storage/_mountPermissions.tpl index dd8fc12bc46..e65ba17d636 100644 --- a/library/common/templates/custom/_mountPermissions.yaml +++ b/library/common/templates/lib/storage/_mountPermissions.tpl @@ -2,7 +2,7 @@ This template serves as the blueprint for the mountPermissions job that is run before chart installation. */}} -{{- define "common.custom.mountpermissions" -}} +{{- define "common.storage.permissions" -}} {{- if and .Values.appVolumeMounts .Values.fixMountPermissions }} {{- range $name, $avm := .Values.appVolumeMounts -}} {{- if and $avm.enabled $avm.setPermissions}} @@ -14,7 +14,7 @@ before chart installation. {{ end -}} {{- $_ := set $ "ObjectValues" (dict "appVolumeMounts" $VMValues) -}} -{{ include "common.custom.mountpermissions.job" $ | nindent 0 }} +{{ include "common.storage.permissions.job" $ | nindent 0 }} {{- end }} {{- end }} {{- end }} diff --git a/library/common/templates/custom/_mountPermissionsJob.yaml b/library/common/templates/lib/storage/_mountPermissionsJob.tpl similarity index 92% rename from library/common/templates/custom/_mountPermissionsJob.yaml rename to library/common/templates/lib/storage/_mountPermissionsJob.tpl index 4ad388bf094..d31899bba7a 100644 --- a/library/common/templates/custom/_mountPermissionsJob.yaml +++ b/library/common/templates/lib/storage/_mountPermissionsJob.tpl @@ -2,7 +2,7 @@ This template serves as the blueprint for the mountPermissions job that is run before chart installation. */}} -{{- define "common.custom.mountpermissions.job" -}} +{{- define "common.storage.permissions.job" -}} {{- $values := .Values.appVolumeMounts -}} {{- if hasKey . "ObjectValues" -}} @@ -55,7 +55,7 @@ spec: #securityContext: # volumeMounts: - {{- include "common.custom.configuredAppVolumeMounts" . | indent 12 }} + {{- include "common.storage.configuredAppVolumeMounts" . | indent 12 }} {{- with (include "common.controller.volumes" . | trim) }} volumes: {{- . | nindent 8 }} diff --git a/library/common/templates/bitnami/_storage.tpl b/library/common/templates/lib/storage/_storageclass.tpl similarity index 100% rename from library/common/templates/bitnami/_storage.tpl rename to library/common/templates/lib/storage/_storageclass.tpl diff --git a/library/common/templates/bitnami/validations/_cassandra.tpl b/library/common/templates/lib/validations/_cassandra.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_cassandra.tpl rename to library/common/templates/lib/validations/_cassandra.tpl diff --git a/library/common/templates/bitnami/validations/_mariadb.tpl b/library/common/templates/lib/validations/_mariadb.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_mariadb.tpl rename to library/common/templates/lib/validations/_mariadb.tpl diff --git a/library/common/templates/bitnami/validations/_mongodb.tpl b/library/common/templates/lib/validations/_mongodb.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_mongodb.tpl rename to library/common/templates/lib/validations/_mongodb.tpl diff --git a/library/common/templates/bitnami/validations/_postgresql.tpl b/library/common/templates/lib/validations/_postgresql.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_postgresql.tpl rename to library/common/templates/lib/validations/_postgresql.tpl diff --git a/library/common/templates/bitnami/validations/_redis.tpl b/library/common/templates/lib/validations/_redis.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_redis.tpl rename to library/common/templates/lib/validations/_redis.tpl diff --git a/library/common/templates/bitnami/validations/_validations.tpl b/library/common/templates/lib/validations/_validations.tpl similarity index 100% rename from library/common/templates/bitnami/validations/_validations.tpl rename to library/common/templates/lib/validations/_validations.tpl