mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47:04 +02:00
feat(common): Release v2.5.0 (#258)
Co-authored-by: Maurits <75321636+maurits-funda@users.noreply.github.com> Co-authored-by: Noam Lerner <bugok@users.noreply.github.com>
This commit is contained in:
parent
1582fe27c4
commit
a548690b00
25 changed files with 670 additions and 56 deletions
|
@ -32,6 +32,9 @@ metadata:
|
|||
annotations: {{- toYaml . | nindent 4 -}}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with $cronjobObject.cronjob.suspend }}
|
||||
suspend: {{ ternary "true" "false" . }}
|
||||
{{- end }}
|
||||
concurrencyPolicy: "{{ $cronjobObject.cronjob.concurrencyPolicy }}"
|
||||
startingDeadlineSeconds: {{ $cronjobObject.cronjob.startingDeadlineSeconds }}
|
||||
{{- with $timeZone }}
|
||||
|
|
46
charts/library/common/templates/classes/_job.tpl
Normal file
46
charts/library/common/templates/classes/_job.tpl
Normal file
|
@ -0,0 +1,46 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the job objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.job" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $jobObject := .object -}}
|
||||
|
||||
{{- $labels := merge
|
||||
(dict "app.kubernetes.io/component" $jobObject.identifier)
|
||||
($jobObject.labels | default dict)
|
||||
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
|
||||
-}}
|
||||
{{- $annotations := merge
|
||||
($jobObject.annotations | default dict)
|
||||
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml)
|
||||
-}}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ $jobObject.name }}
|
||||
{{- with $labels }}
|
||||
labels: {{- toYaml . | nindent 4 -}}
|
||||
{{- end }}
|
||||
{{- with $annotations }}
|
||||
annotations: {{- toYaml . | nindent 4 -}}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with $jobObject.job.suspend }}
|
||||
suspend: {{ ternary "true" "false" . }}
|
||||
{{- end }}
|
||||
{{- with $jobObject.job.ttlSecondsAfterFinished }}
|
||||
ttlSecondsAfterFinished: {{ . }}
|
||||
{{- end }}
|
||||
backoffLimit: {{ $jobObject.job.backoffLimit }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $jobObject)) }}
|
||||
annotations: {{ . | nindent 8 }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $jobObject)) }}
|
||||
labels: {{ . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $jobObject) | nindent 6 }}
|
||||
{{- end -}}
|
|
@ -30,4 +30,8 @@ spec:
|
|||
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
|
||||
{{- end }}
|
||||
endpoints: {{- toYaml $serviceMonitorObject.endpoints | nindent 4 }}
|
||||
{{- if not (empty $serviceMonitorObject.targetLabels )}}
|
||||
targetLabels:
|
||||
{{- toYaml $serviceMonitorObject.targetLabels | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{{/*
|
||||
Return a configMap Object by its Identifier.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.configMap.getByIdentifier" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- $configMapValues := dig $identifier nil $rootContext.Values.configMaps -}}
|
||||
{{- if not (empty $configMapValues) -}}
|
||||
{{- include "bjw-s.common.lib.configMap.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $configMapValues) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -36,8 +36,8 @@ terminationMessagePolicy: {{ . | trim }}
|
|||
{{- with (include "bjw-s.common.lib.container.field.env" (dict "ctx" $ctx) | trim) }}
|
||||
env: {{ . | trim | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with $containerObject.envFrom }}
|
||||
envFrom: {{ toYaml . | trim | nindent 2 }}
|
||||
{{- with (include "bjw-s.common.lib.container.field.envFrom" (dict "ctx" $ctx) | trim) }}
|
||||
envFrom: {{ . | trim | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with $containerObject.ports }}
|
||||
ports: {{ toYaml . | trim | nindent 2 }}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
{{/*
|
||||
Env field used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.envFrom" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- if not (empty (get $containerObject "envFrom")) -}}
|
||||
{{- $envFrom := list -}}
|
||||
{{- range $containerObject.envFrom -}}
|
||||
{{- $item := dict -}}
|
||||
|
||||
{{- if hasKey . "configMap" -}}
|
||||
{{- $configMap := include "bjw-s.common.lib.configMap.getByIdentifier" (dict "rootContext" $rootContext "id" .configMap) | fromYaml -}}
|
||||
{{- $configMapName := default (tpl .configMap $rootContext) $configMap.name -}}
|
||||
{{- $_ := set $item "configMapRef" (dict "name" $configMapName) -}}
|
||||
{{- else if hasKey . "configMapRef" -}}
|
||||
{{- if not (empty (dig "identifier" nil .configMapRef)) -}}
|
||||
{{- $configMap := include "bjw-s.common.lib.configMap.getByIdentifier" (dict "rootContext" $rootContext "id" .configMapRef.identifier) | fromYaml -}}
|
||||
{{- if empty $configMap -}}
|
||||
{{- fail (printf "No configMap configured with identifier '%s'" .configMapRef.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $item "configMapRef" (dict "name" $configMap.name) -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set $item "configMapRef" (dict "name" (tpl .configMapRef.name $rootContext)) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- else if hasKey . "secret" -}}
|
||||
{{- $secret := include "bjw-s.common.lib.secret.getByIdentifier" (dict "rootContext" $rootContext "id" .secret) | fromYaml -}}
|
||||
{{- $secretName := default (tpl .secret $rootContext) $secret.name -}}
|
||||
{{- $_ := set $item "secretRef" (dict "name" $secretName) -}}
|
||||
{{- else if hasKey . "secretRef" -}}
|
||||
{{- if not (empty (dig "identifier" nil .secretRef)) -}}
|
||||
{{- $secret := include "bjw-s.common.lib.secret.getByIdentifier" (dict "rootContext" $rootContext "id" .secretRef.identifier) | fromYaml -}}
|
||||
{{- if empty $secret -}}
|
||||
{{- fail (printf "No secret configured with identifier '%s'" .secretRef.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $item "secretRef" (dict "name" $secret.name) -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set $item "secretRef" (dict "name" (tpl .secretRef.name $rootContext)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty (dig "prefix" nil .)) -}}
|
||||
{{- $_ := set $item "prefix" .prefix -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $item) -}}
|
||||
{{- $envFrom = append $envFrom $item -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $envFrom | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -91,6 +91,12 @@ volumeMounts used by the container.
|
|||
{{- $_ := set $volumeMount "readOnly" $readOnly -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Use the specified mountPropagation setting if provided */ -}}
|
||||
{{- with .mountPropagation -}}
|
||||
{{- $mountPropagation := . -}}
|
||||
{{- $_ := set $volumeMount "mountPropagation" $mountPropagation -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}}
|
||||
{{- end -}}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Validate controller values
|
|||
{{- $rootContext := .rootContext -}}
|
||||
{{- $controllerValues := .object -}}
|
||||
|
||||
{{- $allowedControllerTypes := list "deployment" "daemonset" "statefulset" "cronjob" -}}
|
||||
{{- $allowedControllerTypes := list "deployment" "daemonset" "statefulset" "cronjob" "job" -}}
|
||||
{{- if not (has $controllerValues.type $allowedControllerTypes) -}}
|
||||
{{- fail (printf "Not a valid controller.type (%s)" $controllerValues.type) -}}
|
||||
{{- end -}}
|
||||
|
|
12
charts/library/common/templates/lib/job/_validate.tpl
Normal file
12
charts/library/common/templates/lib/job/_validate.tpl
Normal file
|
@ -0,0 +1,12 @@
|
|||
{{/*
|
||||
Validate job values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.job.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $jobValues := .object -}}
|
||||
|
||||
{{- $allowedRestartPolicy := list "Never" "OnFailure" -}}
|
||||
{{- if not (has $jobValues.pod.restartPolicy $allowedRestartPolicy) -}}
|
||||
{{- fail (printf "Not a valid restart policy for Job (controller: %s, strategy: %s)" $jobValues.identifier $jobValues.pod.restartPolicy) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
14
charts/library/common/templates/lib/job/_valuesToObject.tpl
Normal file
14
charts/library/common/templates/lib/job/_valuesToObject.tpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
{{/*
|
||||
Convert job values to an object
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.job.valuesToObject" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
{{- $objectValues := .values -}}
|
||||
|
||||
{{- $restartPolicy := default "Never" $objectValues.pod.restartPolicy -}}
|
||||
{{- $_ := set $objectValues.pod "restartPolicy" $restartPolicy -}}
|
||||
|
||||
{{- /* Return the Job object */ -}}
|
||||
{{- $objectValues | toYaml -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,12 @@
|
|||
{{/*
|
||||
Return a secret Object by its Identifier.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.secret.getByIdentifier" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- $secretValues := dig $identifier nil $rootContext.Values.secrets -}}
|
||||
{{- if not (empty $secretValues) -}}
|
||||
{{- include "bjw-s.common.lib.secret.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $secretValues) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -35,6 +35,10 @@ Renders the controller objects required by the chart.
|
|||
{{- $statefulsetObject := (include "bjw-s.common.lib.statefulset.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}}
|
||||
{{- include "bjw-s.common.lib.statefulset.validate" (dict "rootContext" $ "object" $statefulsetObject) -}}
|
||||
{{- include "bjw-s.common.class.statefulset" (dict "rootContext" $ "object" $statefulsetObject) | nindent 0 -}}
|
||||
{{- else if eq $controllerObject.type "job" -}}
|
||||
{{- $jobObject := (include "bjw-s.common.lib.job.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}}
|
||||
{{- include "bjw-s.common.lib.job.validate" (dict "rootContext" $ "object" $jobObject) -}}
|
||||
{{- include "bjw-s.common.class.job" (dict "rootContext" $ "object" $jobObject) | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -4,7 +4,13 @@ Renders the Persistent Volume Claim objects required by the chart.
|
|||
{{- define "bjw-s.common.render.pvcs" -}}
|
||||
{{- /* Generate pvc as required */ -}}
|
||||
{{- range $key, $pvc := .Values.persistence -}}
|
||||
{{- if and $pvc.enabled (eq (default "persistentVolumeClaim" $pvc.type) "persistentVolumeClaim") (not $pvc.existingClaim) -}}
|
||||
{{- /* Enable PVC by default, but allow override */ -}}
|
||||
{{- $pvcEnabled := true -}}
|
||||
{{- if hasKey $pvc "enabled" -}}
|
||||
{{- $pvcEnabled = $pvc.enabled -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $pvcEnabled (eq (default "persistentVolumeClaim" $pvc.type) "persistentVolumeClaim") (not $pvc.existingClaim) -}}
|
||||
{{- $pvcValues := (mustDeepCopy $pvc) -}}
|
||||
|
||||
{{- /* Create object from the raw PVC values */ -}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue