mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 16:37:04 +02:00
Copy over kah library
This commit is contained in:
parent
c922af6065
commit
61626834fe
57 changed files with 3583 additions and 0 deletions
|
@ -0,0 +1,84 @@
|
|||
{{- /* The main container included in the controller */ -}}
|
||||
{{- define "common.controller.mainContainer" -}}
|
||||
- name: {{ include "common.names.fullname" . }}
|
||||
image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
{{- with .Values.command }}
|
||||
command:
|
||||
{{- if kindIs "string" . }}
|
||||
- {{ . }}
|
||||
{{- else }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.args }}
|
||||
args:
|
||||
{{- if kindIs "string" . }}
|
||||
- {{ . }}
|
||||
{{- else }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.lifecycle }}
|
||||
lifecycle:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.termination.messagePath }}
|
||||
terminationMessagePath: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.termination.messagePolicy }}
|
||||
terminationMessagePolicy: {{ . }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Values.env }}
|
||||
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 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.secret }}
|
||||
- secretRef:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- include "common.controller.ports" . | trim | nindent 4 }}
|
||||
{{- with (include "common.controller.volumeMounts" . | trim) }}
|
||||
volumeMounts:
|
||||
{{- nindent 4 . }}
|
||||
{{- end }}
|
||||
{{- include "common.controller.probes" . | trim | nindent 2 }}
|
||||
{{- with .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
93
charts/library/common/templates/lib/controller/_pod.tpl
Normal file
93
charts/library/common/templates/lib/controller/_pod.tpl
Normal file
|
@ -0,0 +1,93 @@
|
|||
{{- /*
|
||||
The pod definition included in the controller.
|
||||
*/ -}}
|
||||
{{- define "common.controller.pod" -}}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "common.names.serviceAccountName" . }}
|
||||
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.priorityClassName }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.runtimeClassName }}
|
||||
runtimeClassName: {{ . }}
|
||||
{{- 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.termination.gracePeriodSeconds }}
|
||||
terminationGracePeriodSeconds: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.initContainers }}
|
||||
initContainers:
|
||||
{{- $initContainers := list }}
|
||||
{{- range $index, $key := (keys .Values.initContainers | uniq | sortAlpha) }}
|
||||
{{- $container := get $.Values.initContainers $key }}
|
||||
{{- if not $container.name -}}
|
||||
{{- $_ := set $container "name" $key }}
|
||||
{{- end }}
|
||||
{{- $initContainers = append $initContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $initContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
{{- include "common.controller.mainContainer" . | nindent 2 }}
|
||||
{{- with .Values.additionalContainers }}
|
||||
{{- $additionalContainers := list }}
|
||||
{{- range $name, $container := . }}
|
||||
{{- if not $container.name -}}
|
||||
{{- $_ := set $container "name" $name }}
|
||||
{{- end }}
|
||||
{{- $additionalContainers = append $additionalContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $additionalContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with (include "common.controller.volumes" . | trim) }}
|
||||
volumes:
|
||||
{{- nindent 2 . }}
|
||||
{{- end }}
|
||||
{{- with .Values.hostAliases }}
|
||||
hostAliases:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.topologySpreadConstraints }}
|
||||
topologySpreadConstraints:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
36
charts/library/common/templates/lib/controller/_ports.tpl
Normal file
36
charts/library/common/templates/lib/controller/_ports.tpl
Normal file
|
@ -0,0 +1,36 @@
|
|||
{{/*
|
||||
Ports included by the controller.
|
||||
*/}}
|
||||
{{- define "common.controller.ports" -}}
|
||||
{{- $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 -}}
|
||||
{{- range $_ := $ports }}
|
||||
{{- 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 }}
|
||||
{{- 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 -}}
|
33
charts/library/common/templates/lib/controller/_probes.tpl
Normal file
33
charts/library/common/templates/lib/controller/_probes.tpl
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{/*
|
||||
Probes selection logic.
|
||||
*/}}
|
||||
{{- define "common.controller.probes" -}}
|
||||
{{- $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 }}
|
||||
{{- $probeName }}Probe:
|
||||
{{- if $probe.custom -}}
|
||||
{{- $probe.spec | toYaml | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- if and $primaryService $primaryPort -}}
|
||||
{{- "tcpSocket:" | nindent 2 }}
|
||||
{{- if $primaryPort.targetPort }}
|
||||
{{- printf "port: %v" $primaryPort.targetPort | nindent 4 }}
|
||||
{{- else}}
|
||||
{{- printf "port: %v" $primaryPort.port | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- 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 }}
|
||||
{{- end }}
|
|
@ -0,0 +1,56 @@
|
|||
{{/* Volumes included by the controller */}}
|
||||
{{- define "common.controller.volumeMounts" -}}
|
||||
{{- range $persistenceIndex, $persistenceItem := .Values.persistence }}
|
||||
{{- if $persistenceItem.enabled -}}
|
||||
{{- if kindIs "slice" $persistenceItem.subPath -}}
|
||||
{{- if $persistenceItem.mountPath -}}
|
||||
{{- fail (printf "Cannot use persistence.mountPath with a subPath list (%s)" $persistenceIndex) }}
|
||||
{{- end -}}
|
||||
{{- range $subPathIndex, $subPathItem := $persistenceItem.subPath }}
|
||||
- name: {{ $persistenceIndex }}
|
||||
subPath: {{ required "subPaths as a list of maps require a path field" $subPathItem.path }}
|
||||
mountPath: {{ required "subPaths as a list of maps require an explicit mountPath field" $subPathItem.mountPath }}
|
||||
{{- with $subPathItem.readOnly }}
|
||||
readOnly: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $subPathItem.mountPropagation }}
|
||||
mountPropagation: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* Set the default mountPath to /<name_of_the_peristence_item> */}}
|
||||
{{- $mountPath := (printf "/%v" $persistenceIndex) -}}
|
||||
{{- if eq "hostPath" (default "pvc" $persistenceItem.type) -}}
|
||||
{{- $mountPath = $persistenceItem.hostPath -}}
|
||||
{{- end -}}
|
||||
{{/* Use the specified mountPath if provided */}}
|
||||
{{- with $persistenceItem.mountPath -}}
|
||||
{{- $mountPath = . -}}
|
||||
{{- end }}
|
||||
{{- if ne $mountPath "-" }}
|
||||
- name: {{ $persistenceIndex }}
|
||||
mountPath: {{ $mountPath }}
|
||||
{{- with $persistenceItem.subPath }}
|
||||
subPath: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $persistenceItem.readOnly }}
|
||||
readOnly: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $persistenceItem.mountPropagation }}
|
||||
mountPropagation: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- if eq .Values.controller.type "statefulset" }}
|
||||
{{- range $index, $vct := .Values.volumeClaimTemplates }}
|
||||
- mountPath: {{ $vct.mountPath }}
|
||||
name: {{ $vct.name }}
|
||||
{{- if $vct.subPath }}
|
||||
subPath: {{ $vct.subPath }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
68
charts/library/common/templates/lib/controller/_volumes.tpl
Normal file
68
charts/library/common/templates/lib/controller/_volumes.tpl
Normal file
|
@ -0,0 +1,68 @@
|
|||
{{/*
|
||||
Volumes included by the controller.
|
||||
*/}}
|
||||
{{- define "common.controller.volumes" -}}
|
||||
{{- range $index, $persistence := .Values.persistence }}
|
||||
{{- if $persistence.enabled }}
|
||||
- name: {{ $index }}
|
||||
{{- if eq (default "pvc" $persistence.type) "pvc" }}
|
||||
{{- $pvcName := (include "common.names.fullname" $) -}}
|
||||
{{- if $persistence.existingClaim }}
|
||||
{{- /* Always prefer an existingClaim if that is set */}}
|
||||
{{- $pvcName = $persistence.existingClaim -}}
|
||||
{{- else -}}
|
||||
{{- /* Otherwise refer to the PVC name */}}
|
||||
{{- if $persistence.nameOverride -}}
|
||||
{{- 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) -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ $pvcName }}
|
||||
{{- else if or (eq $persistence.type "configMap") (eq $persistence.type "secret") }}
|
||||
{{- $objectName := (required (printf "name not set for persistence item %s" $index) $persistence.name) }}
|
||||
{{- $objectName = tpl $objectName $ }}
|
||||
{{- if eq $persistence.type "configMap" }}
|
||||
configMap:
|
||||
name: {{ $objectName }}
|
||||
{{- else }}
|
||||
secret:
|
||||
secretName: {{ $objectName }}
|
||||
{{- end }}
|
||||
{{- with $persistence.defaultMode }}
|
||||
defaultMode: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $persistence.items }}
|
||||
items:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- else if eq $persistence.type "emptyDir" }}
|
||||
{{- $emptyDir := dict -}}
|
||||
{{- with $persistence.medium -}}
|
||||
{{- $_ := set $emptyDir "medium" . -}}
|
||||
{{- end -}}
|
||||
{{- with $persistence.sizeLimit -}}
|
||||
{{- $_ := set $emptyDir "sizeLimit" . -}}
|
||||
{{- end }}
|
||||
emptyDir: {{- $emptyDir | toYaml | nindent 4 }}
|
||||
{{- else if eq $persistence.type "hostPath" }}
|
||||
hostPath:
|
||||
path: {{ required "hostPath not set" $persistence.hostPath }}
|
||||
{{- with $persistence.hostPathType }}
|
||||
type: {{ . }}
|
||||
{{- end }}
|
||||
{{- else if eq $persistence.type "nfs" }}
|
||||
nfs:
|
||||
server: {{ required "server not set" $persistence.server }}
|
||||
path: {{ required "path not set" $persistence.path }}
|
||||
{{- else if eq $persistence.type "custom" }}
|
||||
{{- toYaml $persistence.volumeSpec | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" .Values.persistence.type) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
Loading…
Add table
Add a link
Reference in a new issue