mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-24 16:09:08 +00:00
[common] Indenting and fix volume logic (#130)
This commit is contained in:
parent
899a444153
commit
b083c8516c
@ -2,7 +2,7 @@ apiVersion: v2
|
||||
name: common
|
||||
description: Function library for k8s-at-home charts
|
||||
type: library
|
||||
version: 1.0.4
|
||||
version: 1.0.5
|
||||
keywords:
|
||||
- k8s-at-home
|
||||
- common
|
||||
|
@ -38,7 +38,7 @@ spec:
|
||||
{{- end }}
|
||||
|
||||
volumes:
|
||||
{{- include "common.controller.volumes" . | nindent 6 }}
|
||||
{{- include "common.controller.volumes" . | trim | nindent 6 }}
|
||||
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
|
@ -39,7 +39,7 @@ spec:
|
||||
{{- end }}
|
||||
|
||||
volumes:
|
||||
{{- include "common.controller.volumes" . | nindent 6 }}
|
||||
{{- include "common.controller.volumes" . | trim | nindent 6 }}
|
||||
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
|
@ -10,17 +10,17 @@ metadata:
|
||||
labels:
|
||||
{{- include "common.labels" . | nindent 4 }}
|
||||
data:
|
||||
{{- if .Values.addons.vpn.configFile }}
|
||||
{{- with .Values.addons.vpn.configFile }}
|
||||
vpnConfigfile: |-
|
||||
{{- .Values.addons.vpn.configFile | nindent 4}}
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.up }}
|
||||
{{- with .Values.addons.vpn.scripts.up }}
|
||||
up.sh: |-
|
||||
{{- .Values.addons.vpn.scripts.up | nindent 4}}
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.scripts.down }}
|
||||
{{- with .Values.addons.vpn.scripts.down }}
|
||||
down.sh: |-
|
||||
{{- .Values.addons.vpn.scripts.down | nindent 4}}
|
||||
{{- . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -14,8 +14,8 @@ spec:
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
{{- if .Values.addons.vpn.networkPolicy.egress }}
|
||||
{{- .Values.addons.vpn.networkPolicy.egress | toYaml | nindent 4 }}
|
||||
{{- with .Values.addons.vpn.networkPolicy.egress }}
|
||||
{{- . | toYaml | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -15,7 +15,7 @@ Template to render VPN addon
|
||||
{{- $configmap := include "common.addon.vpn.configmap" . -}}
|
||||
{{- if $configmap -}}
|
||||
{{- print "---" | nindent 0 -}}
|
||||
{{- $configmap -}}
|
||||
{{- $configmap | nindent 0 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the vpn config volume to the additionalVolumes */}}
|
||||
@ -29,7 +29,7 @@ Template to render VPN addon
|
||||
{{- $networkpolicy := include "common.addon.vpn.networkpolicy" . -}}
|
||||
{{- if $networkpolicy -}}
|
||||
{{- print "---" | nindent 0 -}}
|
||||
{{- $networkpolicy -}}
|
||||
{{- $networkpolicy | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -5,7 +5,7 @@ Template to render OpenVPN addon
|
||||
{{/* Append the openVPN container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.openvpn.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $additionalContainers := append .Values.additionalContainers $container }}
|
||||
{{- $additionalContainers := append .Values.additionalContainers $container -}}
|
||||
{{- $_ := set .Values "additionalContainers" $additionalContainers -}}
|
||||
{{- end -}}
|
||||
|
||||
@ -13,6 +13,6 @@ Template to render OpenVPN addon
|
||||
{{- $secret := include "common.addon.openvpn.secret" . -}}
|
||||
{{- if $secret -}}
|
||||
{{- print "---" | nindent 0 -}}
|
||||
{{- $secret -}}
|
||||
{{- $secret | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -9,9 +9,9 @@ securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
{{- if .Values.addons.vpn.env }}
|
||||
{{- with .Values.addons.vpn.env }}
|
||||
env:
|
||||
{{- range $k, $v := .Values.addons.vpn.env }}
|
||||
{{- range $k, $v := . }}
|
||||
- name: {{ $k }}
|
||||
value: {{ $v }}
|
||||
{{- end }}
|
||||
@ -43,15 +43,19 @@ volumeMounts:
|
||||
subPath: down.sh
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.shared.enabled }}
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml .Values.addons.vpn.additionalVolumeMounts | nindent 2 }}
|
||||
{{- with .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.livenessProbe }}
|
||||
{{- with .Values.addons.vpn.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml .Values.addons.vpn.livenessProbe | nindent 4 }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- with .Values.addons.vpn.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
@ -2,14 +2,14 @@
|
||||
The OpenVPN secrets to be included
|
||||
*/}}
|
||||
{{- define "common.addon.openvpn.secret" -}}
|
||||
{{- if .Values.addons.vpn.openvpn.auth -}}
|
||||
{{- with .Values.addons.vpn.openvpn.auth -}}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}-openvpn
|
||||
name: {{ template "common.names.fullname" $ }}-openvpn
|
||||
labels:
|
||||
{{- include "common.labels" . | nindent 4 }}
|
||||
{{- include "common.labels" $ | nindent 4 }}
|
||||
data:
|
||||
VPN_AUTH: {{ .Values.addons.vpn.openvpn.auth | b64enc }}
|
||||
VPN_AUTH: {{ . | b64enc }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -5,7 +5,7 @@ Template to render Wireguard addon
|
||||
{{/* Append the Wireguard container to the additionalContainers */}}
|
||||
{{- $container := include "common.addon.wireguard.container" . | fromYaml -}}
|
||||
{{- if $container -}}
|
||||
{{- $additionalContainers := append .Values.additionalContainers $container }}
|
||||
{{- $additionalContainers := append .Values.additionalContainers $container -}}
|
||||
{{- $_ := set .Values "additionalContainers" $additionalContainers -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@ -11,13 +11,13 @@ securityContext:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
- SYS_MODULE
|
||||
{{- if .Values.addons.vpn.env }}
|
||||
{{- with .Values.addons.vpn.env }}
|
||||
env:
|
||||
{{- range $k, $v := .Values.addons.vpn.env }}
|
||||
{{- range $k, $v := . }}
|
||||
- name: {{ $k }}
|
||||
value: {{ $v }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }}
|
||||
volumeMounts:
|
||||
{{- if .Values.addons.vpn.configFile }}
|
||||
@ -36,15 +36,19 @@ volumeMounts:
|
||||
subPath: down.sh
|
||||
{{- end }}
|
||||
{{- if .Values.persistence.shared.enabled }}
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
- mountPath: {{ .Values.persistence.shared.mountPath }}
|
||||
name: shared
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml .Values.addons.vpn.additionalVolumeMounts | nindent 2 }}
|
||||
{{- with .Values.addons.vpn.additionalVolumeMounts }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.addons.vpn.livenessProbe }}
|
||||
{{- with .Values.addons.vpn.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml .Values.addons.vpn.livenessProbe | nindent 4 }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- with .Values.addons.vpn.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
@ -38,6 +38,6 @@
|
||||
|
||||
{{- with .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
@ -2,32 +2,30 @@
|
||||
volumes included by the controller
|
||||
*/}}
|
||||
{{- define "common.controller.volumes" -}}
|
||||
{{/* Store the context to refer in later scope */}}
|
||||
{{- $context := . -}}
|
||||
{{/* Determine the PVC name */}}
|
||||
{{- range $index, $PVC := .Values.persistence }}
|
||||
{{- if $PVC.enabled }}
|
||||
|
||||
{{- $claimName := "" -}}
|
||||
{{- if $PVC.existingClaim -}}
|
||||
{{- $claimName = $PVC.existingClaim -}}
|
||||
{{- else }}
|
||||
{{- if $PVC.nameSuffix -}}
|
||||
{{- $claimName = printf "%s-%s" (include "common.names.fullname" $context) $PVC.nameSuffix -}}
|
||||
{{- else }}
|
||||
{{- $claimName = printf "%s-%s" (include "common.names.fullname" $context) $index -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- range $index, $persistence := .Values.persistence }}
|
||||
{{- if $persistence.enabled }}
|
||||
- name: {{ $index }}
|
||||
{{- if not $PVC.emptyDir }}
|
||||
{{- if $persistence.existingClaim }}
|
||||
{{/* Always prefer an existingClaim if that is set */}}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ $claimName }}
|
||||
{{- else }}
|
||||
claimName: {{ $persistence.existingClaim }}
|
||||
{{- else -}}
|
||||
{{- if $persistence.emptyDir -}}
|
||||
{{/* Always prefer an emptyDir next if that is set */}}
|
||||
emptyDir: {}
|
||||
{{- else -}}
|
||||
{{/* Otherwise refer to the PVC name */}}
|
||||
persistentVolumeClaim:
|
||||
{{- if $persistence.nameSuffix }}
|
||||
claimName: {{ printf "%s-%s" (include "common.names.fullname" $) $persistence.nameSuffix }}
|
||||
{{- else }}
|
||||
claimName: {{ printf "%s-%s" (include "common.names.fullname" $) $index }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.additionalVolumes }}
|
||||
{{- toYaml .Values.additionalVolumes | nindent 0 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
Loading…
Reference in New Issue
Block a user