mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57: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
23
charts/library/common/templates/addons/vpn/_configmap.tpl
Normal file
23
charts/library/common/templates/addons/vpn/_configmap.tpl
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{/*
|
||||
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:
|
||||
{{- with .Values.addons.vpn.scripts.up }}
|
||||
up.sh: |-
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.scripts.down }}
|
||||
down.sh: |-
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,29 @@
|
|||
{{/*
|
||||
Blueprint for the NetworkPolicy object that can be included in the addon.
|
||||
*/}}
|
||||
{{- define "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)) }}
|
||||
labels: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
|
||||
annotations: {{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
podSelector:
|
||||
{{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "common.labels.selectorLabels" . | fromYaml)) }}
|
||||
matchLabels: {{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
{{- with .Values.addons.vpn.networkPolicy.egress }}
|
||||
{{- . | toYaml | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
19
charts/library/common/templates/addons/vpn/_secret.tpl
Normal file
19
charts/library/common/templates/addons/vpn/_secret.tpl
Normal file
|
@ -0,0 +1,19 @@
|
|||
{{/*
|
||||
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 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
37
charts/library/common/templates/addons/vpn/_volume.tpl
Normal file
37
charts/library/common/templates/addons/vpn/_volume.tpl
Normal file
|
@ -0,0 +1,37 @@
|
|||
{{/*
|
||||
The volume (referencing VPN scripts) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn.scriptsVolumeSpec" -}}
|
||||
{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}}
|
||||
configMap:
|
||||
name: {{ include "common.names.fullname" . }}-vpn
|
||||
items:
|
||||
{{- if .Values.addons.vpn.scripts.up }}
|
||||
- key: up.sh
|
||||
path: up.sh
|
||||
mode: 0777
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.down }}
|
||||
- key: down.sh
|
||||
path: down.sh
|
||||
mode: 0777
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
The volume (referencing VPN config) to be inserted into additionalVolumes.
|
||||
*/}}
|
||||
{{- define "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
|
||||
{{- end }}
|
||||
items:
|
||||
- key: vpnConfigfile
|
||||
path: vpnConfigfile
|
||||
{{- end -}}
|
||||
{{- end -}}
|
45
charts/library/common/templates/addons/vpn/_vpn.tpl
Normal file
45
charts/library/common/templates/addons/vpn/_vpn.tpl
Normal file
|
@ -0,0 +1,45 @@
|
|||
{{/*
|
||||
Template to render VPN addon
|
||||
It will include / inject the required templates based on the given values.
|
||||
*/}}
|
||||
{{- define "common.addon.vpn" -}}
|
||||
{{- if .Values.addons.vpn.enabled -}}
|
||||
{{- if eq "openvpn" .Values.addons.vpn.type -}}
|
||||
{{- include "common.addon.openvpn" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq "wireguard" .Values.addons.vpn.type -}}
|
||||
{{- include "common.addon.wireguard" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the configmap if not empty */}}
|
||||
{{- $configmap := include "common.addon.vpn.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- $configmap | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the secret if not empty */}}
|
||||
{{- $secret := include "common.addon.vpn.secret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- $secret | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the vpn scripts volume to the volumes */}}
|
||||
{{- $scriptVolume := include "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 }}
|
||||
{{ 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" . -}}
|
||||
{{- if $networkpolicy -}}
|
||||
{{- $networkpolicy | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,17 @@
|
|||
{{/*
|
||||
Template to render OpenVPN addon. It will add the container to the list of additionalContainers
|
||||
and add a credentials secret if speciffied.
|
||||
*/}}
|
||||
{{- define "common.addon.openvpn" -}}
|
||||
{{/* Append the openVPN container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.openvpn.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-openvpn" $container -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Include the secret if not empty */}}
|
||||
{{- $secret := include "common.addon.openvpn.secret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- $secret | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,65 @@
|
|||
{{/*
|
||||
The OpenVPN sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.openvpn.container" -}}
|
||||
name: openvpn
|
||||
image: "{{ .Values.addons.vpn.openvpn.image.repository }}:{{ .Values.addons.vpn.openvpn.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.addons.vpn.openvpn.pullPolicy }}
|
||||
{{- with .Values.addons.vpn.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.env }}
|
||||
env:
|
||||
{{- range $k, $v := . }}
|
||||
- name: {{ $k }}
|
||||
value: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
args:
|
||||
{{- range .Values.addons.vpn.args }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- if or .Values.addons.vpn.openvpn.auth .Values.addons.vpn.openvpn.authSecret }}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
{{- if .Values.addons.vpn.openvpn.authSecret }}
|
||||
name: {{ .Values.addons.vpn.openvpn.authSecret }}
|
||||
{{- else }}
|
||||
name: {{ include "common.names.fullname" . }}-openvpn
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }}
|
||||
volumeMounts:
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret }}
|
||||
- name: vpnconfig
|
||||
mountPath: /vpn/vpn.conf
|
||||
subPath: vpnConfigfile
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.up }}
|
||||
- name: vpnscript
|
||||
mountPath: /vpn/up.sh
|
||||
subPath: up.sh
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.down }}
|
||||
- name: vpnscript
|
||||
mountPath: /vpn/down.sh
|
||||
subPath: down.sh
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.shared.enabled }}
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with .Values.addons.vpn.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,16 @@
|
|||
{{/*
|
||||
The OpenVPN credentials secrets to be included.
|
||||
*/}}
|
||||
{{- define "common.addon.openvpn.secret" -}}
|
||||
{{- with .Values.addons.vpn.openvpn.auth }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" $ }}-openvpn
|
||||
labels: {{- include "common.labels" $ | nindent 4 }}
|
||||
annotations: {{- include "common.annotations" $ | nindent 4 }}
|
||||
data:
|
||||
VPN_AUTH: {{ . | b64enc }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,11 @@
|
|||
{{/*
|
||||
Template to render Wireguard addon. It will add the container to the list of additionalContainers.
|
||||
*/}}
|
||||
*/}}
|
||||
{{- define "common.addon.wireguard" -}}
|
||||
{{/* Append the Wireguard container to the additionalContainers */}}
|
||||
{{- $container := fromYaml (include "common.addon.wireguard.container" .) -}}
|
||||
{{- if $container -}}
|
||||
{{- $_ := set .Values.additionalContainers "addon-wireguard" $container -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,56 @@
|
|||
{{/*
|
||||
The Wireguard sidecar container to be inserted.
|
||||
*/}}
|
||||
{{- define "common.addon.wireguard.container" -}}
|
||||
name: wireguard
|
||||
image: "{{ .Values.addons.vpn.wireguard.image.repository }}:{{ .Values.addons.vpn.wireguard.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.addons.vpn.wireguard.pullPolicy }}
|
||||
{{- with .Values.addons.vpn.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.env }}
|
||||
env:
|
||||
{{- range $k, $v := . }}
|
||||
- name: {{ $k }}
|
||||
value: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
args:
|
||||
{{- range .Values.addons.vpn.args }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }}
|
||||
volumeMounts:
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret }}
|
||||
- name: vpnconfig
|
||||
mountPath: /etc/wireguard/wg0.conf
|
||||
subPath: vpnConfigfile
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.up }}
|
||||
- name: vpnscript
|
||||
mountPath: /config/up.sh
|
||||
subPath: up.sh
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.down }}
|
||||
- name: vpnscript
|
||||
mountPath: /config/down.sh
|
||||
subPath: down.sh
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.shared.enabled }}
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.addons.vpn.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with .Values.addons.vpn.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue