Add Unlimited Custom hostPath mounts (#201)

This commit is contained in:
Kjeld Schouten-Lebbing
2021-03-01 18:38:55 +01:00
committed by kjeld Schouten-Lebbing
parent 95c2a96a16
commit 3cda910be6
12 changed files with 195 additions and 37 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
apiVersion: v2
kubeVersion: ">=1.16.0-0"
name: common
version: 1.5.0
version: 1.6.0
# upstream_version: 3.0.1
# appVersion:
description: Function library for TrueCharts
@@ -65,7 +65,7 @@ The main container included in the controller.
{{- end }}
{{- end }}
{{- end }}
{{- include "common.storage.configuredAppVolumeMounts" . | indent 2 }}
{{ include "common.storage.allContainerVolumeMounts" . | nindent 2 }}
{{- if .Values.additionalVolumeMounts }}
{{- toYaml .Values.additionalVolumeMounts | nindent 2 }}
{{- end }}
@@ -25,7 +25,7 @@ Volumes included by the controller.
{{- end }}
{{- end }}
{{- end }}
{{- include "common.storage.configuredAppVolumes" . }}
{{ include "common.storage.allAppVolumes" . | nindent 0 }}
{{- if .Values.additionalVolumes }}
{{- toYaml .Values.additionalVolumes | nindent 0 }}
{{- end }}
@@ -1,40 +1,76 @@
{{/*
Define appVolumeMounts for container
*/}}
{{- define "common.storage.configuredAppVolumeMounts" -}}
{{- if .Values.appVolumeMounts }}
{{- range $name, $avm := .Values.appVolumeMounts -}}
{{- if $avm.enabled }}
{{- define "common.storage.configureAppVolumeMountsInContainer" -}}
{{ range $name, $avm := . }}
{{- if (default true $avm.enabled) -}}
{{ if $avm.name }}
{{ $name = $avm.name }}
{{ end }}
- name: {{ $name }}
mountPath: {{ $avm.mountPath }}
{{- if $avm.subPath }}
{{ if $avm.subPath }}
subPath: {{ $avm.subPath }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end -}}
{{ end }}
{{- end -}}
{{/*
Define hostPath for appVolumes
*/}}
{{- define "common.storage.configuredAppVolumes" -}}
{{- if .Values.appVolumeMounts }}
{{- range $name, $av := .Values.appVolumeMounts -}}
{{- if $av.enabled }}
{{- define "common.storage.configureAppVolumes" -}}
{{- range $name, $av := $.volMounts -}}
{{ if (default true $av.enabled) }}
{{ if $av.name }}
{{ $name = $av.name }}
{{ end }}
- name: {{ $name }}
{{- if $av.emptyDir }}
{{ if $av.emptyDir }}
emptyDir: {}
{{- else }}
{{- else -}}
hostPath:
{{ if $av.hostPathEnabled }}
path: {{ required "hostPath not set" $av.hostPath }}
{{- else }}
{{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $.Values.ixVolumes -}}
path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ else }}
{{- $ixVolDict := dict "datasetName" $av.datasetName "ixVolumes" $.ixVolumes -}}
path: {{ include "common.storage.retrieveHostPathFromiXVolume" $ixVolDict }}
{{ end }}
{{ end }}
{{ end }}
{{- end -}}
{{- end -}}
{{/*
Get all volumes configuration
*/}}
{{- define "common.storage.allAppVolumes" -}}
{{- $volDict := dict "volMounts" .Values.appVolumeMounts "ixVolumes" .Values.ixVolumes -}}
{{- $volExtraDict := dict "volMounts" .Values.appExtraVolumeMounts "ixVolumes" .Values.ixVolumes -}}
{{- if .Values.appVolumeMounts -}}
{{- include "common.storage.configureAppVolumes" $volDict | nindent 0 -}}
{{- end -}}
{{- if .Values.appExtraVolumeMounts -}}
{{- include "common.storage.configureAppVolumes" $volExtraDict | nindent 0 -}}
{{- end -}}
{{- end -}}
{{/*
Get all container volume moutns configuration
*/}}
{{- define "common.storage.allContainerVolumeMounts" -}}
{{- if .Values.appVolumeMounts -}}
{{- include "common.storage.configureAppVolumeMountsInContainer" .Values.appVolumeMounts | nindent 0 -}}
{{- end -}}
{{- if .Values.appExtraVolumeMounts -}}
{{- include "common.storage.configureAppVolumeMountsInContainer" .Values.appExtraVolumeMounts | nindent 0 -}}
{{- end -}}
{{- end -}}
@@ -55,7 +55,7 @@ spec:
#securityContext:
#
volumeMounts:
{{- include "common.storage.configuredAppVolumeMounts" . | indent 12 }}
{{- include "common.storage.allContainerVolumeMounts" . | indent 12 }}
{{- with (include "common.controller.volumes" . | trim) }}
volumes:
{{- . | nindent 8 }}
+3 -2
View File
@@ -493,8 +493,8 @@ fixMountPermissions: true
# hostPath: ""
# setPermissions: true
#
# data:
# appExtraVolumeMounts:
# - name: "data"
# enabled: false
# emptyDir: false
# datasetName: "data"
@@ -502,6 +502,7 @@ fixMountPermissions: true
# subPath: some-subpath
# hostPathEnabled: false
# hostPath: ""
# setPermissions: true
# appIngress:
# main: