diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 05ec648fc50..2fbe311de89 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -19,4 +19,4 @@ name: common sources: - https://github.com/truecharts/apps/tree/master/library/common type: library -version: 4.0.1 +version: 4.1.0 diff --git a/charts/library/common/templates/_all.tpl b/charts/library/common/templates/_all.tpl index 28391d77e00..644d7cb3b3f 100644 --- a/charts/library/common/templates/_all.tpl +++ b/charts/library/common/templates/_all.tpl @@ -7,26 +7,31 @@ Main entrypoint for the common library chart. It will render all underlying temp {{- /* Build the templates */ -}} {{- include "common.pvc" . }} - {{- print "---" | nindent 0 -}} + {{- if .Values.serviceAccount.create -}} {{- include "common.serviceAccount" . }} - {{- print "---" | nindent 0 -}} {{- end -}} - {{- if eq .Values.controllerType "deployment" }} + + {{- if eq .Values.controller.type "deployment" }} {{- include "common.deployment" . | nindent 0 }} - {{ else if eq .Values.controllerType "daemonset" }} + {{ else if eq .Values.controller.type "daemonset" }} {{- include "common.daemonset" . | nindent 0 }} - {{ else if eq .Values.controllerType "statefulset" }} + {{ else if eq .Values.controller.type "statefulset" }} {{- include "common.statefulset" . | nindent 0 }} + {{ else }} + {{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) }} {{- end -}} + {{ include "common.classes.hpa" . | nindent 0 }} - {{ include "common.services" . | nindent 0 }} + + {{ include "common.service" . | nindent 0 }} + {{ include "common.ingress" . | nindent 0 }} + {{- if .Values.secret -}} - {{- print "---" | nindent 0 -}} {{ include "common.secret" . | nindent 0 }} {{- end -}} - {{ include "common.classes.mountPermissions" . | nindent 0 }} {{ include "common.classes.portal" . | nindent 0 }} + {{ include "common.class.mountPermissions" . | nindent 0 }} {{- end -}} diff --git a/charts/library/common/templates/_daemonset.tpl b/charts/library/common/templates/_daemonset.tpl index 91bb0a4fafd..0f0670cf40a 100644 --- a/charts/library/common/templates/_daemonset.tpl +++ b/charts/library/common/templates/_daemonset.tpl @@ -1,52 +1,35 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - - {{/* This template serves as the blueprint for the DaemonSet objects that are created within the common library. */}} -{{- define "common.daemonset" -}} -apiVersion: {{ include "common.capabilities.daemonset.apiVersion" . }} +{{- define "common.daemonset" }} +--- +apiVersion: apps/v1 kind: DaemonSet metadata: name: {{ include "common.names.fullname" . }} labels: {{- include "common.labels" . | nindent 4 }} - {{- with .Values.controllerLabels }} - {{- toYaml . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.controllerAnnotations }} + {{- with .Values.controller.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} selector: matchLabels: - {{- include "common.labels.selectorLabels" . | nindent 6 }} + {{- include "common.labels.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} annotations: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- include "common.labels.selectorLabels" . | nindent 8 }} spec: {{- include "common.controller.pod" . | nindent 6 }} {{- end }} diff --git a/charts/library/common/templates/_deployment.tpl b/charts/library/common/templates/_deployment.tpl index caa9464359b..4cb645b58cf 100644 --- a/charts/library/common/templates/_deployment.tpl +++ b/charts/library/common/templates/_deployment.tpl @@ -1,56 +1,53 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - {{/* This template serves as the blueprint for the Deployment objects that are created within the common library. */}} -{{- define "common.deployment" -}} -apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }} +{{- define "common.deployment" }} +--- +apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "common.names.fullname" . }} labels: {{- include "common.labels" . | nindent 4 }} - {{- with .Values.controllerLabels }} - {{- toYaml . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.controllerAnnotations }} + {{- with .Values.controller.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - replicas: {{ .Values.replicas }} - {{- with .Values.strategy }} - strategy: - {{- toYaml . | nindent 4 }} + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + replicas: {{ .Values.controller.replicas }} + {{- $strategy := default "Recreate" .Values.controller.strategy }} + {{- if and (ne $strategy "Recreate") (ne $strategy "RollingUpdate") }} + {{- fail (printf "Not a valid strategy type for Deployment (%s)" $strategy) }} {{- end }} + strategy: + type: {{ $strategy }} + {{- with .Values.controller.rollingUpdate }} + {{- if and (eq $strategy "RollingUpdate") (or .surge .unavailable) }} + rollingUpdate: + {{- with .unavailable }} + maxUnavailable: {{ . }} + {{- end }} + {{- with .surge }} + maxSurge: {{ . }} + {{- end }} + {{- end }} + {{- end }} selector: matchLabels: - {{- include "common.labels.selectorLabels" . | nindent 6 }} + {{- include "common.labels.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} annotations: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- include "common.labels.selectorLabels" . | nindent 8 }} spec: {{- include "common.controller.pod" . | nindent 6 }} {{- end }} diff --git a/charts/library/common/templates/_ingress.tpl b/charts/library/common/templates/_ingress.tpl index e4bec46807b..71eb165b5d9 100644 --- a/charts/library/common/templates/_ingress.tpl +++ b/charts/library/common/templates/_ingress.tpl @@ -1,34 +1,48 @@ -{{/* -Renders the Ingress objects required by the chart by returning a concatinated list -of the main Ingress and any additionalIngresses. -*/}} +{{/* Renders the Ingress objects required by the chart */}} {{- define "common.ingress" -}} - {{- /* Generate named ingresses as required */ -}} - {{- range $name, $ingress := .Values.ingress }} - {{- if $ingress.enabled -}} - {{- print ("---\n") | nindent 0 -}} - {{- $ingressValues := $ingress -}} + {{- /* Generate named ingresses as required */ -}} + {{- range $name, $ingress := .Values.ingress }} + {{- if $ingress.enabled -}} + {{- $ingressValues := $ingress -}} - {{/* set defaults */}} - {{- if not $ingressValues.nameSuffix -}} - {{- $_ := set $ingressValues "nameSuffix" $name -}} - {{ end -}} + {{/* set defaults */}} + {{- if and (not $ingressValues.nameOverride) (ne $name (include "common.ingress.primary" $)) -}} + {{- $_ := set $ingressValues "nameOverride" $name -}} + {{- end -}} - {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}} - {{- include "common.classes.ingress" $ }} + {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}} + {{- include "common.classes.ingress" $ }} - - {{- range $index, $tlsValues := $ingressValues.tls }} - {{- if .scaleCert }} - {{- $nameSuffix := ( printf "%v-%v-%v" $ingressValues.nameSuffix "tls" $index ) -}} - {{- $_ := set $tlsValues "nameSuffix" $nameSuffix -}} - {{- $_ := set $ "ObjectValues" (dict "certHolder" $tlsValues) -}} - {{- print ("---\n") | nindent 0 -}} - {{- include "common.cert.secret" $ -}} - {{- end }} + {{- range $name, $tlsValues := $ingressValues.tls }} + {{- if .scaleCert }} + {{- $nameOverride := ( printf "%v-%v-%v" $ingressValues.nameOverride "tls" $name ) -}} + {{- $_ := set $tlsValues "nameOverride" $nameOverride -}} + {{- $_ := set $ "ObjectValues" (dict "certHolder" $tlsValues) -}} + {{- include "common.cert.secret" $ -}} {{- end }} - - {{- end }} {{- end }} + {{- end }} {{- end }} + +{{/* Return the name of the primary ingress object */}} +{{- define "common.ingress.primary" -}} + {{- $enabledIngresses := dict -}} + {{- range $name, $ingress := .Values.ingress -}} + {{- if $ingress.enabled -}} + {{- $_ := set $enabledIngresses $name . -}} + {{- end -}} + {{- end -}} + + {{- $result := "" -}} + {{- range $name, $ingress := $enabledIngresses -}} + {{- if and (hasKey $ingress "primary") $ingress.primary -}} + {{- $result = $name -}} + {{- end -}} + {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledIngresses | first -}} + {{- end -}} + {{- $result -}} +{{- end -}} diff --git a/charts/library/common/templates/_pvc.tpl b/charts/library/common/templates/_pvc.tpl index 4f2af2f3e64..e6322e4a8ce 100644 --- a/charts/library/common/templates/_pvc.tpl +++ b/charts/library/common/templates/_pvc.tpl @@ -32,11 +32,10 @@ of all the entries of the persistence key. {{- if and $PVC.enabled (not (or $emptyDir $PVC.existingClaim)) -}} {{- $persistenceValues := $PVC -}} - {{- if not $persistenceValues.nameSuffix -}} - {{- $_ := set $persistenceValues "nameSuffix" $index -}} + {{- if not $persistenceValues.nameOverride -}} + {{- $_ := set $persistenceValues "nameOverride" $index -}} {{- end -}} {{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}} - {{- print ("---") | nindent 0 -}} {{- include "common.classes.pvc" $ | nindent 0 -}} {{- end }} {{- end }} diff --git a/charts/library/common/templates/_secret.tpl b/charts/library/common/templates/_secret.tpl index 34d10d9c87f..1a6df463d7f 100644 --- a/charts/library/common/templates/_secret.tpl +++ b/charts/library/common/templates/_secret.tpl @@ -1,7 +1,8 @@ {{/* The Secret object to be created. */}} -{{- define "common.secret" -}} +{{- define "common.secret" }} +--- apiVersion: v1 kind: Secret metadata: diff --git a/charts/library/common/templates/_service.tpl b/charts/library/common/templates/_service.tpl new file mode 100644 index 00000000000..07e2a2a2b0a --- /dev/null +++ b/charts/library/common/templates/_service.tpl @@ -0,0 +1,43 @@ +{{/* +Renders the Service objects required by the chart. +*/}} +{{- define "common.service" -}} + {{- /* Generate named services as required */ -}} + {{- range $name, $service := .Values.service }} + {{- if $service.enabled -}} + {{- $serviceValues := $service -}} + + {{/* set the default nameOverride to the service name */}} + {{- if and (not $serviceValues.nameOverride) (ne $name (include "common.service.primary" $)) -}} + {{- $_ := set $serviceValues "nameOverride" $name -}} + {{ end -}} + + {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} + {{- include "common.classes.service" $ }} + {{- end }} + {{- end }} +{{- end }} + +{{/* +Return the name of the primary service object +*/}} +{{- define "common.service.primary" -}} + {{- $enabledServices := dict -}} + {{- range $name, $service := .Values.service -}} + {{- if $service.enabled -}} + {{- $_ := set $enabledServices $name . -}} + {{- end -}} + {{- end -}} + + {{- $result := "" -}} + {{- range $name, $service := $enabledServices -}} + {{- if and (hasKey $service "primary") $service.primary -}} + {{- $result = $name -}} + {{- end -}} + {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledServices | first -}} + {{- end -}} + {{- $result -}} +{{- end -}} diff --git a/charts/library/common/templates/_serviceaccount.tpl b/charts/library/common/templates/_serviceaccount.tpl index a8c0e7903ba..0cca83c05bd 100644 --- a/charts/library/common/templates/_serviceaccount.tpl +++ b/charts/library/common/templates/_serviceaccount.tpl @@ -1,7 +1,8 @@ {{/* The ServiceAccount object to be created. */}} -{{- define "common.serviceAccount" -}} +{{- define "common.serviceAccount" }} +--- apiVersion: v1 kind: ServiceAccount metadata: diff --git a/charts/library/common/templates/_services.tpl b/charts/library/common/templates/_services.tpl deleted file mode 100644 index 18a39cf9d3c..00000000000 --- a/charts/library/common/templates/_services.tpl +++ /dev/null @@ -1,21 +0,0 @@ -{{/* -Renders the Service objects required by the chart by returning a concatinated list -of the main Service and any additionalservice. -*/}} -{{- define "common.services" -}} - {{- if .Values.services -}} - {{- range $name, $service := .Values.services }} - {{- if $service.enabled -}} - {{- print ("---\n") | nindent 0 -}} - {{- $serviceValues := $service -}} - - {{- if $serviceValues.nameSuffix -}} - {{- $_ := set $serviceValues "nameSuffix" $name -}} - {{ end -}} - - {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} - {{- include "common.classes.service" $ -}} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/charts/library/common/templates/_statefulset.tpl b/charts/library/common/templates/_statefulset.tpl index 3b7915b3d92..24579fa06af 100644 --- a/charts/library/common/templates/_statefulset.tpl +++ b/charts/library/common/templates/_statefulset.tpl @@ -20,52 +20,60 @@ This file is considered to be modified by the TrueCharts Project. This template serves as the blueprint for the StatefulSet objects that are created within the common library. */}} -{{- define "common.statefulset" -}} -apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} +{{- define "common.statefulset" }} +--- +apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "common.names.fullname" . }} labels: - {{- include "common.labels" . | nindent 4 }} - {{- with .Values.controllerLabels }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.controllerAnnotations }} + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.controller.annotations }} annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - replicas: {{ .Values.replicas }} - {{- with .Values.strategy }} - updateStrategy: {{- toYaml . | nindent 4 }} {{- end }} +spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + replicas: {{ .Values.controller.replicas }} + {{- $strategy := default "RollingUpdate" .Values.controller.strategy }} + {{- if and (ne $strategy "OnDelete") (ne $strategy "RollingUpdate") }} + {{- fail (printf "Not a valid strategy type for StatefulSet (%s)" $strategy) }} + {{- end }} + updateStrategy: + type: {{ $strategy }} + {{- if and (eq $strategy "RollingUpdate") .Values.controller.rollingUpdate.partition }} + rollingUpdate: + partition: {{ .Values.controller.rollingUpdate.partition }} + {{- end }} selector: matchLabels: - {{- include "common.labels.selectorLabels" . | nindent 6 }} + {{- include "common.labels.selectorLabels" . | nindent 6 }} serviceName: {{ include "common.names.fullname" . }} template: metadata: {{- with .Values.podAnnotations }} annotations: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- include "common.labels.selectorLabels" . | nindent 8 }} spec: {{- include "common.controller.pod" . | nindent 6 }} volumeClaimTemplates: - {{- range $index, $vct := .Values.volumeClaimTemplates }} - - metadata: - name: {{ $vct.name }} - spec: - accessModes: - - {{ required (printf "accessMode is required for vCT %v" $vct.name) $vct.accessMode | quote }} - resources: - requests: - storage: {{ required (printf "size is required for PVC %v" $vct.name) $vct.size | quote }} - {{- if $vct.storageClass }} - storageClassName: {{ if (eq "-" $vct.storageClass) }}""{{- else }}{{ $vct.storageClass | quote }}{{- end }} - {{- end }} -{{- end }} + {{- range $index, $vct := .Values.volumeClaimTemplates }} + - metadata: + name: {{ $vct.name }} + spec: + accessModes: + - {{ required (printf "accessMode is required for vCT %v" $vct.name) $vct.accessMode | quote }} + resources: + requests: + storage: {{ required (printf "size is required for PVC %v" $vct.name) $vct.size | quote }} + {{- if $vct.storageClass }} + storageClassName: {{ if (eq "-" $vct.storageClass) }}""{{- else }}{{ $vct.storageClass | quote }}{{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/library/common/templates/classes/_HorizontalPodAutoscaler.tpl b/charts/library/common/templates/classes/_HorizontalPodAutoscaler.tpl index ae5769e2c26..1c448acd758 100644 --- a/charts/library/common/templates/classes/_HorizontalPodAutoscaler.tpl +++ b/charts/library/common/templates/classes/_HorizontalPodAutoscaler.tpl @@ -3,12 +3,10 @@ This template serves as a blueprint for horizontal pod autoscaler objects that a using the common library. */}} {{- define "common.classes.hpa" -}} -{{- if .Values.autoscaling }} -{{- if .Values.autoscaling.enabled }} -{{- print "---" | nindent 0 -}} -{{- $hpaName := include "common.names.fullname" . -}} -{{- $targetName := include "common.names.fullname" . -}} - + {{- if .Values.autoscaling.enabled -}} + {{- $hpaName := include "common.names.fullname" . -}} + {{- $targetName := include "common.names.fullname" . }} +--- apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: @@ -18,27 +16,22 @@ metadata: spec: scaleTargetRef: apiVersion: apps/v1 - {{- if eq .Values.controllerType "statefulset" }} - kind: StatefulSet - {{- else }} - kind: Deployment - {{- end }} + kind: {{ include "common.names.controllerType" . }} name: {{ .Values.autoscaling.target | default $targetName }} minReplicas: {{ .Values.autoscaling.minReplicas | default 1 }} maxReplicas: {{ .Values.autoscaling.maxReplicas | default 3 }} metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource resource: name: cpu targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} -{{- end }} + {{- end }} + {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/classes/_ingress.tpl b/charts/library/common/templates/classes/_ingress.tpl index 8efc187a78a..6aa779658ef 100644 --- a/charts/library/common/templates/classes/_ingress.tpl +++ b/charts/library/common/templates/classes/_ingress.tpl @@ -3,23 +3,24 @@ This template serves as a blueprint for all Ingress objects that are created within the common library. */}} {{- define "common.classes.ingress" -}} -{{- $ingressName := include "common.names.fullname" . -}} -{{- $values := index .Values.ingress (keys .Values.ingress | first) -}} + {{- $ingressName := include "common.names.fullname" . -}} + {{- $values := .Values.ingress -}} -{{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.ingress -}} - {{- $values = . -}} + {{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.ingress -}} + {{- $values = . -}} + {{- end -}} + {{ end -}} + + {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}} {{- end -}} -{{ end -}} - -{{- if hasKey $values "nameSuffix" -}} - {{- $ingressName = printf "%v-%v" $ingressName $values.nameSuffix -}} -{{ end -}} - -{{- $svc := index .Values.services (keys .Values.services | first) -}} -{{- $svcName := $values.serviceName | default (include "common.names.fullname" .) -}} -{{- $svcPort := $values.servicePort | default $svc.port.port -}} + {{- $primaryService := get .Values.service (include "common.service.primary" .) }} + {{- $primaryPort := get $primaryService.ports (include "common.classes.service.ports.primary" (dict "values" $primaryService)) -}} + {{- $name := include "common.names.name" . -}} + {{- $isStable := include "common.capabilities.ingress.isStable" . }} +--- apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }} kind: Ingress metadata: @@ -31,60 +32,49 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: - {{- if eq (include "common.capabilities.ingress.apiVersion" $) "networking.k8s.io/v1" }} - {{- if $values.ingressClassName }} + {{- if and $isStable $values.ingressClassName }} ingressClassName: {{ $values.ingressClassName }} {{- end }} - {{- end }} {{- if $values.tls }} tls: {{- range $index, $tlsValues := $values.tls }} - hosts: {{- range $tlsValues.hosts }} - - {{ . | quote }} - {{- end }} - {{- range $tlsValues.hostsTpl }} - {{ tpl . $ | quote }} {{- end }} - {{- if or $tlsValues.secretNameTpl $tlsValues.secretName $tlsValues.scaleCert }} {{- if $tlsValues.scaleCert }} secretName: {{ ( printf "%v-%v-%v-%v-%v" $ingressName "tls" $index "ixcert" $tlsValues.scaleCert ) }} - {{- else if $tlsValues.secretNameTpl }} - secretName: {{ tpl $tlsValues.secretNameTpl $ | quote}} - {{- else }} - secretName: {{ $tlsValues.secretName }} - {{- end }} + {{- else if .secretName }} + secretName: {{ tpl .secretName $ | quote}} {{- end }} {{- end }} {{- end }} rules: {{- range $values.hosts }} - {{- if .hostTpl }} - - host: {{ tpl .hostTpl $ | quote }} - {{- else }} - - host: {{ .host | quote }} - {{- end }} + - host: {{ tpl .host $ | quote }} http: paths: {{- range .paths }} - {{- if .pathTpl }} - - path: {{ tpl .pathTpl $ | quote }} - {{- else }} - - path: {{ .path | quote }} + {{- $service := $name -}} + {{- $port := $primaryPort.port -}} + {{- if .service -}} + {{- $service = default $name .service.name -}} + {{- $port = default $primaryPort.port .service.port -}} {{- end }} - {{- if eq (include "common.capabilities.ingress.apiVersion" $) "networking.k8s.io/v1" }} + - path: {{ tpl .path $ | quote }} + {{- if $isStable }} pathType: {{ default "Prefix" .pathType }} {{- end }} backend: - {{- if eq (include "common.capabilities.ingress.apiVersion" $) "networking.k8s.io/v1" }} + {{- if $isStable }} service: - name: {{ .serviceName | default $svcName }} + name: {{ $service }} port: - number: {{ .servicePort | default $svcPort }} - {{- else }} - serviceName: {{ .serviceName | default $svcName }} - servicePort: {{ .servicePort | default $svcPort }} - {{- end }} + number: {{ $port }} + {{- else }} + serviceName: {{ $service }} + servicePort: {{ $port }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/charts/library/common/templates/classes/_mountPermissions.tpl b/charts/library/common/templates/classes/_mountPermissions.tpl index a830b5dc7ea..2d043f7ea88 100644 --- a/charts/library/common/templates/classes/_mountPermissions.tpl +++ b/charts/library/common/templates/classes/_mountPermissions.tpl @@ -2,41 +2,37 @@ This template serves as the blueprint for the mountPermissions job that is run before chart installation. */}} -{{- define "common.classes.mountPermissions" -}} -{{- if .Values.hostPathMounts -}} - -{{- $jobName := include "common.names.fullname" . -}} -{{- $values := .Values -}} -{{- $user := 568 -}} -{{- $group := 568 -}} -{{- print "---" | nindent 0 -}} - -{{- if $values.podSecurityContext }} - {{- if $values.podSecurityContext.runAsUser }} - {{- $user = $values.podSecurityContext.runAsUser -}} - {{- end -}} - {{- if $values.podSecurityContext.fsGroup -}} - {{- $group = $values.podSecurityContext.fsGroup -}} - {{- end -}} -{{- else if $values.env }} - {{- if $values.env.PUID }} - {{- $user = $values.env.PUID -}} - {{- end -}} - {{- if $values.env.PGID }} - {{- $group = $values.env.PGID -}} - {{- end -}} -{{- end -}} - +{{- define "common.class.mountPermissions" -}} + {{- if .Values.hostPathMounts -}} + {{- $jobName := include "common.names.fullname" . -}} + {{- $user := 568 -}} + {{- if .Values.env -}} + {{- $user = dig "PUID" $user .Values.env -}} + {{- end -}} + {{- $user = dig "runAsUser" $user .Values.podSecurityContext -}} + {{- $group := 568 -}} + {{- if and .Values.env -}} + {{- $group = dig "PGID" $group .Values.env -}} + {{- end -}} + {{- $group = dig "fsGroup" $group .Values.podSecurityContext -}} + {{- $hostPathMounts := dict -}} + {{- range $name, $mount := .Values.hostPathMounts -}} + {{- if and $mount.enabled $mount.setPermissions -}} + {{- $name = default $name $mount.name -}} + {{- $_ := set $hostPathMounts $name $mount -}} + {{- end -}} + {{- end }} +--- apiVersion: batch/v1 kind: Job metadata: - name: {{ $jobName }}-autopermissions + name: {{ printf "%s-auto-permissions" $jobName }} labels: {{- include "common.labels" . | nindent 4 }} annotations: - "helm.sh/hook": pre-install,pre-upgrade - "helm.sh/hook-weight": "-10" - "helm.sh/hook-delete-policy": hook-succeeded,hook-failed,before-hook-creation + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-10" + "helm.sh/hook-delete-policy": hook-succeeded,hook-failed,before-hook-creation spec: template: metadata: @@ -44,48 +40,31 @@ spec: restartPolicy: Never containers: - name: set-mount-permissions - image: "alpine:3.3" + image: alpine:3.3 command: - - /bin/sh - - -c - - | {{ range $index, $hpm := .Values.hostPathMounts}}{{ if and $hpm.enabled $hpm.setPermissions}} - chown -R {{ print $user }}:{{ print $group }} {{ print $hpm.mountPath }}{{ end }}{{ end }} - #args: - # - #securityContext: - # + - /bin/sh + - -c + - | + {{- range $_, $hpm := $hostPathMounts }} + chown -R {{ printf "%d:%d %s" (int $user) (int $group) $hpm.mountPath }} + {{- end }} volumeMounts: - {{ range $name, $hpmm := .Values.hostPathMounts }} - {{- if $hpmm.enabled -}} - {{- if $hpmm.setPermissions -}} - {{ if $hpmm.name }} - {{ $name = $hpmm.name }} - {{ end }} - - name: hostpathmounts-{{ $name }} - mountPath: {{ $hpmm.mountPath }} - {{ if $hpmm.subPath }} - subPath: {{ $hpmm.subPath }} - {{ end }} - {{- end -}} - {{- end -}} - {{ end }} + {{- range $name, $hpm := $hostPathMounts }} + - name: {{ printf "hostpathmounts-%s" $name }} + mountPath: {{ $hpm.mountPath }} + {{- if $hpm.subPath }} + subPath: {{ $hpm.subPath }} + {{- end }} + {{- end }} volumes: - {{- range $name, $hpm := .Values.hostPathMounts -}} - {{ if $hpm.enabled }} - {{ if $hpm.setPermissions }} - {{ if $hpm.name }} - {{ $name = $hpm.name }} - {{ end }} - - name: hostpathmounts-{{ $name }} - {{ if $hpm.emptyDir }} - emptyDir: {} - {{- else -}} - hostPath: - path: {{ required "hostPath not set" $hpm.hostPath }} - {{ end }} - {{ end }} - {{ end }} - {{- end -}} - -{{- end }} -{{- end }} + {{- range $name, $hpm := $hostPathMounts }} + - name: {{ printf "hostpathmounts-%s" $name }} + {{- if $hpm.emptyDir }} + emptyDir: {} + {{- else }} + hostPath: + path: {{ required "hostPath not set" $hpm.hostPath }} + {{- end }} + {{- end }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/classes/_pvc.tpl b/charts/library/common/templates/classes/_pvc.tpl index 038ed3de5c1..b2e4064aac5 100644 --- a/charts/library/common/templates/classes/_pvc.tpl +++ b/charts/library/common/templates/classes/_pvc.tpl @@ -28,13 +28,12 @@ within the common library. {{- end -}} {{ end -}} {{- $pvcName := include "common.names.fullname" . -}} -{{- if hasKey $values "nameOverride" -}} - {{- $pvcName = $values.nameOverride -}} -{{- else if hasKey $values "nameSuffix" -}} - {{- if not (eq $values.nameSuffix "-") -}} - {{- $pvcName = printf "%v-%v" $pvcName $values.nameSuffix -}} +{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- if not (eq $values.nameOverride "-") -}} + {{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}} {{ end -}} -{{ end -}} +{{ end }} +--- kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/charts/library/common/templates/classes/_service.tpl b/charts/library/common/templates/classes/_service.tpl index cfaec8bc46a..09e49a43fb4 100644 --- a/charts/library/common/templates/classes/_service.tpl +++ b/charts/library/common/templates/classes/_service.tpl @@ -21,17 +21,20 @@ This template serves as a blueprint for all Service objects that are created within the common library. */}} {{- define "common.classes.service" -}} -{{- $values := index .Values.services (keys .Values.services | first) -}} +{{- $values := .Values.service -}} {{- if hasKey . "ObjectValues" -}} {{- with .ObjectValues.service -}} {{- $values = . -}} {{- end -}} {{ end -}} + {{- $serviceName := include "common.names.fullname" . -}} -{{- if hasKey $values "nameSuffix" -}} - {{- $serviceName = printf "%v-%v" $serviceName $values.nameSuffix -}} +{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}} {{ end -}} {{- $svcType := $values.type | default "" -}} +{{- $primaryPort := get $values.ports (include "common.classes.service.ports.primary" (dict "values" $values)) }} +--- apiVersion: v1 kind: Service metadata: @@ -42,7 +45,7 @@ metadata: {{ toYaml $values.labels | nindent 4 }} {{- end }} annotations: - {{- if eq ( $values.port.protocol | default "" ) "HTTPS" }} + {{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }} traefik.ingress.kubernetes.io/service.serversscheme: https {{- end }} {{- with $values.annotations }} @@ -83,7 +86,26 @@ spec: {{- if $values.publishNotReadyAddresses }} publishNotReadyAddresses: {{ $values.publishNotReadyAddresses }} {{- end }} - {{- include "common.classes.service.ports" (dict "svcType" $svcType "values" $values ) | trim | nindent 2 }} + ports: + {{- range $name, $port := $values.ports }} + {{- if $port.enabled }} + - port: {{ $port.port }} + targetPort: {{ $port.targetPort | default $name }} + {{- if $port.protocol }} + {{- if or ( eq $port.protocol "HTTP" ) ( eq $port.protocol "HTTPS" ) ( eq $port.protocol "TCP" ) }} + protocol: TCP + {{- else }} + protocol: {{ $port.protocol }} + {{- end }} + {{- else }} + protocol: TCP + {{- end }} + name: {{ $name }} + {{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }} + nodePort: {{ $port.nodePort }} + {{ end }} + {{- end }} + {{- end }} selector: {{- include "common.labels.selectorLabels" . | nindent 4 }} {{- end }} diff --git a/charts/library/common/templates/classes/_service_ports.tpl b/charts/library/common/templates/classes/_service_ports.tpl index 7a9f62b70da..3eaaa9e1bc4 100644 --- a/charts/library/common/templates/classes/_service_ports.tpl +++ b/charts/library/common/templates/classes/_service_ports.tpl @@ -17,33 +17,29 @@ This file is considered to be modified by the TrueCharts Project. */}} {{/* -Render all the ports and additionalPorts for a Service object. +Return the name of the primary port for a given Service object. */}} -{{- define "common.classes.service.ports" -}} - {{- $ports := list -}} - {{- $values := .values -}} - {{- $ports = mustAppend $ports $values.port -}} - {{- range $_ := $values.additionalPorts -}} - {{- $ports = mustAppend $ports . -}} +{{- define "common.classes.service.ports.primary" -}} + {{- $enabledPorts := dict -}} + {{- range $name, $port := .values.ports -}} + {{- if $port.enabled -}} + {{- $_ := set $enabledPorts $name . -}} + {{- end -}} + {{- end -}} + + {{- if eq 0 (len $enabledPorts) }} + {{- fail (printf "No ports are enabled for service \"%s\"!" .serviceName) }} {{- end }} - {{- if $ports -}} - ports: - {{- range $_ := $ports }} - - port: {{ .port }} - targetPort: {{ .targetPort | default .name | default "http" }} - {{- if .protocol }} - {{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) ( eq .protocol "TCP" ) }} - protocol: TCP - {{- else }} - protocol: {{ .protocol }} - {{- end }} - {{- else }} - protocol: TCP - {{- end }} - name: {{ .name | default "http" }} - {{- if (and (eq $.svcType "NodePort") (not (empty .nodePort))) }} - nodePort: {{ .nodePort }} - {{ end }} + + {{- $result := "" -}} + {{- range $name, $port := $enabledPorts -}} + {{- if and (hasKey $port "primary") $port.primary -}} + {{- $result = $name -}} + {{- end -}} {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledPorts | first -}} {{- end -}} -{{- end }} + {{- $result -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/cert/_certSecret.yaml b/charts/library/common/templates/lib/cert/_certSecret.yaml index fe133800f37..fe15636491e 100644 --- a/charts/library/common/templates/lib/cert/_certSecret.yaml +++ b/charts/library/common/templates/lib/cert/_certSecret.yaml @@ -14,6 +14,7 @@ {{ end -}} {{- if eq (include "common.cert.available" $ ) "true" -}} +--- apiVersion: v1 kind: Secret metadata: diff --git a/charts/library/common/templates/lib/chart/_capabilities.tpl b/charts/library/common/templates/lib/chart/_capabilities.tpl index 809dcae467d..96de3c104d9 100644 --- a/charts/library/common/templates/lib/chart/_capabilities.tpl +++ b/charts/library/common/templates/lib/chart/_capabilities.tpl @@ -1,110 +1,19 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* -Return the appropriate apiVersion for DaemonSet objects. -*/}} -{{- define "common.capabilities.daemonset.apiVersion" -}} -{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} -{{- print "extensions/v1beta1" -}} -{{- else -}} -{{- print "apps/v1" -}} -{{- end -}} +{{/* Allow KubeVersion to be overridden. */}} +{{- define "common.capabilities.ingress.kubeVersion" -}} + {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}} {{- end -}} -{{/* -Waiting on https://github.com/helm/helm/pull/8608 -{{- define "common.capabilities.daemonset.apiVersion" -}} -{{- if .Capabilities.APIVersions.Has "apps/v1/DaemonSet" -}} -{{- print "apps/v1" -}} -{{- else -}} -{{- print "extensions/v1beta1" -}} -{{- end -}} -{{- end -}} -*/}} - -{{/* -Return the appropriate apiVersion for Deployment objects. -*/}} -{{- define "common.capabilities.deployment.apiVersion" -}} -{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} -{{- print "extensions/v1beta1" -}} -{{- else -}} -{{- print "apps/v1" -}} -{{- end -}} -{{- end -}} - -{{/* -Waiting on https://github.com/helm/helm/pull/8608 -{{- define "common.capabilities.deployment.apiVersion" -}} -{{- if .Capabilities.APIVersions.Has "apps/v1/Deployment" -}} -{{- print "apps/v1" -}} -{{- else -}} -{{- print "extensions/v1beta1" -}} -{{- end -}} -{{- end -}} -*/}} - -{{/* -Return the appropriate apiVersion for StatefulSet objects. -*/}} -{{- define "common.capabilities.statefulset.apiVersion" -}} -{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} -{{- print "apps/v1beta1" -}} -{{- else -}} -{{- print "apps/v1" -}} -{{- end -}} -{{- end -}} - -{{/* -Waiting on https://github.com/helm/helm/pull/8608 -{{- define "common.capabilities.statefulset.apiVersion" -}} -{{- if .Capabilities.APIVersions.Has "apps/v1/StatefulSet" -}} -{{- print "apps/v1" -}} -{{- else -}} -{{- print "apps/v1beta1" -}} -{{- end -}} -{{- end -}} -*/}} - -{{/* -Return the appropriate apiVersion for Ingress objects. -*/}} - +{{/* Return the appropriate apiVersion for Ingress objects */}} {{- define "common.capabilities.ingress.apiVersion" -}} -{{- 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" -}} -{{- else -}} -{{- print "networking.k8s.io/v1" -}} -{{- end }} + {{- print "networking.k8s.io/v1" -}} + {{- if semverCompare "<1.19" (include "common.capabilities.ingress.kubeVersion" .) -}} + {{- print "beta1" -}} + {{- end -}} {{- end -}} -{{/* -Waiting on https://github.com/helm/helm/pull/8608 -{{- define "common.capabilities.ingress.apiVersion" -}} -{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}} -{{- print "networking.k8s.io/v1" -}} -{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}} -{{- print "networking.k8s.io/v1beta1" -}} -{{- else -}} -{{- print "extensions/v1beta1" -}} -{{- end }} +{{/* Check Ingress stability */}} +{{- define "common.capabilities.ingress.isStable" -}} + {{- if eq (include "common.capabilities.ingress.apiVersion" .) "networking.k8s.io/v1" -}} + {{- true -}} + {{- end -}} {{- end -}} -*/}} diff --git a/charts/library/common/templates/lib/chart/_errors.tpl b/charts/library/common/templates/lib/chart/_errors.tpl deleted file mode 100644 index 2985af443df..00000000000 --- a/charts/library/common/templates/lib/chart/_errors.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* vim: set filetype=mustache: */}} -{{/* -Through error when upgrading using empty passwords values that must not be empty. - -Usage: -{{- $validationError00 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password00" "secret" "secretName" "field" "password-00") -}} -{{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}} -{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }} - -Required password params: - - validationErrors - String - Required. List of validation strings to be return, if it is empty it won't throw error. - - context - Context - Required. Parent context. -*/}} -{{- define "common.errors.upgrade.passwords.empty" -}} - {{- $validationErrors := join "" .validationErrors -}} - {{- if and $validationErrors .context.Release.IsUpgrade -}} - {{- $errorString := "\nPASSWORDS ERROR: you must provide your current passwords when upgrade the release%s" -}} - {{- printf $errorString $validationErrors | fail -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_images.tpl b/charts/library/common/templates/lib/chart/_images.tpl deleted file mode 100644 index 12c8ea13608..00000000000 --- a/charts/library/common/templates/lib/chart/_images.tpl +++ /dev/null @@ -1,65 +0,0 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* vim: set filetype=mustache: */}} -{{/* -Return the proper image name -{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" $) }} -*/}} -{{- define "common.images.image" -}} -{{- $registryName := .imageRoot.registry -}} -{{- $repositoryName := .imageRoot.repository -}} -{{- $tag := .imageRoot.tag | toString -}} -{{- if .global }} - {{- if .global.imageRegistry }} - {{- $registryName = .global.imageRegistry -}} - {{- end -}} -{{- end -}} -{{- if $registryName }} -{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} -{{- else -}} -{{- printf "%s:%s" $repositoryName $tag -}} -{{- end -}} -{{- end -}} - -{{/* -Return the proper Docker Image Registry Secret Names -{{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }} -*/}} -{{- define "common.images.pullSecrets" -}} - {{- $pullSecrets := list }} - - {{- if .global }} - {{- range .global.imagePullSecrets -}} - {{- $pullSecrets = append $pullSecrets . -}} - {{- end -}} - {{- end -}} - - {{- range .images -}} - {{- range .pullSecrets -}} - {{- $pullSecrets = append $pullSecrets . -}} - {{- end -}} - {{- end -}} - - {{- if (not (empty $pullSecrets)) }} -imagePullSecrets: - {{- range $pullSecrets }} - - name: {{ . }} - {{- end }} - {{- end }} -{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_labels.tpl b/charts/library/common/templates/lib/chart/_labels.tpl index 760bdd65db9..8a1e11aa807 100644 --- a/charts/library/common/templates/lib/chart/_labels.tpl +++ b/charts/library/common/templates/lib/chart/_labels.tpl @@ -1,37 +1,15 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* -Common labels shared across objects. -*/}} +{{/* Common labels shared across objects */}} {{- define "common.labels" -}} helm.sh/chart: {{ include "common.names.chart" . }} {{ include "common.labels.selectorLabels" . }} -{{- if .Chart.AppVersion }} + {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} + {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} +{{- end -}} -{{/* -Selector labels shared across objects. -*/}} +{{/* Selector labels shared across objects */}} {{- define "common.labels.selectorLabels" -}} app.kubernetes.io/name: {{ include "common.names.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} +{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_names.tpl b/charts/library/common/templates/lib/chart/_names.tpl index 0112cc3b3f0..d0587cddf24 100644 --- a/charts/library/common/templates/lib/chart/_names.tpl +++ b/charts/library/common/templates/lib/chart/_names.tpl @@ -16,13 +16,10 @@ limitations under the License. This file is considered to be modified by the TrueCharts Project. */}} -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} +{{/* Expand the name of the chart */}} {{- define "common.names.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} + {{- default .Chart.Name (default .Values.nameOverride .Values.global.nameOverride) | trunc 63 | trimSuffix "-" -}} +{{- end -}} {{/* Create a default fully qualified app name. @@ -30,32 +27,42 @@ 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 }} + {{- $name := include "common.names.name" . -}} + {{- if or .Values.fullnameOverride .Values.global.fullnameOverride -}} + {{- $name = default .Values.fullnameOverride .Values.global.fullnameOverride -}} + {{- else -}} + {{- if contains $name .Release.Name -}} + {{- $name := .Release.Name -}} + {{- else -}} + {{- $name := printf "%s-%s" .Release.Name $name -}} + {{- end -}} + {{- end -}} + {{- trunc 63 $name | trimSuffix "-" -}} +{{- end -}} -{{/* -Create chart name and version as used by the chart label. -*/}} +{{/* 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 }} + {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} -{{/* -Create the name of the ServiceAccount to use. -*/}} +{{/* Create the name of the ServiceAccount to use */}} {{- define "common.names.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} - {{- default (include "common.names.fullname" .) .Values.serviceAccount.name }} -{{- else }} - {{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} + {{- if .Values.serviceAccount.create -}} + {{- default (include "common.names.fullname" .) .Values.serviceAccount.name -}} + {{- else -}} + {{- default "default" .Values.serviceAccount.name -}} + {{- end -}} +{{- end -}} + +{{/* Return the properly cased version of the controller type */}} +{{- define "common.names.controllerType" -}} + {{- if eq .Values.controller.type "deployment" -}} + {{- print "Deployment" -}} + {{- else if eq .Values.controller.type "daemonset" -}} + {{- print "DaemonSet" -}} + {{- else if eq .Values.controller.type "statefulset" -}} + {{- print "StatefulSet" -}} + {{- else -}} + {{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_utils.tpl b/charts/library/common/templates/lib/chart/_utils.tpl deleted file mode 100644 index c8cec118629..00000000000 --- a/charts/library/common/templates/lib/chart/_utils.tpl +++ /dev/null @@ -1,80 +0,0 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* vim: set filetype=mustache: */}} -{{/* -Print instructions to get a secret value. -Usage: -{{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }} -*/}} -{{- define "common.utils.secret.getvalue" -}} -{{- $varname := include "common.utils.fieldToEnvVar" . -}} -export {{ $varname }}=$(kubectl get secret --namespace {{ .context.Release.Namespace | quote }} {{ .secret }} -o jsonpath="{.data.{{ .field }}}" | base64 --decode) -{{- end -}} - -{{/* -Build env var name given a field -Usage: -{{ include "common.utils.fieldToEnvVar" dict "field" "my-password" }} -*/}} -{{- define "common.utils.fieldToEnvVar" -}} - {{- $fieldNameSplit := splitList "-" .field -}} - {{- $upperCaseFieldNameSplit := list -}} - - {{- range $fieldNameSplit -}} - {{- $upperCaseFieldNameSplit = append $upperCaseFieldNameSplit ( upper . ) -}} - {{- end -}} - - {{ join "_" $upperCaseFieldNameSplit }} -{{- end -}} - -{{/* -Gets a value from .Values given -Usage: -{{ include "common.utils.getValueFromKey" (dict "key" "path.to.key" "context" $) }} -*/}} -{{- define "common.utils.getValueFromKey" -}} -{{- $splitKey := splitList "." .key -}} -{{- $value := "" -}} -{{- $latestObj := $.context.Values -}} -{{- range $splitKey -}} - {{- if not $latestObj -}} - {{- printf "please review the entire path of '%s' exists in values" $.key | fail -}} - {{- end -}} - {{- $value = ( index $latestObj . ) -}} - {{- $latestObj = $value -}} -{{- end -}} -{{- printf "%v" (default "" $value) -}} -{{- end -}} - -{{/* -Returns first .Values key with a defined value or first of the list if all non-defined -Usage: -{{ include "common.utils.getKeyFromList" (dict "keys" (list "path.to.key1" "path.to.key2") "context" $) }} -*/}} -{{- define "common.utils.getKeyFromList" -}} -{{- $key := first .keys -}} -{{- $reverseKeys := reverse .keys }} -{{- range $reverseKeys }} - {{- $value := include "common.utils.getValueFromKey" (dict "key" . "context" $.context ) }} - {{- if $value -}} - {{- $key = . }} - {{- end -}} -{{- end -}} -{{- printf "%s" $key -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_values.tpl b/charts/library/common/templates/lib/chart/_values.tpl index af6b4658fdf..d3c8413c8f7 100644 --- a/charts/library/common/templates/lib/chart/_values.tpl +++ b/charts/library/common/templates/lib/chart/_values.tpl @@ -1,29 +1,9 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - -{{/* -Merge the local chart values and the common chart defaults. -*/}} +{{/* Merge the local chart values and the common chart defaults */}} {{- define "common.values.setup" -}} {{- if .Values.common -}} {{- $defaultValues := deepCopy .Values.common -}} {{- $userValues := deepCopy (omit .Values "common") -}} {{- $mergedValues := mustMergeOverwrite $defaultValues $userValues -}} {{- $_ := set . "Values" (deepCopy $mergedValues) -}} - {{- end }} -{{- end }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_container.tpl b/charts/library/common/templates/lib/controller/_container.tpl index fabfeaa2e50..4e61b6571f4 100644 --- a/charts/library/common/templates/lib/controller/_container.tpl +++ b/charts/library/common/templates/lib/controller/_container.tpl @@ -1,44 +1,23 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - - -{{- /* -The main container included in the controller. -*/ -}} +{{- /* 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: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.command }} - {{- if kindIs "string" . }} - command: {{ . }} - {{- else }} command: - {{ toYaml . | nindent 2 }} - {{- end }} + {{- if kindIs "string" . }} + - {{ . }} + {{- else }} + {{ toYaml . | nindent 4 }} + {{- end }} {{- end }} {{- with .Values.args }} - {{- if kindIs "string" . }} - args: {{ . }} - {{- else }} args: - {{ toYaml . | nindent 2 }} - {{- end }} + {{- if kindIs "string" . }} + - {{ . }} + {{- else }} + {{ toYaml . | nindent 4 }} + {{- end }} {{- end }} {{- with .Values.securityContext }} securityContext: @@ -46,53 +25,68 @@ The main container included in the controller. {{- end }} {{- with .Values.lifecycle }} lifecycle: - {{- toYaml . | nindent 2 }} + {{- toYaml . | nindent 4 }} {{- end }} + env: - {{- if .Values.timezone }} - - name: TZ - value: {{ .Values.timezone | quote }} - {{- end }} - {{- if or .Values.env .Values.envTpl .Values.envValueFrom .Values.envVariable .Values.envList }} + {{- range $key, $value := .Values.envTpl }} + - name: {{ $key }} + value: {{ tpl $value $ | quote }} + {{- end }} + {{- range $key, $value := .Values.envValueFrom }} + - name: {{ $key }} + valueFrom: + {{- $value | toYaml | nindent 6 }} + {{- end }} {{- range $envList := .Values.envList }} - {{- if and $envList.name $envList.value }} - - name: {{ $envList.name }} - value: {{ $envList.value | quote }} - {{- else }} + {{- if and $envList.name $envList.value }} + - name: {{ $envList.name }} + value: {{ $envList.value | quote }} + {{- else }} {{- fail "Please specify name/value for environment variable" }} - {{- end }} + {{- end }} {{- end}} - {{- range $key, $value := .Values.env }} - - name: {{ $key }} - value: {{ $value | quote }} - {{- end }} - {{- range $key, $value := .Values.envTpl }} - - name: {{ $key }} - value: {{ tpl $value $ | quote }} - {{- end }} - {{- range $key, $value := .Values.envValueFrom }} - - name: {{ $key }} - valueFrom: - {{- $value | toYaml | nindent 6 }} - {{- end }} + {{- with .Values.env }} + {{- range $k, $v := . }} + {{- $name := $k }} + {{- $value := $v }} + {{- if kindIs "int" $name }} + {{- $name = required "environment variables as a list of maps require a name field" $value.name }} + {{- end }} + - name: {{ quote $name }} + {{- if kindIs "map" $value -}} + {{- if hasKey $value "value" }} + {{- $value = $value.value -}} + {{- else if hasKey $value "valueFrom" }} + {{- toYaml $value | nindent 6 }} + {{- else }} + {{- dict "valueFrom" $value | toYaml | nindent 6 }} + {{- end }} + {{- end }} + {{- if not (kindIs "map" $value) }} + {{- if kindIs "string" $value }} + {{- $value = tpl $value $ }} + {{- end }} + value: {{ quote $value }} + {{- end }} + {{- end }} {{- end }} {{- if or .Values.envFrom .Values.secret }} envFrom: - {{- with .Values.envFrom }} - {{- toYaml . | nindent 2 }} - {{- end }} - {{- if or .Values.secret }} - - secretRef: - name: {{ include "common.names.fullname" . }} - {{- end }} + {{- with .Values.envFrom }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if .Values.secret }} + - secretRef: + name: {{ include "common.names.fullname" . }} + {{- end }} {{- end }} {{- include "common.controller.ports" . | trim | nindent 2 }} {{- with (include "common.controller.volumeMounts" . | trim) }} volumeMounts: - {{- . | nindent 2 }} + {{ nindent 4 . }} {{- end }} - {{- include "common.controller.probes" . | nindent 2 }} - + {{- include "common.controller.probes" . | trim | nindent 2 }} {{/* Merges the TrueNAS SCALE generated GPU info with the .Values.resources dict */}} diff --git a/charts/library/common/templates/lib/controller/_pod.tpl b/charts/library/common/templates/lib/controller/_pod.tpl index 5a053a41827..76bd45a84fb 100644 --- a/charts/library/common/templates/lib/controller/_pod.tpl +++ b/charts/library/common/templates/lib/controller/_pod.tpl @@ -2,66 +2,66 @@ The pod definition included in the controller. */ -}} {{- define "common.controller.pod" -}} -{{- with .Values.imagePullSecrets }} + {{- with .Values.imagePullSecrets }} imagePullSecrets: - {{- toYaml . | nindent 2 }} -{{- end }} -serviceAccountName: {{ include "common.names.serviceAccountName" . }} -{{- with .Values.podSecurityContext }} -securityContext: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.priorityClassName }} -priorityClassName: {{ . }} -{{- end }} -{{- with .Values.schedulerName }} -schedulerName: {{ . }} -{{- end }} -{{- with .Values.hostNetwork }} -hostNetwork: {{ . }} -{{- end }} -{{- with .Values.hostname }} -hostname: {{ . }} -{{- end }} -{{- if .Values.dnsPolicy }} -dnsPolicy: {{ .Values.dnsPolicy }} -{{- else if .Values.hostNetwork }} -dnsPolicy: "ClusterFirstWithHostNet" -{{- else }} -dnsPolicy: ClusterFirst -{{- end }} -{{- with .Values.dnsConfig }} -dnsConfig: - {{- toYaml . | nindent 2 }} -{{- end }} -enableServiceLinks: {{ .Values.enableServiceLinks }} -{{- with .Values.initContainers }} -initContainers: - {{- toYaml . | nindent 2 }} -{{- end }} -containers: - {{- include "common.controller.mainContainer" . | nindent 0 }} - {{- with .Values.additionalContainers }} - {{- tpl (toYaml .) $ | nindent 0 }} + {{- toYaml . | nindent 2 }} {{- end }} -{{- with (include "common.controller.volumes" . | trim) }} +serviceAccountName: {{ include "common.names.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} +securityContext: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.priorityClassName }} +priorityClassName: {{ . }} + {{- end }} + {{- with .Values.schedulerName }} +schedulerName: {{ . }} + {{- end }} + {{- with .Values.hostNetwork }} +hostNetwork: {{ . }} + {{- end }} + {{- with .Values.hostname }} +hostname: {{ . }} + {{- end }} + {{- if .Values.dnsPolicy }} +dnsPolicy: {{ .Values.dnsPolicy }} + {{- else if .Values.hostNetwork }} +dnsPolicy: ClusterFirstWithHostNet + {{- else }} +dnsPolicy: ClusterFirst + {{- end }} + {{- with .Values.dnsConfig }} +dnsConfig: + {{- toYaml . | nindent 2 }} + {{- end }} +enableServiceLinks: {{ .Values.enableServiceLinks }} + {{- with .Values.initContainers }} +initContainers: + {{- toYaml . | nindent 2 }} + {{- end }} +containers: + {{- include "common.controller.mainContainer" . | nindent 2 }} + {{- with .Values.additionalContainers }} + {{- tpl (toYaml .) $ | nindent 2 }} + {{- end }} + {{- with (include "common.controller.volumes" . | trim) }} volumes: - {{- . | nindent 0 }} -{{- end }} -{{- with .Values.hostAliases }} + {{- nindent 2 . }} + {{- end }} + {{- with .Values.hostAliases }} hostAliases: -{{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.nodeSelector }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.affinity }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.tolerations }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.tolerations }} tolerations: - {{- toYaml . | nindent 2 }} -{{- end }} + {{- toYaml . | nindent 2 }} + {{- end }} {{- end -}} diff --git a/charts/library/common/templates/lib/controller/_ports.tpl b/charts/library/common/templates/lib/controller/_ports.tpl index 13b1e8e0185..39e4e9300b4 100644 --- a/charts/library/common/templates/lib/controller/_ports.tpl +++ b/charts/library/common/templates/lib/controller/_ports.tpl @@ -2,41 +2,36 @@ Ports included by the controller. */}} {{- define "common.controller.ports" -}} -{{- $ports := list -}} - {{/* append the ports for each service */}} - {{- if $.Values.services -}} - {{- range $name, $_ := $.Values.services }} - {{- if .enabled -}} - {{- if kindIs "string" $name -}} - {{- $_ := set .port "name" (default .port.name | default $name) -}} - {{- else -}} - {{- $_ := set .port "name" (required "Missing port.name" .port.name) -}} - {{- end -}} - {{- $ports = mustAppend $ports .port -}} - {{- range $_ := .additionalPorts -}} - {{/* append the additonalPorts for each additional service */}} - {{- $ports = mustAppend $ports . -}} - {{- end }} - {{- end }} + {{- $ports := list -}} + {{- range .Values.service -}} + {{- if .enabled -}} + {{- range $name, $port := .ports -}} + {{- $_ := set $port "name" $name -}} + {{- $ports = mustAppend $ports $port -}} {{- end }} {{- end }} + {{- end }} {{/* export/render the list of ports */}} {{- if $ports -}} ports: {{- range $_ := $ports }} -{{- $protocol := "" -}} -{{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) }} - {{- $protocol = "TCP" -}} -{{- else }} - {{- $protocol = .protocol | default "TCP" -}} -{{- end }} -- name: {{ required "The port's 'name' is not defined" .name }} +{{- if .enabled }} +- name: {{ .name }} {{- if and .targetPort (kindIs "string" .targetPort) }} {{- fail (printf "Our charts do not support named ports for targetPort. (port name %s, targetPort %s)" .name .targetPort) }} {{- end }} containerPort: {{ .targetPort | default .port }} - protocol: {{ $protocol | default "TCP" }} + {{- if .protocol }} + {{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) ( eq .protocol "TCP" ) }} + protocol: TCP + {{- else }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + protocol: TCP + {{- end }} +{{- end}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/controller/_probes.tpl b/charts/library/common/templates/lib/controller/_probes.tpl index 0083fb65b4b..f8eaa26cb80 100644 --- a/charts/library/common/templates/lib/controller/_probes.tpl +++ b/charts/library/common/templates/lib/controller/_probes.tpl @@ -21,8 +21,12 @@ This file is considered to be modified by the TrueCharts Project. Probes selection logic. */}} {{- define "common.controller.probes" -}} -{{- $svc := index .Values.services (keys .Values.services | first) -}} -{{- $svcPort := $svc.port.name -}} +{{- $primaryService := get .Values.service (include "common.service.primary" .) -}} +{{- $primaryPort := "" -}} +{{- if $primaryService -}} + {{- $primaryPort = get $primaryService.ports (include "common.classes.service.ports.primary" (dict "serviceName" (include "common.service.primary" .) "values" $primaryService)) -}} +{{- end -}} + {{- range $probeName, $probe := .Values.probes }} {{- if $probe.enabled -}} {{- "" | nindent 0 }} @@ -30,12 +34,14 @@ Probes selection logic. {{- if $probe.custom -}} {{- $probe.spec | toYaml | nindent 2 }} {{- else }} - {{- "tcpSocket:" | nindent 2 }} - {{- printf "port: %v" $svcPort | nindent 4 }} - {{- printf "initialDelaySeconds: %v" $probe.spec.initialDelaySeconds | nindent 2 }} - {{- printf "failureThreshold: %v" $probe.spec.failureThreshold | nindent 2 }} - {{- printf "timeoutSeconds: %v" $probe.spec.timeoutSeconds | nindent 2 }} - {{- printf "periodSeconds: %v" $probe.spec.periodSeconds | nindent 2 }} + {{- if and $primaryService $primaryPort -}} + {{- "tcpSocket:" | nindent 2 }} + {{- printf "port: %v" $primaryPort.port | nindent 4 }} + {{- printf "initialDelaySeconds: %v" $probe.spec.initialDelaySeconds | nindent 2 }} + {{- printf "failureThreshold: %v" $probe.spec.failureThreshold | nindent 2 }} + {{- printf "timeoutSeconds: %v" $probe.spec.timeoutSeconds | nindent 2 }} + {{- printf "periodSeconds: %v" $probe.spec.periodSeconds | nindent 2 }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/charts/library/common/templates/lib/controller/_volumeMounts.tpl b/charts/library/common/templates/lib/controller/_volumeMounts.tpl index 98dd4af3f42..f0badf21818 100644 --- a/charts/library/common/templates/lib/controller/_volumeMounts.tpl +++ b/charts/library/common/templates/lib/controller/_volumeMounts.tpl @@ -1,17 +1,14 @@ -{{/* -Volumes included by the controller. -*/}} +{{/* Volumes included by the controller */}} {{- define "common.controller.volumeMounts" -}} - -{{- range $index, $PVC := .Values.persistence }} -{{- if $PVC.enabled }} + {{- range $index, $PVC := .Values.persistence }} + {{- if $PVC.enabled }} - mountPath: {{ $PVC.mountPath | default (printf "/%v" $index) }} name: {{ $index }} -{{- if $PVC.subPath }} + {{- if $PVC.subPath }} subPath: {{ $PVC.subPath }} -{{- end }} -{{- end }} -{{- end }} + {{- end }} + {{- end }} + {{- end }} {{/* Creates mountpoints to mount devices directly to the same path inside the container @@ -28,38 +25,32 @@ Creates mountpoints to mount devices directly to the same path inside the contai {{ end }} {{- end -}} {{ end }} + {{- if .Values.additionalVolumeMounts }} + {{- toYaml .Values.additionalVolumeMounts | nindent 0 }} + {{- end }} -{{/* -Creates mountpoints to mount hostPaths directly to the container -*/}} -{{ range $name, $hpm := .Values.hostPathMounts }} -{{- if $hpm.enabled -}} -{{ if $hpm.name }} - {{ $name = $hpm.name }} -{{ end }} -- name: hostpathmounts-{{ $name }} - mountPath: {{ $hpm.mountPath }} - {{ if $hpm.subPath }} - subPath: {{ $hpm.subPath }} - {{ end }} - {{ if $hpm.readOnly }} - readOnly: {{ $hpm.readOnly }} - {{ end }} -{{- end -}} -{{ end }} - -{{- if .Values.additionalVolumeMounts }} -{{- toYaml .Values.additionalVolumeMounts | nindent 0 }} -{{- end }} - -{{- if eq .Values.controllerType "statefulset" }} -{{- range $index, $vct := .Values.volumeClaimTemplates }} + {{- if eq .Values.controller.type "statefulset" }} + {{- range $index, $vct := .Values.volumeClaimTemplates }} - mountPath: {{ $vct.mountPath }} name: {{ $vct.name }} -{{- if $vct.subPath }} + {{- if $vct.subPath }} subPath: {{ $vct.subPath }} -{{- end }} -{{- end }} -{{- end }} + {{- end }} + {{- end }} + {{- end }} + {{/* Creates mountpoints to mount hostPaths directly to the container */}} + {{- range $name, $hpm := .Values.hostPathMounts }} + {{- if $hpm.enabled }} + {{- $name = default $name $hpm.name }} +- name: hostpathmounts-{{ $name }} + mountPath: {{ $hpm.mountPath }} + {{- if $hpm.subPath }} + subPath: {{ $hpm.subPath }} + {{- end }} + {{- if $hpm.readOnly }} + readOnly: {{ $hpm.readOnly }} + {{- end }} + {{- end }} + {{ end }} {{- end -}} diff --git a/charts/library/common/templates/lib/controller/_volumes.tpl b/charts/library/common/templates/lib/controller/_volumes.tpl index ccb602d00d7..f8cd0990c03 100644 --- a/charts/library/common/templates/lib/controller/_volumes.tpl +++ b/charts/library/common/templates/lib/controller/_volumes.tpl @@ -1,22 +1,3 @@ -{{/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -`SPDX-License-Identifier: Apache-2.0` - -This file is considered to be modified by the TrueCharts Project. -*/}} - - {{/* Volumes included by the controller. */}} @@ -52,10 +33,8 @@ Volumes included by the controller. {{- /* Otherwise refer to the PVC name */}} {{- $pvcName := (include "common.names.fullname" $) -}} {{- if $persistence.nameOverride -}} - {{- $pvcName = $persistence.nameOverride -}} - {{- else if $persistence.nameSuffix -}} - {{- if not (eq $persistence.nameSuffix "-") -}} - {{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameSuffix) -}} + {{- if not (eq $persistence.nameOverride "-") -}} + {{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameOverride) -}} {{- end -}} {{- else -}} {{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $index) -}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 0b2c1332d8e..224d9dbc931 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -1,41 +1,89 @@ -# type: options are deployment, daemonset or statefulset -controllerType: deployment -# Set annotations on the deployment/statefulset/daemonset -controllerAnnotations: {} -# Set labels on the deployment/statefulset/daemonset -controllerLabels: {} +global: + # -- Set an override for the prefix of the fullname + nameOverride: + # -- Set the entire name definition + fullnameOverride: -replicas: 1 -strategy: - ## For Deployments, valid values are Recreate and RollingUpdate - ## For StatefulSets, valid values are OnDelete and RollingUpdate - ## DaemonSets ignore this - type: RollingUpdate +controller: + # -- Set the controller type. + # Valid options are deployment, daemonset or statefulset + type: deployment + # -- Set annotations on the deployment/statefulset/daemonset + annotations: {} + # -- Set labels on the deployment/statefulset/daemonset + labels: {} + # -- Number of desired pods + replicas: 1 + # -- Set the controller upgrade strategy + # For Deployments, valid values are Recreate (default) and RollingUpdate. + # For StatefulSets, valid values are OnDelete and RollingUpdate (default). + # DaemonSets ignore this. + strategy: + rollingUpdate: + # -- Set deployment RollingUpdate max unavailable + unavailable: + # -- Set deployment RollingUpdate max surge + surge: + # -- Set statefulset RollingUpdate partition + partition: + # -- ReplicaSet revision history limit + revisionHistoryLimit: 3 -# Override the default command +image: + # -- image repository + repository: + # -- image tag + tag: + # -- image pull policy + pullPolicy: + +# -- Override the command(s) for the default container command: [] -# Override the default args +# -- Override the args for the default container args: [] -nameOverride: "" -fullnameOverride: "" - -# Set annotations on the pod +# -- Set annotations on the pod podAnnotations: {} +# -- Add a Horizontal Pod Autoscaler +# @default -- +autoscaling: + enabled: false + target: # deploymentname + minReplicas: # 1 + maxReplicas: # 100 + targetCPUUtilizationPercentage: # 80 + targetMemoryUtilizationPercentage: # 80 + serviceAccount: - # Specifies whether a service account should be created + # -- Specifies whether a service account should be created create: false - # Annotations to add to the service account + + # -- Annotations to add to the service account annotations: {} - # The name of the service account to use. + + # -- The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: "" +# -- Use this to populate a secret with the values you specify. +# Be aware that these values are not encrypted by default, and could therefore visible +# to anybody with access to the values.yaml file. +secret: {} + # PASSWORD: my-password +# -- Main environment variables. Template enabled. +# Syntax options: +# A) TZ: UTC +# B) PASSWD: '{{ .Release.Name }}' +# C) PASSWD: +# envFrom: +# ... +# D) - name: TZ +# value: UTC +# E) - name: TZ +# value: '{{ .Release.Name }}' env: {} - # TZ: UTC - ## Variables with values set from templates, example ## With a release name of: demo, the example env value will be: demo-admin envTpl: {} @@ -53,170 +101,274 @@ envFrom: [] # name: config-map-name # - secretRef: # name: secret-name +# -- Custom priority class for different treatment by the scheduler +priorityClassName: # system-node-critical -# Custom priority class for different treatment by the scheduler -# priorityClassName: system-node-critical +# -- Allows specifying a custom scheduler name +schedulerName: # awkward-dangerous-scheduler -# Allow specifying a custom scheduler name -# schedulerName: awkward-dangerous-scheduler +# -- Allows specifying explicit hostname setting +hostname: -# Allow specifying explicit hostname setting -# hostname: - -# When using hostNetwork make sure you set dnsPolicy to ClusterFirstWithHostNet +# -- When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` hostNetwork: false -## Default get based on hostNetwork setting -# dnsPolicy: ClusterFirst +# -- Defaults to "ClusterFirst" if hostNetwork is false and "ClusterFirstWithHostNet" if hostNetwork is true. +dnsPolicy: # ClusterFirst -# Optional DNS settings, configuring the ndots option may resolve -# nslookup issues on some Kubernetes setups. -# dnsConfig: +# -- Optional DNS settings, configuring the ndots option may resolve nslookup issues on some Kubernetes setups. +dnsConfig: {} # options: # - name: ndots # value: "1" -# Enable/disable the generation of environment variables for services. -# See https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service -# for more information. +# -- Enable/disable the generation of environment variables for services. +# [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) enableServiceLinks: true -# Configure the Security Context for the Pod -# podSecurityContext: -# runAsNonRoot: true -# runAsUser: 568 -# runAsGroup: 568 -# fsGroup: 568 -# fsGroupChangePolicy: "OnRootMismatch" +# -- Configure the Security Context for the Pod +podSecurityContext: {} -# Configure the Security Context for the main container +# -- Configure the Security Context for the main container securityContext: {} +# -- Configure the lifecycle for the main container +lifecycle: {} +# -- Specify any initContainers here. Yaml will be passed in to the Pod as-is. initContainers: [] +# -- Specify any additional containers here. Yaml will be passed in to the Pod as-is. additionalContainers: [] -## Probes configuration +# -- Probe configuration +# -- [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) +# @default -- See below probes: + # -- Liveness probe configuration + # @default -- See below liveness: + # -- Enable the liveness probe enabled: true - ## Set this to true if you wish to specify your own livenessProbe + # -- Set this to `true` if you wish to specify your own livenessProbe custom: false - ## The spec field contains the values for the default livenessProbe. - ## If you selected custom: true, this field holds the definition of the livenessProbe. + # -- The spec field contains the values for the default livenessProbe. + # If you selected `custom: true`, this field holds the definition of the livenessProbe. + # @default -- See below spec: initialDelaySeconds: 0 periodSeconds: 10 - timeoutSeconds: 10 - failureThreshold: 5 + timeoutSeconds: 1 + failureThreshold: 3 + # -- Redainess probe configuration + # @default -- See below readiness: + # -- Enable the readiness probe enabled: true - ## Set this to true if you wish to specify your own readinessProbe + # -- Set this to `true` if you wish to specify your own readinessProbe custom: false - ## The spec field contains the values for the default readinessProbe. - ## If you selected custom: true, this field holds the definition of the readinessProbe. + # -- The spec field contains the values for the default readinessProbe. + # If you selected `custom: true`, this field holds the definition of the readinessProbe. + # @default -- See below spec: initialDelaySeconds: 0 periodSeconds: 10 - timeoutSeconds: 10 - failureThreshold: 5 + timeoutSeconds: 1 + failureThreshold: 3 + # -- Startup probe configuration + # @default -- See below startup: + # -- Enable the startup probe enabled: true - ## Set this to true if you wish to specify your own startupProbe + # -- Set this to `true` if you wish to specify your own startupProbe custom: false - ## The spec field contains the values for the default startupProbe. - ## If you selected custom: true, this field holds the definition of the startupProbe. + # -- The spec field contains the values for the default startupProbe. + # If you selected `custom: true`, this field holds the definition of the startupProbe. + # @default -- See below spec: initialDelaySeconds: 0 - timeoutSeconds: 10 + timeoutSeconds: 1 ## This means it has a maximum of 5*30=150 seconds to start up before it fails - periodSeconds: 10 + periodSeconds: 5 failureThreshold: 30 -services: +# -- Configure the services for the chart here. +# Additional services can be added by adding a dictionary key similar to the 'main' service. +# @default -- See below +service: main: + # -- Enables or disables the service enabled: true - type: ClusterIP - ## Specify the default port information - ## It is adviced not to mix different port protocols on the same service - port: - port: - ## name defaults to http - name: - ## Accepts: HTTP, HTTPS, TCP and UDP - ## HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation - protocol: HTTP - ## Specify a service targetPort if you wish to differ the service port from the application port. - ## If targetPort is specified, this port number is used in the container definition instead of - ## service.port.port. Therefore named ports are not supported for this field. - targetPort: - ## Specify the nodePort value for the LoadBalancer and NodePort service types. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport - ## - # nodePort: - additionalPorts: [] - ## Provide any additional annotations which may be required. This can be used to - ## set the LoadBalancer service type to internal only. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer - ## + # -- Make this the primary service (used in probes, notes, etc...). + # If there is more than 1 service, make sure that only 1 service is marked as primary. + primary: true + + # -- Override the name suffix that is used for this service + nameOverride: + + # -- Set the service type + type: ClusterIP + + # -- Provide additional annotations which may be required. annotations: {} + + # -- Provide additional labels which may be required. labels: {} - ## additionalServices can be created as either a dict. - # additionalService: - # type: ClusterIP - # # Specify the default port information - # port: - # port: - # # name defaults to http - # name: - # protocol: TCP - # # targetPort defaults to http - # targetPort: - # # nodePort: - # additionalPorts: [] - # annotations: {} - # labels: {} + # -- Configure the Service port information here. + # Additional ports can be added by adding a dictionary key similar to the 'http' service. + # @default -- See below + ports: + http: + # -- Enables or disables the port + enabled: true -persistence: - config: + # -- Make this the primary port (used in probes, notes, etc...) + # If there is more than 1 service, make sure that only 1 port is marked as primary. + primary: true + + # -- The port number + port: + + # -- Port protocol. + # Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. + # HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation + protocol: HTTP + + # -- Specify a service targetPort if you wish to differ the service port from the application port. + # If `targetPort` is specified, this port number is used in the container definition instead of + # the `port` value. Therefore named ports are not supported for this field. + targetPort: + + # -- Specify the nodePort value for the LoadBalancer and NodePort service types. + # [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) + nodePort: + +# -- Configure the ingresses for the chart here. +# Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. +# @default -- See below +ingress: + main: + # -- Enables or disables the ingress enabled: false + + # -- Make this the primary ingress (used in probes, notes, etc...). + # If there is more than 1 ingress, make sure that only 1 ingress is marked as primary. + primary: true + + # -- Override the name suffix that is used for this ingress. + nameOverride: + + # -- Provide additional annotations which may be required. + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + + # -- Provide additional labels which may be required. + labels: {} + + # -- Set the ingressClass that is used for this ingress. + # Requires Kubernetes >=1.19 + ingressClassName: # "nginx" + + ## Configure the hosts for the ingress + hosts: + - # -- Host address. Helm template can be passed. + host: chart-example.local + ## Configure the paths for the host + paths: + - # -- Path. Helm template can be passed. + path: / + # -- Ignored if not kubeVersion >= 1.14-0 + pathType: Prefix + service: + # -- Overrides the service name reference for this path + name: + # -- Overrides the service port reference for this path + port: + + # -- Configure TLS for the ingress. Both secretName and hosts can process a Helm template. + tls: [] + # - secretName: chart-example-tls + # -- Create a secret from a GUI selected TrueNAS SCALE certificate + # scaleCert: true + # hosts: + # - chart-example.local + +# -- Configure the persistent volumes for the chart here. +# Additional items can be added by adding a dictionary key similar to the 'config' key. +# @default -- See below +persistence: + # -- Default persistence for configuration files. + # @default -- See below + config: + # -- Enables or disables the persistent volume + enabled: false + + # -- Where to mount the volume in the main container. mountPath: /config - ## configuration data Persistent Volume Storage Class - ## If defined, storageClassName: - ## If set to "-", storageClassName: "", which disables dynamic provisioning - ## If undefined (the default) or set to null, no storageClassName spec is - ## set, choosing the default provisioner. (gp2 on AWS, standard on - ## GKE, AWS & OpenStack) - ## - # storageClass: "-" - ## - ## If you want to reuse an existing claim, you can pass the name of the PVC using - ## the existingClaim variable - # existingClaim: your-claim - # subPath: some-subpath + + # -- Override the name suffix that is used for this volume. + nameOverride: + + emptyDir: + # -- Create an emptyDir volume instead of a persistent volume. + # [[ref]] (https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) + enabled: false + + # -- Storage Class for the config volume. + # If set to `-`, dynamic provisioning is disabled. + # If set to `SCALE-ZFS`, the default provisioner for TrueNAS SCALE is used. + # If set to something else, the given storageClass is used. + # If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. + storageClass: # "-" + + # -- If you want to reuse an existing claim, the name of the existing PVC can be passed here. + existingClaim: # your-claim + + # -- Used in conjunction with `existingClaim`. Specifies a sub-path inside the referenced volume instead of its root + subPath: # some-subpath + + # -- AccessMode for the persistent volume. + # Make sure to select an access mode that is supported by your storage provider! + # [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) accessMode: ReadWriteOnce + + # -- The amount of storage that is requested for the persistent volume. size: 1Gi - ## Set to true to retain the PVC upon helm uninstall + + # - Set to true to retain the PVC upon `helm uninstall` skipuninstall: false - # Create an emptyDir volume to share between all containers shared: + # -- Create an emptyDir volume to share between all containers enabled: false emptyDir: enabled: true + # -- Where to mount the shared volume in the main container. mountPath: /shared +# -- Mount a path on the host to the main container. +hostPathMounts: [] + # - name: "data" + # enabled: false + # emptyDir: false + # mountPath: "/data" + # subPath: some-subpath + # hostPath: "" + # readOnly: false + +# -- Specify any additional volumes here. (e.g. to mount nfs volumes directly) additionalVolumes: [] +# -- Specify any additional volume mounts for the main container here. additionalVolumeMounts: [] +# -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. volumeClaimTemplates: [] -# Used in statefulset to create individual disks for each instance # - name: data # mountPath: /data # accessMode: "ReadWriteOnce" @@ -228,107 +380,271 @@ volumeClaimTemplates: [] # size: 2Gi # storageClass: cheap-storage-class +# -- Node selection constraint +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) nodeSelector: {} +# -- Defines affinity constraint rules. +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) affinity: {} +# -- Specify taint tolerations +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) tolerations: [] +# -- Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. +# [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) hostAliases: [] -# Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. -# ref: https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/ # - ip: "192.168.1.100" # hostnames: # - "example.com" # - "www.example.com" +# -- Set the resource requests / limits for the main container. resources: {} -# We usually recommend not to specify default resources and to leave this as a conscious -# choice for the user. This also increases chances charts run on environments with little -# resources, such as Minikube. If you do want to specify resources, uncomment the following -# lines, adjust them as necessary, and remove the curly braces after 'resources:'. -# limits: -# cpu: 100m -# memory: 128Mi -# requests: -# cpu: 100m -# memory: 128Mi + ## We usually recommend not to specify default resources and to leave this as a conscious + ## choice for the user. This also increases chances charts run on environments with little + ## resources, such as Minikube. If you do want to specify resources, uncomment the following + ## lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi -## Used by TrueNAS SCALE to easily set add GPU's to Apps -# scaleGPU: {} +# -- The common chart supports several add-ons. These can be configured under this key. +# @default -- See below +addons: -## TrueCharts Specific - -# deviceMounts: -# config: -# enabled: false -# emptyDir: false -# hostPath: "/config" -# setPermissions: true - -# customStorage: -# - name: "data" -# enabled: false -# emptyDir: false -# mountPath: "/data" -# subPath: some-subpath -# hostPath: "" -# readOnly: false -# setPermissions: true - -ingress: - main: + # -- The common chart supports adding a VPN add-on. It can be configured under this key. + # For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#wireguard-vpn) + # @default -- See values.yaml + vpn: + # -- Enable running a VPN in the pod to route traffic through a VPN enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - labels: {} - # ingressClassName: "nginx" - hosts: - - host: chart-example.local - ## Or a tpl that is evaluated - # hostTpl: '{{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.{{ .Values.ingress.domainname }}' - paths: - - path: / - ## Or a tpl that is evaluated - # pathTpl: '{{ include "common.names.fullname" . }}' - ## Ignored if not kubeVersion >= 1.14-0 - pathType: Prefix - tls: [] - # - secretName: chart-example-tls - ## Or if you need a dynamic secretname - # - secretNameTpl: '{{ include "common.names.fullname" . }}-ingress' - # hosts: - # - chart-example.local - ## Or a tpl that is evaluated - # hostsTpl: - # - '{{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.{{ .Values.ingress.domainname }}' - # additionalIngress: - # annotations: {} - # # kubernetes.io/ingress.class: nginx - # # kubernetes.io/tls-acme: "true" - # labels: {} - # hosts: - # - host: chart-example.local - # paths: - # - path: /api - # # Ignored if not kubeVersion >= 1.14-0 - # pathType: Prefix - # serviceName: # optionally target a specific service - # servicePort: # optionally target a specific service port - # tls: [] - # # - secretName: chart-example-tls - # # hosts: - # # - chart-example.local -# ## Adds a portal configmap for use with TrueNAS SCALE -# ## This should not be enabled on other systems than TrueNAS SCALE, -# ## Because it requires a seperate namespace for each chart. -# portal: -# enabled: false -# ## Override default port used for the portal button when using ingress. -# # ingressPort: 80 -# ## Override hostname used for the portal button when using nodePort -# # host: 192.168.0.2 -# ## Override the path used in the url -# # path: /example + # -- Specify the VPN type. Valid options are openvpn or wireguard + type: openvpn + + # -- OpenVPN specific configuration + # @default -- See below + openvpn: + image: + # -- Specify the openvpn client image + repository: dperson/openvpn-client + # -- Specify the openvpn client image tag + tag: latest + # -- Specify the openvpn client image pull policy + pullPolicy: IfNotPresent + + # -- Credentials to connect to the VPN Service (used with -a) + auth: # "user;password" + # -- Optionally specify an existing secret that contains the credentials. + # Credentials should be stored under the `VPN_AUTH` key + authSecret: # my-vpn-secret + + # -- WireGuard specific configuration + # @default -- See below + wireguard: + image: + # -- Specify the WireGuard image + repository: docker pull ghcr.io/k8s-at-home/wireguard + # -- Specify the WireGuard image tag + tag: v1.0.20210424 + # -- Specify the WireGuard image pull policy + pullPolicy: IfNotPresent + + # -- Set the VPN container securityContext + # @default -- See values.yaml + securityContext: + capabilities: + add: + - NET_ADMIN + - SYS_MODULE + + # -- All variables specified here will be added to the vpn sidecar container + # See the documentation of the VPN image for all config values + env: {} + # TZ: UTC + + # -- Provide a customized vpn configuration file to be used by the VPN. + configFile: # |- + # Some Example Config + # remote greatvpnhost.com 8888 + # auth-user-pass + # Cipher AES + + # -- Reference an existing secret that contains the VPN configuration file + # The chart expects it to be present under the `vpnConfigfile` key. + configFileSecret: + + # -- Provide custom up/down scripts that can be used by the vpn configuration. + # @default -- See values.yaml + scripts: + up: # |- + # #!/bin/bash + # echo "connected" > /shared/vpnstatus + down: # |- + # #!/bin/bash + # echo "disconnected" > /shared/vpnstatus + + additionalVolumeMounts: [] + + # -- Optionally specify a livenessProbe, e.g. to check if the connection is still + # being protected by the VPN + livenessProbe: {} + # exec: + # command: + # - sh + # - -c + # - if [ $(curl -s https://ipinfo.io/country) == 'US' ]; then exit 0; else exit $?; fi + # initialDelaySeconds: 30 + # periodSeconds: 60 + # failureThreshold: 1 + + # If set to true, will deploy a network policy that blocks all outbound + # traffic except traffic specified as allowed + networkPolicy: + enabled: false + + # The egress configuration for your network policy, All outbound traffic + # From the pod will be blocked unless specified here. Your cluster must + # have a CNI that supports network policies (Canal, Calico, etc...) + # https://kubernetes.io/docs/concepts/services-networking/network-policies/ + # https://github.com/ahmetb/kubernetes-network-policy-recipes + egress: + # - to: + # - ipBlock: + # cidr: 0.0.0.0/0 + # ports: + # - port: 53 + # protocol: UDP + # - port: 53 + # protocol: TCP + + # -- The common library supports adding a code-server add-on to access files. It can be configured under this key. + # For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#code-server) + # @default -- See values.yaml + codeserver: + # -- Enable running a code-server container in the pod + enabled: false + + image: + # -- Specify the code-server image + repository: codercom/code-server + # -- Specify the code-server image tag + tag: 3.9.2 + # -- Specify the code-server image pull policy + pullPolicy: IfNotPresent + + # -- Set any environment variables for code-server here + env: {} + # TZ: UTC + + # -- Set codeserver command line arguments. + # Consider setting --user-data-dir to a persistent location to preserve code-server setting changes + args: + - --auth + - none + # - --user-data-dir + # - "/config/.vscode" + + # -- Specify a list of volumes that get mounted in the code-server container. + # At least 1 volumeMount is required! + volumeMounts: [] + # - name: config + # mountPath: /data/config + + # -- Specify the working dir that will be opened when code-server starts + # If not given, the app will default to the mountpah of the first specified volumeMount + workingDir: "" + + # -- Optionally allow access a Git repository by passing in a private SSH key + # @default -- See below + git: + # -- Raw SSH private key + deployKey: "" + # -- Base64-encoded SSH private key. When both variables are set, the raw SSH key takes precedence. + deployKeyBase64: "" + # -- Existing secret containing SSH private key + # The chart expects it to be present under the `id_rsa` key. + deployKeySecret: "" + + service: + # -- Enable a service for the code-server add-on. + enabled: true + type: ClusterIP + # Specify the default port information + ports: + codeserver: + port: 12321 + enabled: true + protocol: TCP + targetPort: codeserver + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + # nodePort: + annotations: {} + labels: {} + + ingress: + # -- Enable an ingress for the code-server add-on. + enabled: false + nameOverride: codeserver + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + labels: {} + hosts: + - host: code.chart-example.local + paths: + - path: / + # Ignored if not kubeVersion >= 1.14-0 + pathType: Prefix + tls: [] + # - secretName: chart-example-tls + # hosts: + # - code.chart-example.local + + securityContext: + runAsUser: 0 + + # -- The common library supports adding a promtail add-on to to access logs and ship them to loki. It can be configured under this key. + # @default -- See values.yaml + promtail: + # -- Enable running a promtail container in the pod + enabled: false + + image: + # -- Specify the promtail image + repository: grafana/promtail + # -- Specify the promtail image tag + tag: 2.2.0 + # -- Specify the promtail image pull policy + pullPolicy: IfNotPresent + + # -- Set any environment variables for promtail here + env: {} + + # -- Set promtail command line arguments + args: [] + + # -- The URL to Loki + loki: "" + + # -- The paths to logs on the volume + logs: [] + # - name: log + # path: /config/logs/*.log + + # -- Specify a list of volumes that get mounted in the promtail container. + # At least 1 volumeMount is required! + volumeMounts: [] + # - name: config + # mountPath: /config + # readOnly: true + + securityContext: + runAsUser: 0