mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 16:37:04 +02:00
feat(common)!: Release version 1.0.0 (#68)
- Removed: **BREAKING**: Removed support for HorizontalPodAutoscaler - Added: Support services have extraSelectorLabels (#58) - Added: support for `httpGet` probes - Added: support for setting labels / annotations on volumeClaimTemplates - Changed: **BREAKING**: Restructure of template components. All Helm templates have been renamed / namespaced. E.g. `common.values.setup` has now become `bjw-s.common.loader.init`. - Changed: **BREAKING**: Raised minimum supported k8s version to 1.22 - Changed: **BREAKING**: Renamed `configmap` key to `configMaps` - Changed: **BREAKING**: Moved `serviceMonitor` from `service` to its own key - Changed: **BREAKING**: Renamed `secret` key to `secrets`, which now works similar to `configMaps` - Changed: Updated code-server image to v4.8.2 - Changed: Updated gluetun image to v3.32.0 - Fixed: Fix NOTES always showing ingress protocol as http (#62) Signed-off-by: Gavin Mogan <git@gavinmogan.com> Co-authored-by: Gavin Mogan <github@gavinmogan.com> Co-authored-by: Gabe Cook <gabe565@gmail.com>
This commit is contained in:
parent
98ee81df4e
commit
ae4233c77f
94 changed files with 1126 additions and 976 deletions
|
@ -1,58 +0,0 @@
|
|||
{{/*
|
||||
Main entrypoint for the common library chart. It will render all underlying templates based on the provided values.
|
||||
*/}}
|
||||
{{- define "common.all" -}}
|
||||
{{- /* Merge the local chart values and the common chart defaults */ -}}
|
||||
{{- include "common.values.setup" . }}
|
||||
|
||||
{{- /* Enable code-server add-on if required */ -}}
|
||||
{{- if .Values.addons.codeserver.enabled }}
|
||||
{{- include "common.addon.codeserver" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable VPN add-on if required */ -}}
|
||||
{{- if .Values.addons.vpn.enabled }}
|
||||
{{- include "common.addon.vpn" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable promtail add-on if required */ -}}
|
||||
{{- if .Values.addons.promtail.enabled }}
|
||||
{{- include "common.addon.promtail" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable netshoot add-on if required */ -}}
|
||||
{{- if .Values.addons.netshoot.enabled }}
|
||||
{{- include "common.addon.netshoot" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{ include "common.configmap" . | nindent 0 }}
|
||||
|
||||
{{- /* Build the templates */ -}}
|
||||
{{- include "common.pvc" . }}
|
||||
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- include "common.serviceAccount" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- if .Values.controller.enabled }}
|
||||
{{- if eq .Values.controller.type "deployment" }}
|
||||
{{- include "common.deployment" . | nindent 0 }}
|
||||
{{ else if eq .Values.controller.type "daemonset" }}
|
||||
{{- include "common.daemonset" . | nindent 0 }}
|
||||
{{ 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 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ include "common.classes.hpa" . | nindent 0 }}
|
||||
|
||||
{{ include "common.service" . | nindent 0 }}
|
||||
|
||||
{{ include "common.ingress" . | nindent 0 }}
|
||||
|
||||
{{- if .Values.secret -}}
|
||||
{{ include "common.secret" . | nindent 0 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,35 +0,0 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the DaemonSet objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.daemonset" }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("common.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "common.controller.pod" . | nindent 6 }}
|
||||
{{- end }}
|
|
@ -1,39 +0,0 @@
|
|||
{{/* Renders the Ingress objects required by the chart */}}
|
||||
{{- define "common.ingress" -}}
|
||||
{{- /* Generate named ingresses as required */ -}}
|
||||
{{- range $name, $ingress := .Values.ingress }}
|
||||
{{- if $ingress.enabled -}}
|
||||
{{- $ingressValues := $ingress -}}
|
||||
|
||||
{{/* 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" $ }}
|
||||
{{- 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 -}}
|
|
@ -1,17 +0,0 @@
|
|||
{{/*
|
||||
The Secret object to be created.
|
||||
*/}}
|
||||
{{- define "common.secret" }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
type: Opaque
|
||||
{{- with .Values.secret }}
|
||||
stringData:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -1,57 +0,0 @@
|
|||
{{/*
|
||||
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 -}}
|
||||
|
||||
{{/* Include the Service class */}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
|
||||
{{- include "common.classes.service" $ | nindent 0 -}}
|
||||
|
||||
{{/* Include a serviceMonitor if required */}}
|
||||
{{- if ($service.monitor).enabled | default false -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "serviceMonitor" $serviceValues.monitor) -}}
|
||||
{{- $_ := set $.ObjectValues.serviceMonitor "nameOverride" $serviceValues.nameOverride -}}
|
||||
|
||||
{{- $serviceName := include "common.names.fullname" $ -}}
|
||||
{{- if and (hasKey $serviceValues "nameOverride") $serviceValues.nameOverride -}}
|
||||
{{- $serviceName = printf "%v-%v" $serviceName $serviceValues.nameOverride -}}
|
||||
{{ end -}}
|
||||
{{- $_ := set $.ObjectValues.serviceMonitor "serviceName" $serviceName -}}
|
||||
{{- include "common.classes.serviceMonitor" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Return 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 -}}
|
|
@ -1,14 +0,0 @@
|
|||
{{/*
|
||||
The ServiceAccount object to be created.
|
||||
*/}}
|
||||
{{- define "common.serviceAccount" }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "common.names.serviceAccountName" . }}
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
{{- with (merge (.Values.serviceAccount.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -1,62 +0,0 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the StatefulSet objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.statefulset" }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
|
||||
replicas: {{ .Values.controller.replicas }}
|
||||
podManagementPolicy: {{ default "OrderedReady" .Values.controller.podManagementPolicy }}
|
||||
{{- $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 }}
|
||||
serviceName: {{ include "common.names.fullname" . }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("common.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
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 }}
|
||||
{{- end }}
|
|
@ -0,0 +1,40 @@
|
|||
{{/*
|
||||
Template to render code-server addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.addon.codeserver" -}}
|
||||
{{- if .Values.addons.codeserver.enabled -}}
|
||||
{{/* Append the code-server container to the additionalContainers */}}
|
||||
{{- $container := include "bjw-s.common.addon.codeserver.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-codeserver" $container -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the deployKeySecret if not empty */}}
|
||||
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 -}}
|
||||
{{- $deployKeySecret := include "bjw-s.common.addon.codeserver.deployKeySecret" . -}}
|
||||
{{- if $deployKeySecret -}}
|
||||
{{- $_ := set .Values.secrets "addon-codeserver-deploykey" (dict "enabled" "true" "stringData" ($deployKeySecret | fromYaml)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the secret volume to the volumes */}}
|
||||
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }}
|
||||
{{- $volume := include "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" . | fromYaml -}}
|
||||
{{- if $volume -}}
|
||||
{{- $_ := set .Values.persistence "deploykey" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Add the code-server service */}}
|
||||
{{- $_ := set .Values.service "addon-codeserver" .Values.addons.codeserver.service -}}
|
||||
|
||||
{{/* Add the code-server ingress */}}
|
||||
{{- $svcName := printf "%v-addon-codeserver" (include "bjw-s.common.lib.chart.names.fullname" .) -}}
|
||||
{{- $svcPort := .Values.addons.codeserver.service.ports.codeserver.port -}}
|
||||
{{- range $_, $host := .Values.addons.codeserver.ingress.hosts -}}
|
||||
{{- $_ := set (index $host.paths 0) "service" (dict "name" $svcName "port" $svcPort) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set .Values.ingress "addon-codeserver" .Values.addons.codeserver.ingress -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,50 +0,0 @@
|
|||
{{/*
|
||||
Template to render code-server addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "common.addon.codeserver" -}}
|
||||
{{- if .Values.addons.codeserver.enabled -}}
|
||||
{{/* Append the code-server container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.codeserver.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-codeserver" $container -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the deployKeySecret if not empty */}}
|
||||
{{- $secret := include "common.addon.codeserver.deployKeySecret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- $secret | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the secret volume to the volumes */}}
|
||||
{{- $volume := include "common.addon.codeserver.deployKeyVolumeSpec" . | fromYaml -}}
|
||||
{{- if $volume -}}
|
||||
{{- $_ := set .Values.persistence "deploykey" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Add the code-server service */}}
|
||||
{{- if .Values.addons.codeserver.service.enabled -}}
|
||||
{{- $serviceValues := .Values.addons.codeserver.service -}}
|
||||
{{- $_ := set $serviceValues "nameOverride" "codeserver" -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
|
||||
{{- include "common.classes.service" $ -}}
|
||||
{{- $_ := unset $ "ObjectValues" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Add the code-server ingress */}}
|
||||
{{- if .Values.addons.codeserver.ingress.enabled -}}
|
||||
{{- $ingressValues := .Values.addons.codeserver.ingress -}}
|
||||
{{- $_ := set $ingressValues "nameOverride" "codeserver" -}}
|
||||
|
||||
{{/* Determine the target service name & port */}}
|
||||
{{- $svcName := printf "%v-codeserver" (include "common.names.fullname" .) -}}
|
||||
{{- $svcPort := .Values.addons.codeserver.service.ports.codeserver.port -}}
|
||||
{{- range $_, $host := $ingressValues.hosts -}}
|
||||
{{- $_ := set (index $host.paths 0) "service" (dict "name" $svcName "port" $svcPort) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
|
||||
{{- include "common.classes.ingress" $ -}}
|
||||
{{- $_ := unset $ "ObjectValues" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
The code-server sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.codeserver.container" -}}
|
||||
{{- define "bjw-s.common.addon.codeserver.container" -}}
|
||||
{{- if lt (len .Values.addons.codeserver.volumeMounts) 1 }}
|
||||
{{- fail "At least 1 volumeMount is required for codeserver container" }}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
{{/*
|
||||
The OpenVPN credentials secrets to be included.
|
||||
The deployKey secret to be included.
|
||||
*/}}
|
||||
{{- define "common.addon.codeserver.deployKeySecret" -}}
|
||||
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}-deploykey
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
type: Opaque
|
||||
{{- if .Values.addons.codeserver.git.deployKey }}
|
||||
stringData:
|
||||
id_rsa: {{ .Values.addons.codeserver.git.deployKey | quote }}
|
||||
{{- else }}
|
||||
data:
|
||||
id_rsa: {{ .Values.addons.codeserver.git.deployKeyBase64 | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- define "bjw-s.common.addon.codeserver.deployKeySecret" -}}
|
||||
{{- $deployKeyValue := .Values.addons.codeserver.git.deployKey -}}
|
||||
{{- if .Values.addons.codeserver.git.deployKeyBase64 -}}
|
||||
{{- $deployKeyValue = .Values.addons.codeserver.git.deployKeyBase64 | b64dec -}}
|
||||
{{- end -}}
|
||||
id_rsa: {{ $deployKeyValue | quote }}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
{{/*
|
||||
The volume (referencing git deploykey) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "common.addon.codeserver.deployKeyVolumeSpec" -}}
|
||||
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }}
|
||||
{{- define "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" -}}
|
||||
secret:
|
||||
{{- if .Values.addons.codeserver.git.deployKeySecret }}
|
||||
secretName: {{ .Values.addons.codeserver.git.deployKeySecret }}
|
||||
{{- else }}
|
||||
secretName: {{ include "common.names.fullname" . }}-deploykey
|
||||
secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-codeserver-deploykey
|
||||
{{- end }}
|
||||
defaultMode: {{ "0400" | toDecimal }}
|
||||
items:
|
||||
- key: id_rsa
|
||||
path: id_rsa
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
Template to render netshoot addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "common.addon.netshoot" -}}
|
||||
{{- define "bjw-s.common.addon.netshoot" -}}
|
||||
{{- if .Values.addons.netshoot.enabled -}}
|
||||
{{/* Append the netshoot container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.netshoot.container" . | fromYaml -}}
|
||||
{{- $container := include "bjw-s.common.addon.netshoot.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-netshoot" $container -}}
|
||||
{{- end -}}
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
The netshoot sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.netshoot.container" -}}
|
||||
{{- define "bjw-s.common.addon.netshoot.container" -}}
|
||||
name: netshoot
|
||||
image: "{{ .Values.addons.netshoot.image.repository }}:{{ .Values.addons.netshoot.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.addons.netshoot.pullPolicy }}
|
||||
|
|
25
charts/library/common/templates/addons/promtail/_addon.tpl
Normal file
25
charts/library/common/templates/addons/promtail/_addon.tpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{/*
|
||||
Template to render promtail addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.addon.promtail" -}}
|
||||
{{- if .Values.addons.promtail.enabled -}}
|
||||
{{/* Append the promtail container to the additionalContainers */}}
|
||||
{{- $container := include "bjw-s.common.addon.promtail.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-promtail" $container -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the promtail configMap to the configmaps dict */}}
|
||||
{{- $configmap := include "bjw-s.common.addon.promtail.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- $_ := set .Values.configMaps "addon-promtail" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the promtail config volume to the volumes */}}
|
||||
{{- $volume := include "bjw-s.common.addon.promtail.volumeSpec" . | fromYaml -}}
|
||||
{{- if $volume -}}
|
||||
{{- $_ := set .Values.persistence "addon-promtail" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,35 +1,25 @@
|
|||
{{/*
|
||||
The promtail config to be included.
|
||||
*/}}
|
||||
{{- define "common.addon.promtail.configmap" -}}
|
||||
{{- if .Values.addons.promtail.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}-promtail
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
data:
|
||||
promtail.yaml: |
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
{{- with .Values.addons.promtail.loki }}
|
||||
client:
|
||||
url: {{ . }}
|
||||
{{- end }}
|
||||
scrape_configs:
|
||||
{{- range .Values.addons.promtail.logs }}
|
||||
- job_name: {{ .name }}
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: {{ .name }}
|
||||
__path__: "{{ .path }}"
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- define "bjw-s.common.addon.promtail.configmap" -}}
|
||||
promtail.yaml: |
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
{{- with .Values.addons.promtail.loki }}
|
||||
client:
|
||||
url: {{ . }}
|
||||
{{- end }}
|
||||
scrape_configs:
|
||||
{{- range .Values.addons.promtail.logs }}
|
||||
- job_name: {{ .name }}
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: {{ .name }}
|
||||
__path__: "{{ .path }}"
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
The promtail sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.promtail.container" -}}
|
||||
{{- define "bjw-s.common.addon.promtail.container" -}}
|
||||
{{- if lt (len .Values.addons.promtail.volumeMounts) 1 }}
|
||||
{{- fail "At least 1 volumeMount is required for the promtail container" }}
|
||||
{{- end -}}
|
||||
|
@ -25,7 +25,7 @@ args:
|
|||
{{- end }}
|
||||
- "-config.file=/etc/promtail/promtail.yaml"
|
||||
volumeMounts:
|
||||
- name: promtail-config
|
||||
- name: addon-promtail
|
||||
mountPath: /etc/promtail/promtail.yaml
|
||||
subPath: promtail.yaml
|
||||
readOnly: true
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{{/*
|
||||
Template to render promtail addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "common.addon.promtail" -}}
|
||||
{{- if .Values.addons.promtail.enabled -}}
|
||||
{{/* Append the promtail container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.promtail.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-promtail" $container -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the configmap if not empty */}}
|
||||
{{- $configmap := include "common.addon.promtail.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- $configmap | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the promtail config volume to the volumes */}}
|
||||
{{- $volume := include "common.addon.promtail.volumeSpec" . | fromYaml -}}
|
||||
{{- if $volume -}}
|
||||
{{- $_ := set .Values.persistence "promtail-config" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
The volume (referencing config) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "common.addon.promtail.volumeSpec" -}}
|
||||
{{- define "bjw-s.common.addon.promtail.volumeSpec" -}}
|
||||
configMap:
|
||||
name: {{ include "common.names.fullname" . }}-promtail
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-promtail
|
||||
{{- end -}}
|
||||
|
|
|
@ -2,46 +2,42 @@
|
|||
Template to render VPN addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn" -}}
|
||||
{{- define "bjw-s.common.addon.vpn" -}}
|
||||
{{- if .Values.addons.vpn.enabled -}}
|
||||
{{- if eq "openvpn" .Values.addons.vpn.type -}}
|
||||
{{- fail "The 'openvpn' VPN type is no longer supported. Please migrate to the 'gluetun' type." }}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq "wireguard" .Values.addons.vpn.type -}}
|
||||
{{- fail "The 'wireguard' VPN type is no longer supported. Please migrate to the 'gluetun' type." }}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq "gluetun" .Values.addons.vpn.type -}}
|
||||
{{- include "common.addon.gluetun" . }}
|
||||
{{- include "bjw-s.common.addon.gluetun" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the configmap if not empty */}}
|
||||
{{- $configmap := include "common.addon.vpn.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- $configmap | nindent 0 -}}
|
||||
{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }}
|
||||
{{- $configmap := include "bjw-s.common.addon.vpn.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- $_ := set .Values.configMaps "addon-vpn" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the secret if not empty */}}
|
||||
{{- $secret := include "common.addon.vpn.secret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- $secret | nindent 0 -}}
|
||||
{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }}
|
||||
{{- $secret := include "bjw-s.common.addon.vpn.secret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- $_ := set .Values.secrets "addon-vpn-config" (dict "enabled" "true" "stringData" ($secret | fromYaml)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the vpn scripts volume to the volumes */}}
|
||||
{{- $scriptVolume := include "common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}}
|
||||
{{- $scriptVolume := include "bjw-s.common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}}
|
||||
{{- if $scriptVolume -}}
|
||||
{{- $_ := set .Values.persistence "vpnscript" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the vpn config volume to the volumes */}}
|
||||
{{- $configVolume := include "common.addon.vpn.configVolumeSpec" . | fromYaml }}
|
||||
{{- $configVolume := include "bjw-s.common.addon.vpn.configVolumeSpec" . | fromYaml }}
|
||||
{{ if $configVolume -}}
|
||||
{{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the networkpolicy if not empty */}}
|
||||
{{- $networkpolicy := include "common.addon.vpn.networkpolicy" . -}}
|
||||
{{- $networkpolicy := include "bjw-s.common.addon.vpn.networkpolicy" . -}}
|
||||
{{- if $networkpolicy -}}
|
||||
{{- $networkpolicy | nindent 0 -}}
|
||||
{{- end -}}
|
|
@ -1,23 +1,14 @@
|
|||
{{/*
|
||||
The VPN config and scripts to be included.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.configmap" -}}
|
||||
{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}-vpn
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
data:
|
||||
{{- define "bjw-s.common.addon.vpn.configmap" -}}
|
||||
{{- with .Values.addons.vpn.scripts.up }}
|
||||
up.sh: |-
|
||||
{{- . | nindent 4}}
|
||||
up.sh: |-
|
||||
{{- . | nindent 2}}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Values.addons.vpn.scripts.down }}
|
||||
down.sh: |-
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
down.sh: |-
|
||||
{{- . | nindent 2}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
{{/*
|
||||
Blueprint for the NetworkPolicy object that can be included in the addon.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.networkpolicy" -}}
|
||||
{{- define "bjw-s.common.addon.vpn.networkpolicy" -}}
|
||||
{{- if .Values.addons.vpn.networkPolicy.enabled }}
|
||||
---
|
||||
kind: NetworkPolicy
|
||||
apiVersion: networking.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
{{- with (merge (.Values.addons.vpn.networkPolicy.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- with (merge (.Values.addons.vpn.networkPolicy.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
podSelector:
|
||||
{{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "common.labels.selectorLabels" . | fromYaml)) }}
|
||||
{{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }}
|
||||
matchLabels: {{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
policyTypes:
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
{{/*
|
||||
The OpenVPN config secret to be included.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.secret" -}}
|
||||
{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}-vpnconfig
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
stringData:
|
||||
{{- with .Values.addons.vpn.configFile }}
|
||||
vpnConfigfile: |-
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- define "bjw-s.common.addon.vpn.secret" -}}
|
||||
{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) -}}
|
||||
vpnConfigfile: |-
|
||||
{{- .Values.addons.vpn.configFile | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{{/*
|
||||
The volume (referencing VPN scripts) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.scriptsVolumeSpec" -}}
|
||||
{{- define "bjw-s.common.addon.vpn.scriptsVolumeSpec" -}}
|
||||
{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}}
|
||||
configMap:
|
||||
name: {{ include "common.names.fullname" . }}-vpn
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn
|
||||
items:
|
||||
{{- if .Values.addons.vpn.scripts.up }}
|
||||
- key: up.sh
|
||||
|
@ -22,13 +22,13 @@ configMap:
|
|||
{{/*
|
||||
The volume (referencing VPN config) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.configVolumeSpec" -}}
|
||||
{{- define "bjw-s.common.addon.vpn.configVolumeSpec" -}}
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret -}}
|
||||
secret:
|
||||
{{- if .Values.addons.vpn.configFileSecret }}
|
||||
secretName: {{ .Values.addons.vpn.configFileSecret }}
|
||||
{{- else }}
|
||||
secretName: {{ include "common.names.fullname" . }}-vpnconfig
|
||||
secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn-config
|
||||
{{- end }}
|
||||
items:
|
||||
- key: vpnConfigfile
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
Template to render gluetun addon. It will add the container to the list of additionalContainers.
|
||||
*/}}
|
||||
*/}}
|
||||
{{- define "common.addon.gluetun" -}}
|
||||
{{- define "bjw-s.common.addon.gluetun" -}}
|
||||
{{/* Append the gluetun container to the additionalContainers */}}
|
||||
{{- $container := fromYaml (include "common.addon.gluetun.container" .) -}}
|
||||
{{- $container := fromYaml (include "bjw-s.common.addon.gluetun.container" .) -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-gluetun" $container -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
The gluetun sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.gluetun.container" -}}
|
||||
{{- define "bjw-s.common.addon.gluetun.container" -}}
|
||||
name: gluetun
|
||||
image: "{{ .Values.addons.vpn.gluetun.image.repository }}:{{ .Values.addons.vpn.gluetun.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.addons.vpn.gluetun.pullPolicy }}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
{{/*
|
||||
This template serves as a blueprint for horizontal pod autoscaler objects that are created
|
||||
using the common library.
|
||||
*/}}
|
||||
{{- define "common.classes.hpa" -}}
|
||||
{{- if .Values.autoscaling.enabled -}}
|
||||
{{- $hpaName := include "common.names.fullname" . -}}
|
||||
{{- $targetName := include "common.names.fullname" . }}
|
||||
---
|
||||
apiVersion: autoscaling/v2beta1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ $hpaName }}
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
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 }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -2,8 +2,8 @@
|
|||
This template serves as a blueprint for all configMap objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.classes.configmap" -}}
|
||||
{{- $fullName := include "common.names.fullname" . -}}
|
||||
{{- define "bjw-s.common.class.configmap" -}}
|
||||
{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- $configMapName := $fullName -}}
|
||||
{{- $values := .Values.configmap -}}
|
||||
|
||||
|
@ -21,14 +21,14 @@ apiVersion: v1
|
|||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ $configMapName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- with $values.data }}
|
||||
{{- tpl (toYaml .) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
|
35
charts/library/common/templates/classes/_daemonset.tpl
Normal file
35
charts/library/common/templates/classes/_daemonset.tpl
Normal file
|
@ -0,0 +1,35 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the DaemonSet objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.daemonset" -}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
|
||||
labels: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
|
||||
annotations: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
|
||||
{{- end }}
|
|
@ -1,26 +1,26 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the Deployment objects that are created
|
||||
within the common library.
|
||||
This template serves as a blueprint for Deployment objects that are created
|
||||
using the common library.
|
||||
*/}}
|
||||
{{- define "common.deployment" }}
|
||||
{{- define "bjw-s.common.class.deployment" -}}
|
||||
{{- $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 -}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
|
||||
labels: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
|
||||
annotations: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
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 }}
|
||||
|
@ -36,18 +36,18 @@ spec:
|
|||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 6 }}
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("common.podAnnotations") . }}
|
||||
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 8 }}
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "common.controller.pod" . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
|
||||
{{- end -}}
|
|
@ -2,8 +2,8 @@
|
|||
This template serves as a blueprint for all Ingress objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.classes.ingress" -}}
|
||||
{{- $fullName := include "common.names.fullname" . -}}
|
||||
{{- define "bjw-s.common.class.ingress" -}}
|
||||
{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- $ingressName := $fullName -}}
|
||||
{{- $values := .Values.ingress -}}
|
||||
|
||||
|
@ -17,26 +17,25 @@ within the common library.
|
|||
{{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $primaryService := get .Values.service (include "common.service.primary" .) -}}
|
||||
{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
|
||||
{{- $defaultServiceName := $fullName -}}
|
||||
{{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}}
|
||||
{{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}}
|
||||
{{- end -}}
|
||||
{{- $defaultServicePort := get $primaryService.ports (include "common.classes.service.ports.primary" (dict "values" $primaryService)) -}}
|
||||
{{- $isStable := include "common.capabilities.ingress.isStable" . }}
|
||||
{{- $defaultServicePort := get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $primaryService)) -}}
|
||||
---
|
||||
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $ingressName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and $isStable $values.ingressClassName }}
|
||||
{{- if $values.ingressClassName }}
|
||||
ingressClassName: {{ $values.ingressClassName }}
|
||||
{{- end }}
|
||||
{{- if $values.tls }}
|
||||
|
@ -64,19 +63,12 @@ spec:
|
|||
{{- $port = default $port .service.port -}}
|
||||
{{- end }}
|
||||
- path: {{ tpl .path $ | quote }}
|
||||
{{- if $isStable }}
|
||||
pathType: {{ default "Prefix" .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if $isStable }}
|
||||
service:
|
||||
name: {{ $service }}
|
||||
port:
|
||||
number: {{ $port }}
|
||||
{{- else }}
|
||||
serviceName: {{ $service }}
|
||||
servicePort: {{ $port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
This template serves as a blueprint for all PersistentVolumeClaim objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.classes.pvc" -}}
|
||||
{{- define "bjw-s.common.class.pvc" -}}
|
||||
{{- $values := .Values.persistence -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.persistence -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
{{- $pvcName := include "common.names.fullname" . -}}
|
||||
{{- $pvcName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- if not (eq $values.nameOverride "-") -}}
|
||||
{{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}}
|
||||
|
@ -20,14 +20,14 @@ kind: PersistentVolumeClaim
|
|||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ $pvcName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if $values.retain }}
|
||||
"helm.sh/resource-policy": keep
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
|
|
34
charts/library/common/templates/classes/_secret.tpl
Normal file
34
charts/library/common/templates/classes/_secret.tpl
Normal file
|
@ -0,0 +1,34 @@
|
|||
{{/*
|
||||
This template serves as a blueprint for all Secret objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.secret" -}}
|
||||
{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- $secretName := $fullName -}}
|
||||
{{- $values := .Values.configmap -}}
|
||||
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.secret -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- $secretName = printf "%v-%v" $secretName $values.nameOverride -}}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ $secretName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
stringData:
|
||||
{{- with $values.stringData }}
|
||||
{{- tpl (toYaml .) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -2,7 +2,7 @@
|
|||
This template serves as a blueprint for all Service objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "common.classes.service" -}}
|
||||
{{- define "bjw-s.common.class.service" -}}
|
||||
{{- $values := .Values.service -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.service -}}
|
||||
|
@ -10,12 +10,12 @@ within the common library.
|
|||
{{- end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $serviceName := include "common.names.fullname" . -}}
|
||||
{{- $serviceName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- 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)) }}
|
||||
{{- $primaryPort := get $values.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $values)) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
@ -23,14 +23,14 @@ metadata:
|
|||
name: {{ $serviceName }}
|
||||
labels:
|
||||
app.kubernetes.io/service: {{ $serviceName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }}
|
||||
traefik.ingress.kubernetes.io/service.serversscheme: https
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
|
@ -95,6 +95,7 @@ spec:
|
|||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "common.labels.selectorLabels" . | nindent 4 }}
|
||||
{{- with (merge ($values.extraSelectorLabels | default dict) (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }}
|
||||
selector: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
15
charts/library/common/templates/classes/_serviceAccount.tpl
Normal file
15
charts/library/common/templates/classes/_serviceAccount.tpl
Normal file
|
@ -0,0 +1,15 @@
|
|||
{{/*
|
||||
This template serves as a blueprint for ServiceAccount objects that are created
|
||||
using the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.serviceAccount" -}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }}
|
||||
labels: {{- include "bjw-s.common.lib.metadata.allLabels" $ | nindent 4 }}
|
||||
{{- with (merge (.Values.serviceAccount.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -1,4 +1,4 @@
|
|||
{{- define "common.classes.serviceMonitor" -}}
|
||||
{{- define "bjw-s.common.class.serviceMonitor" -}}
|
||||
{{- $values := dict -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.serviceMonitor -}}
|
||||
|
@ -6,7 +6,7 @@
|
|||
{{- end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $serviceMonitorName := include "common.names.fullname" . -}}
|
||||
{{- $serviceMonitorName := include "bjw-s.common.lib.chart.names.fullname" . -}}
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- $serviceMonitorName = printf "%v-%v" $serviceMonitorName $values.nameOverride -}}
|
||||
{{ end -}}
|
||||
|
@ -15,16 +15,20 @@ apiVersion: monitoring.coreos.com/v1
|
|||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ $serviceMonitorName }}
|
||||
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
{{- if $values.selector -}}
|
||||
{{- tpl ($values.selector | toYaml) $ | nindent 4}}
|
||||
{{- else }}
|
||||
matchLabels:
|
||||
app.kubernetes.io/service: {{ $values.serviceName }}
|
||||
{{- include "common.labels.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/service: {{ tpl $values.serviceName $ }}
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
|
||||
{{- end }}
|
||||
endpoints: {{- toYaml (required (printf "endpoints are required for serviceMonitor %v" $serviceMonitorName) $values.endpoints) | nindent 4 }}
|
||||
{{- end }}
|
||||
|
|
68
charts/library/common/templates/classes/_statefulset.tpl
Normal file
68
charts/library/common/templates/classes/_statefulset.tpl
Normal file
|
@ -0,0 +1,68 @@
|
|||
{{/*
|
||||
This template serves as the blueprint for the StatefulSet objects that are created
|
||||
within the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.statefulset" -}}
|
||||
{{- $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 -}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
|
||||
labels: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
|
||||
annotations: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
|
||||
replicas: {{ .Values.controller.replicas }}
|
||||
podManagementPolicy: {{ default "OrderedReady" .Values.controller.podManagementPolicy }}
|
||||
updateStrategy:
|
||||
type: {{ $strategy }}
|
||||
{{- if and (eq $strategy "RollingUpdate") .Values.controller.rollingUpdate.partition }}
|
||||
rollingUpdate:
|
||||
partition: {{ .Values.controller.rollingUpdate.partition }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
|
||||
serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
|
||||
volumeClaimTemplates:
|
||||
{{- range $index, $volumeClaimTemplate := .Values.volumeClaimTemplates }}
|
||||
- metadata:
|
||||
name: {{ $volumeClaimTemplate.name }}
|
||||
{{- with ($volumeClaimTemplate.labels | default dict) }}
|
||||
labels: {{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with ($volumeClaimTemplate.annotations | default dict) }}
|
||||
annotations: {{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ required (printf "accessMode is required for volumeClaimTemplate %v" $volumeClaimTemplate.name) $volumeClaimTemplate.accessMode | quote }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ required (printf "size is required for PVC %v" $volumeClaimTemplate.name) $volumeClaimTemplate.size | quote }}
|
||||
{{- if $volumeClaimTemplate.storageClass }}
|
||||
storageClassName: {{ if (eq "-" $volumeClaimTemplate.storageClass) }}""{{- else }}{{ $volumeClaimTemplate.storageClass | quote }}{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -1,19 +0,0 @@
|
|||
{{/* Allow KubeVersion to be overridden. */}}
|
||||
{{- define "common.capabilities.ingress.kubeVersion" -}}
|
||||
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Return the appropriate apiVersion for Ingress objects */}}
|
||||
{{- define "common.capabilities.ingress.apiVersion" -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- if semverCompare "<1.19" (include "common.capabilities.ingress.kubeVersion" .) -}}
|
||||
{{- print "beta1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Check Ingress stability */}}
|
||||
{{- define "common.capabilities.ingress.isStable" -}}
|
||||
{{- if eq (include "common.capabilities.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,22 +0,0 @@
|
|||
{{/* Common labels shared across objects */}}
|
||||
{{- define "common.labels" -}}
|
||||
helm.sh/chart: {{ include "common.names.chart" . }}
|
||||
{{ include "common.labels.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- with .Values.global.labels }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Selector labels shared across objects */}}
|
||||
{{- define "common.labels.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "common.names.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
|
@ -1,5 +1,5 @@
|
|||
{{/* Expand the name of the chart */}}
|
||||
{{- define "common.names.name" -}}
|
||||
{{- define "bjw-s.common.lib.chart.names.name" -}}
|
||||
{{- $globalNameOverride := "" -}}
|
||||
{{- if hasKey .Values "global" -}}
|
||||
{{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}}
|
||||
|
@ -12,8 +12,8 @@ Create a default fully qualified app name.
|
|||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "common.names.fullname" -}}
|
||||
{{- $name := include "common.names.name" . -}}
|
||||
{{- define "bjw-s.common.lib.chart.names.fullname" -}}
|
||||
{{- $name := include "bjw-s.common.lib.chart.names.name" . -}}
|
||||
{{- $globalFullNameOverride := "" -}}
|
||||
{{- if hasKey .Values "global" -}}
|
||||
{{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}}
|
||||
|
@ -31,28 +31,15 @@ If release name contains chart name it will be used as a full name.
|
|||
{{- end -}}
|
||||
|
||||
{{/* Create chart name and version as used by the chart label */}}
|
||||
{{- define "common.names.chart" -}}
|
||||
{{- define "bjw-s.common.lib.chart.names.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Create the name of the ServiceAccount to use */}}
|
||||
{{- define "common.names.serviceAccountName" -}}
|
||||
{{- define "bjw-s.common.lib.chart.names.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- default (include "common.names.fullname" .) .Values.serviceAccount.name -}}
|
||||
{{- default (include "bjw-s.common.lib.chart.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 -}}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{{/*
|
||||
Default NOTES.txt content.
|
||||
*/}}
|
||||
{{- define "common.notes.defaultNotes" -}}
|
||||
{{- define "bjw-s.common.lib.chart.notes" -}}
|
||||
|
||||
{{- $primaryIngress := get .Values.ingress (include "common.ingress.primary" .) -}}
|
||||
{{- $primaryService := get .Values.service (include "common.service.primary" .) -}}
|
||||
{{- $primaryIngress := get .Values.ingress (include "bjw-s.common.lib.ingress.primary" .) -}}
|
||||
{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
|
||||
{{- $primaryPort := "" -}}
|
||||
{{- if $primaryService -}}
|
||||
{{- $primaryPort = get $primaryService.ports (include "common.classes.service.ports.primary" (dict "serviceName" (include "common.service.primary" .) "values" $primaryService)) -}}
|
||||
{{- $primaryPort = get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "serviceName" (include "bjw-s.common.lib.service.primary" .) "values" $primaryService)) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $prefix := "http" -}}
|
||||
|
@ -22,7 +22,7 @@ Default NOTES.txt content.
|
|||
{{- if $primaryIngress }}
|
||||
1. Access the application by visiting one of these URL's:
|
||||
{{ range $primaryIngress.hosts }}
|
||||
{{- $protocol := "http" -}}
|
||||
{{- $prefix = "http" -}}
|
||||
{{ if $primaryIngress.tls -}}
|
||||
{{- $prefix = "https" -}}
|
||||
{{ end -}}
|
||||
|
@ -34,21 +34,21 @@ Default NOTES.txt content.
|
|||
{{ if (first .paths).pathTpl -}}
|
||||
{{- $path = tpl (first .paths).pathTpl $ -}}
|
||||
{{ end }}
|
||||
- {{ $protocol }}://{{- $host }}{{- $path }}
|
||||
- {{ $prefix }}://{{- $host }}{{- $path }}
|
||||
{{- end }}
|
||||
{{- else if and $primaryService $primaryPort }}
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if contains "NodePort" $primaryService.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }})
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bjw-s.common.lib.chart.names.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo {{ $prefix }}://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" $primaryService.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get svc -w {{ include "common.names.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
||||
You can watch the status of by running 'kubectl get svc -w {{ include "bjw-s.common.lib.chart.names.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bjw-s.common.lib.chart.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
||||
echo {{ $prefix }}://$SERVICE_IP:{{ $primaryPort.port }}
|
||||
{{- else if contains "ClusterIP" $primaryService.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bjw-s.common.lib.chart.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
echo "Visit {{ $prefix }}://127.0.0.1:8080 to use your application"
|
||||
kubectl port-forward $POD_NAME 8080:{{ $primaryPort.port }}
|
||||
{{- end }}
|
|
@ -1,10 +1,10 @@
|
|||
{{/*
|
||||
Environment variables used by containers.
|
||||
*/}}
|
||||
{{- define "common.controller.env_vars" -}}
|
||||
{{- define "bjw-s.common.lib.container.envVars" -}}
|
||||
{{- $values := .Values.env -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.env -}}
|
||||
{{- with .ObjectValues.envVars -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
Ports included by the controller.
|
||||
*/}}
|
||||
{{- define "common.controller.ports" -}}
|
||||
{{- define "bjw-s.common.lib.container.ports" -}}
|
||||
{{- $ports := list -}}
|
||||
{{- range .Values.service -}}
|
||||
{{- if .enabled -}}
|
47
charts/library/common/templates/lib/container/_probes.tpl
Normal file
47
charts/library/common/templates/lib/container/_probes.tpl
Normal file
|
@ -0,0 +1,47 @@
|
|||
{{/*
|
||||
Probes selection logic.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.probes" -}}
|
||||
{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
|
||||
{{- $primaryPort := "" -}}
|
||||
{{- if $primaryService -}}
|
||||
{{- $primaryPort = get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "serviceName" (include "bjw-s.common.lib.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 -}}
|
||||
{{- $probeType := "" -}}
|
||||
{{- if eq $probe.type "AUTO" -}}
|
||||
{{- $probeType = $primaryPort.protocol -}}
|
||||
{{- else -}}
|
||||
{{- $probeType = $probe.type | default "TCP" -}}
|
||||
{{- end }}
|
||||
{{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}}
|
||||
httpGet:
|
||||
path: {{ $probe.path }}
|
||||
scheme: {{ $probeType }}
|
||||
{{- else }}
|
||||
tcpSocket:
|
||||
{{- end }}
|
||||
{{- if $probe.port }}
|
||||
port: {{ ( tpl ( $probe.port | toString ) $ ) }}
|
||||
{{- else if $primaryPort.targetPort }}
|
||||
port: {{ $primaryPort.targetPort }}
|
||||
{{- else }}
|
||||
port: {{ $primaryPort.port }}
|
||||
{{- end }}
|
||||
initialDelaySeconds: {{ $probe.spec.initialDelaySeconds }}
|
||||
failureThreshold: {{ $probe.spec.failureThreshold }}
|
||||
timeoutSeconds: {{ $probe.spec.timeoutSeconds }}
|
||||
periodSeconds: {{ $probe.spec.periodSeconds }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -1,5 +1,5 @@
|
|||
{{/* Volumes included by the controller */}}
|
||||
{{- define "common.controller.volumeMounts" -}}
|
||||
{{- define "bjw-s.common.lib.container.volumeMounts" -}}
|
||||
{{- range $persistenceIndex, $persistenceItem := .Values.persistence }}
|
||||
{{- if $persistenceItem.enabled -}}
|
||||
{{- if kindIs "slice" $persistenceItem.subPath -}}
|
|
@ -1,6 +1,6 @@
|
|||
{{- /* The main container included in the controller */ -}}
|
||||
{{- define "common.controller.mainContainer" -}}
|
||||
- name: {{ include "common.names.fullname" . }}
|
||||
{{- define "bjw-s.common.lib.controller.mainContainer" -}}
|
||||
- name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
{{- with .Values.command }}
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
{{- with .Values.env }}
|
||||
env:
|
||||
{{- get (fromYaml (include "common.controller.env_vars" $)) "env" | toYaml | nindent 4 -}}
|
||||
{{- get (fromYaml (include "bjw-s.common.lib.container.envVars" $)) "env" | toYaml | nindent 4 -}}
|
||||
{{- end }}
|
||||
{{- if or .Values.envFrom .Values.secret }}
|
||||
envFrom:
|
||||
|
@ -45,16 +45,16 @@
|
|||
{{- end }}
|
||||
{{- if .Values.secret }}
|
||||
- secretRef:
|
||||
name: {{ include "common.names.fullname" . }}
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- include "common.controller.ports" . | trim | nindent 4 }}
|
||||
{{- with (include "common.controller.volumeMounts" . | trim) }}
|
||||
{{- include "bjw-s.common.lib.container.ports" . | trim | nindent 4 }}
|
||||
{{- with (include "bjw-s.common.lib.container.volumeMounts" . | trim) }}
|
||||
volumeMounts:
|
||||
{{- nindent 4 . }}
|
||||
{{- end }}
|
||||
{{- include "common.controller.probes" . | trim | nindent 2 }}
|
||||
{{- include "bjw-s.common.lib.container.probes" . | trim | nindent 2 }}
|
||||
{{- with .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 4 }}
|
25
charts/library/common/templates/lib/controller/_metadata.tpl
Normal file
25
charts/library/common/templates/lib/controller/_metadata.tpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{- define "bjw-s.common.lib.controller.metadata.labels" -}}
|
||||
{{-
|
||||
$labels := (
|
||||
merge
|
||||
(.Values.controller.labels | default dict)
|
||||
(include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)
|
||||
)
|
||||
-}}
|
||||
{{- with $labels -}}
|
||||
{{- toYaml . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "bjw-s.common.lib.controller.metadata.annotations" -}}
|
||||
{{-
|
||||
$annotations := (
|
||||
merge
|
||||
(.Values.controller.annotations | default dict)
|
||||
(include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)
|
||||
)
|
||||
-}}
|
||||
{{- with $annotations -}}
|
||||
{{- toYaml . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,12 +1,12 @@
|
|||
{{- /*
|
||||
The pod definition included in the controller.
|
||||
*/ -}}
|
||||
{{- define "common.controller.pod" -}}
|
||||
{{- define "bjw-s.common.lib.controller.pod" -}}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "common.names.serviceAccountName" . }}
|
||||
serviceAccountName: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }}
|
||||
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
|
@ -51,9 +51,9 @@ initContainers:
|
|||
{{- $_ := set $container "name" $key }}
|
||||
{{- end }}
|
||||
{{- if $container.env -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "common.controller.env_vars" $) -}}
|
||||
{{- $_ := unset $.ObjectValues "env" -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}}
|
||||
{{- $_ := unset $.ObjectValues "envVars" -}}
|
||||
{{- $_ := set $container "env" $newEnv.env }}
|
||||
{{- end }}
|
||||
{{- $initContainers = append $initContainers $container }}
|
||||
|
@ -61,7 +61,7 @@ initContainers:
|
|||
{{- tpl (toYaml $initContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
{{- include "common.controller.mainContainer" . | nindent 2 }}
|
||||
{{- include "bjw-s.common.lib.controller.mainContainer" . | nindent 2 }}
|
||||
{{- with .Values.additionalContainers }}
|
||||
{{- $additionalContainers := list }}
|
||||
{{- range $name, $container := . }}
|
||||
|
@ -69,16 +69,16 @@ containers:
|
|||
{{- $_ := set $container "name" $name }}
|
||||
{{- end }}
|
||||
{{- if $container.env -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "common.controller.env_vars" $) -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}}
|
||||
{{- $_ := set $container "env" $newEnv.env }}
|
||||
{{- $_ := unset $.ObjectValues "env" -}}
|
||||
{{- $_ := unset $.ObjectValues "envVars" -}}
|
||||
{{- end }}
|
||||
{{- $additionalContainers = append $additionalContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $additionalContainers) $ | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with (include "common.controller.volumes" . | trim) }}
|
||||
{{- with (include "bjw-s.common.lib.controller.volumes" . | trim) }}
|
||||
volumes:
|
||||
{{- nindent 2 . }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
{{/*
|
||||
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 }}
|
|
@ -1,12 +1,12 @@
|
|||
{{/*
|
||||
Volumes included by the controller.
|
||||
*/}}
|
||||
{{- define "common.controller.volumes" -}}
|
||||
{{- define "bjw-s.common.lib.controller.volumes" -}}
|
||||
{{- range $index, $persistence := .Values.persistence }}
|
||||
{{- if $persistence.enabled }}
|
||||
- name: {{ $index }}
|
||||
{{- if eq (default "pvc" $persistence.type) "pvc" }}
|
||||
{{- $pvcName := (include "common.names.fullname" $) -}}
|
||||
{{- $pvcName := (include "bjw-s.common.lib.chart.names.fullname" $) -}}
|
||||
{{- if $persistence.existingClaim }}
|
||||
{{- /* Always prefer an existingClaim if that is set */}}
|
||||
{{- $pvcName = $persistence.existingClaim -}}
|
||||
|
@ -14,10 +14,10 @@ Volumes included by the controller.
|
|||
{{- /* Otherwise refer to the PVC name */}}
|
||||
{{- if $persistence.nameOverride -}}
|
||||
{{- if not (eq $persistence.nameOverride "-") -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameOverride) -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $persistence.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $index) -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $index) -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
persistentVolumeClaim:
|
||||
|
|
21
charts/library/common/templates/lib/ingress/_primary.tpl
Normal file
21
charts/library/common/templates/lib/ingress/_primary.tpl
Normal file
|
@ -0,0 +1,21 @@
|
|||
{{/* Return the name of the primary ingress object */}}
|
||||
{{- define "bjw-s.common.lib.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 -}}
|
10
charts/library/common/templates/lib/metadata/_allLabels.tpl
Normal file
10
charts/library/common/templates/lib/metadata/_allLabels.tpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{/* Common labels shared across objects */}}
|
||||
{{- define "bjw-s.common.lib.metadata.allLabels" -}}
|
||||
helm.sh/chart: {{ include "bjw-s.common.lib.chart.names.chart" . }}
|
||||
{{ include "bjw-s.common.lib.metadata.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{ include "bjw-s.common.lib.metadata.globalLabels" . }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,10 @@
|
|||
{{/* Common annotations shared across objects */}}
|
||||
{{- define "bjw-s.common.lib.metadata.globalAnnotations" -}}
|
||||
{{- with .Values.global.annotations }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,9 @@
|
|||
{{- define "bjw-s.common.lib.metadata.globalLabels" -}}
|
||||
{{- with .Values.global.labels }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -1,22 +1,11 @@
|
|||
{{/* Common annotations shared across objects */}}
|
||||
{{- define "common.annotations" -}}
|
||||
{{- with .Values.global.annotations }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $name := $k }}
|
||||
{{- $value := tpl $v $ }}
|
||||
{{ $name }}: {{ quote $value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Determine the Pod annotations used in the controller */}}
|
||||
{{- define "common.podAnnotations" -}}
|
||||
{{- define "bjw-s.common.lib.metadata.podAnnotations" -}}
|
||||
{{- if .Values.podAnnotations -}}
|
||||
{{- tpl (toYaml .Values.podAnnotations) . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $configMapsFound := dict -}}
|
||||
{{- range $name, $configmap := .Values.configmap -}}
|
||||
{{- range $name, $configmap := .Values.configMaps -}}
|
||||
{{- if $configmap.enabled -}}
|
||||
{{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,5 @@
|
|||
{{/* Selector labels shared across objects */}}
|
||||
{{- define "bjw-s.common.lib.metadata.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "bjw-s.common.lib.chart.names.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
23
charts/library/common/templates/lib/service/_primary.tpl
Normal file
23
charts/library/common/templates/lib/service/_primary.tpl
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{/*
|
||||
Return the primary service object
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.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 -}}
|
|
@ -1,7 +1,7 @@
|
|||
{{/*
|
||||
Return the primary port for a given Service object.
|
||||
*/}}
|
||||
{{- define "common.classes.service.ports.primary" -}}
|
||||
{{- define "bjw-s.common.lib.service.primaryPort" -}}
|
||||
{{- $enabledPorts := dict -}}
|
||||
{{- range $name, $port := .values.ports -}}
|
||||
{{- if $port.enabled -}}
|
10
charts/library/common/templates/loader/_all.tpl
Normal file
10
charts/library/common/templates/loader/_all.tpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{/*
|
||||
Main entrypoint for the common library chart. It will render all underlying templates based on the provided values.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.loader.all" -}}
|
||||
{{- /* Generate chart and dependency values */ -}}
|
||||
{{- include "bjw-s.common.loader.init" . -}}
|
||||
|
||||
{{- /* Generate remaining objects */ -}}
|
||||
{{- include "bjw-s.common.loader.generate" . -}}
|
||||
{{- end -}}
|
34
charts/library/common/templates/loader/_generate.tpl
Normal file
34
charts/library/common/templates/loader/_generate.tpl
Normal file
|
@ -0,0 +1,34 @@
|
|||
{{/*
|
||||
Secondary entrypoint and primary loader for the common chart
|
||||
*/}}
|
||||
{{- define "bjw-s.common.loader.generate" -}}
|
||||
{{- /* Enable code-server add-on if required */ -}}
|
||||
{{- if .Values.addons.codeserver.enabled -}}
|
||||
{{- include "bjw-s.common.addon.codeserver" . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable VPN add-on if required */ -}}
|
||||
{{- if .Values.addons.vpn.enabled -}}
|
||||
{{- include "bjw-s.common.addon.vpn" . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable promtail add-on if required */ -}}
|
||||
{{- if .Values.addons.promtail.enabled -}}
|
||||
{{- include "bjw-s.common.addon.promtail" . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Enable netshoot add-on if required */ -}}
|
||||
{{- if .Values.addons.netshoot.enabled -}}
|
||||
{{- include "bjw-s.common.addon.netshoot" . | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Build the templates */ -}}
|
||||
{{- include "bjw-s.common.render.configmaps" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.pvcs" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.controller" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.services" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}}
|
||||
{{- end -}}
|
4
charts/library/common/templates/loader/_init.tpl
Normal file
4
charts/library/common/templates/loader/_init.tpl
Normal file
|
@ -0,0 +1,4 @@
|
|||
{{- define "bjw-s.common.loader.init" -}}
|
||||
{{- /* Merge the local chart values and the common chart defaults */ -}}
|
||||
{{- include "bjw-s.common.values.init" . }}
|
||||
{{- end -}}
|
|
@ -1,19 +1,19 @@
|
|||
{{/*
|
||||
Renders the configMap objects required by the chart.
|
||||
*/}}
|
||||
{{- define "common.configmap" -}}
|
||||
{{- define "bjw-s.common.render.configmaps" -}}
|
||||
{{- /* Generate named configMaps as required */ -}}
|
||||
{{- range $name, $configmap := .Values.configmap }}
|
||||
{{- range $name, $configmap := .Values.configMaps -}}
|
||||
{{- if $configmap.enabled -}}
|
||||
{{- $configmapValues := $configmap -}}
|
||||
|
||||
{{/* set the default nameOverride to the configMap name */}}
|
||||
{{- /* set the default nameOverride to the configMap name */ -}}
|
||||
{{- if not $configmapValues.nameOverride -}}
|
||||
{{- $_ := set $configmapValues "nameOverride" $name -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}}
|
||||
{{- include "common.classes.configmap" $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- include "bjw-s.common.class.configmap" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
16
charts/library/common/templates/render/_controller.tpl
Normal file
16
charts/library/common/templates/render/_controller.tpl
Normal file
|
@ -0,0 +1,16 @@
|
|||
{{/*
|
||||
Renders the controller object required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.controller" -}}
|
||||
{{- if .Values.controller.enabled -}}
|
||||
{{- if eq .Values.controller.type "deployment" -}}
|
||||
{{- include "bjw-s.common.class.deployment" . | nindent 0 -}}
|
||||
{{ else if eq .Values.controller.type "daemonset" -}}
|
||||
{{- include "bjw-s.common.class.daemonset" . | nindent 0 -}}
|
||||
{{ else if eq .Values.controller.type "statefulset" -}}
|
||||
{{- include "bjw-s.common.class.statefulset" . | nindent 0 -}}
|
||||
{{ else -}}
|
||||
{{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
19
charts/library/common/templates/render/_ingresses.tpl
Normal file
19
charts/library/common/templates/render/_ingresses.tpl
Normal file
|
@ -0,0 +1,19 @@
|
|||
{{/*
|
||||
Renders the Ingress objects required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.ingresses" -}}
|
||||
{{- /* Generate named ingresses as required */ -}}
|
||||
{{- range $name, $ingress := .Values.ingress }}
|
||||
{{- if $ingress.enabled -}}
|
||||
{{- $ingressValues := $ingress -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if and (not $ingressValues.nameOverride) (ne $name (include "bjw-s.common.lib.ingress.primary" $)) -}}
|
||||
{{- $_ := set $ingressValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
|
||||
{{- include "bjw-s.common.class.ingress" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,16 +1,16 @@
|
|||
{{/*
|
||||
Renders the Persistent Volume Claim objects required by the chart.
|
||||
*/}}
|
||||
{{- define "common.pvc" -}}
|
||||
{{- define "bjw-s.common.render.pvcs" -}}
|
||||
{{- /* Generate pvc as required */ -}}
|
||||
{{- range $index, $PVC := .Values.persistence }}
|
||||
{{- range $index, $PVC := .Values.persistence -}}
|
||||
{{- if and $PVC.enabled (eq (default "pvc" $PVC.type) "pvc") (not $PVC.existingClaim) -}}
|
||||
{{- $persistenceValues := $PVC -}}
|
||||
{{- if not $persistenceValues.nameOverride -}}
|
||||
{{- $_ := set $persistenceValues "nameOverride" $index -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}}
|
||||
{{- include "common.classes.pvc" $ | nindent 0 -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- include "bjw-s.common.class.pvc" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
19
charts/library/common/templates/render/_secrets.tpl
Normal file
19
charts/library/common/templates/render/_secrets.tpl
Normal file
|
@ -0,0 +1,19 @@
|
|||
{{/*
|
||||
Renders the Secret objects required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.secrets" -}}
|
||||
{{- /* Generate named Secrets as required */ -}}
|
||||
{{- range $name, $secret := .Values.secrets -}}
|
||||
{{- if $secret.enabled -}}
|
||||
{{- $secretValues := $secret -}}
|
||||
|
||||
{{- /* set the default nameOverride to the Secret name */ -}}
|
||||
{{- if not $secretValues.nameOverride -}}
|
||||
{{- $_ := set $secretValues "nameOverride" $name -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- $_ := set $ "ObjectValues" (dict "secret" $secretValues) -}}
|
||||
{{- include "bjw-s.common.class.secret" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
20
charts/library/common/templates/render/_serviceMonitors.tpl
Normal file
20
charts/library/common/templates/render/_serviceMonitors.tpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
{{/*
|
||||
Renders the serviceMonitor objects required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.serviceMonitors" -}}
|
||||
{{- /* Generate named services as required */ -}}
|
||||
{{- range $name, $serviceMonitor := .Values.serviceMonitor -}}
|
||||
{{- if $serviceMonitor.enabled -}}
|
||||
{{- $serviceMonitorValues := $serviceMonitor -}}
|
||||
|
||||
{{- if and (not $serviceMonitorValues.nameOverride) (ne $name "main") -}}
|
||||
{{- $_ := set $serviceMonitorValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the serviceMonitor class */}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "serviceMonitor" $serviceMonitorValues) -}}
|
||||
{{- include "bjw-s.common.class.serviceMonitor" $ | nindent 0 -}}
|
||||
{{- $_ := unset $.ObjectValues "serviceMonitor" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,8 @@
|
|||
{{/*
|
||||
Renders the serviceAccount object required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.serviceAccount" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- include "bjw-s.common.class.serviceAccount" $ | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
21
charts/library/common/templates/render/_services.tpl
Normal file
21
charts/library/common/templates/render/_services.tpl
Normal file
|
@ -0,0 +1,21 @@
|
|||
{{/*
|
||||
Renders the Service objects required by the chart.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.services" -}}
|
||||
{{- /* 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 "bjw-s.common.lib.service.primary" $)) -}}
|
||||
{{- $_ := set $serviceValues "nameOverride" $name -}}
|
||||
{{ end -}}
|
||||
|
||||
{{/* Include the Service class */}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
|
||||
{{- include "bjw-s.common.class.service" $ | nindent 0 -}}
|
||||
{{- $_ := unset $.ObjectValues "service" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,5 +1,7 @@
|
|||
{{/* Merge the local chart values and the common chart defaults */}}
|
||||
{{- define "common.values.setup" -}}
|
||||
{{/*
|
||||
Merge the local chart values and the common chart defaults
|
||||
*/}}
|
||||
{{- define "bjw-s.common.values.init" -}}
|
||||
{{- if .Values.common -}}
|
||||
{{- $defaultValues := deepCopy .Values.common -}}
|
||||
{{- $userValues := deepCopy (omit .Values "common") -}}
|
Loading…
Add table
Add a link
Reference in a new issue