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
No known key found for this signature in database
GPG Key ID: 4CDAD4A532BC1EDB
12 changed files with 195 additions and 37 deletions

View File

@ -0,0 +1,69 @@
# Unlimited Storage Mounts
We support presenting the user with a "Do it yourself" style list, in which the user can add unlimited paths on the host system to mount.
It should always be included in any App, to give users the option to customise things however they like.
### Example
```
- variable: appExtraVolumeMounts
label: "Custom app storage"
group: "Storage"
schema:
type: list
default: []
items:
- variable: volumeMount
label: "Custom Storage"
schema:
type: dict
attrs:
- variable: enabled
label: "Enabled"
schema:
type: boolean
default: true
required: true
hidden: true
editable: false
- variable: setPermissions
label: "Automatic Permissions"
description: "Automatically set permissions on install"
schema:
type: boolean
default: true
hidden: false
- variable: name
label: "Mountpoint Name"
schema:
type: string
default: ""
required: true
editable: true
- variable: emptyDir
label: "emptyDir"
schema:
type: boolean
default: false
hidden: true
editable: false
- variable: mountPath
label: "Mount Path"
description: "Path to mount inside the pod"
schema:
type: path
required: true
default: ""
editable: true
- variable: hostPathEnabled
label: "host Path Enabled"
schema:
type: boolean
default: true
hidden: true
- variable: hostPath
label: "Host Path"
schema:
type: hostpath
required: true
```

View File

@ -33,3 +33,7 @@ Setting permissions automatically means we `chown` the folder and all folder wit
However, we only do so when installing or updating an app.
These permission get based on the user and group you enter in the App configuration dialog and default to `568` (the SCALE default Apps user).
### Custom Storage
Besides the earlier mentioned storage options, we also provide the option to mount as many host folders as you want. This is limited to hostPath mounts only.

View File

@ -1,7 +1,7 @@
apiVersion: v2
kubeVersion: ">=1.16.0-0"
name: common-test
version: 1.3.2
version: 1.4.0
# upstream_version:
# appVersion:
description: Helper chart to test different use cases of the common library

View File

@ -25,16 +25,32 @@ appVolumeMounts:
emptyDir: true
datasetName: "data"
mountPath: "/data"
hostPathEnabled: true
hostPath: "/tmp"
hostPathEnabled: false
hostPath: ""
test:
enabled: true
emptyDir: true
emptyDir: false
datasetName: "test"
mountPath: "/test"
hostPathEnabled: true
hostPath: "/tmp"
appExtraVolumeMounts:
- name: "extratest1"
enabled: true
emptyDir: true
datasetName: "extratest1"
mountPath: "/extratest1"
hostPathEnabled: false
hostPath: ""
- name: "extratest2"
enabled: true
emptyDir: false
datasetName: "extratest2"
mountPath: "/extratest2"
hostPathEnabled: true
hostPath: "/tmp"
appAdditionalServicesEnabled: true
appAdditionalServices:
extra-tcp:

View File

@ -33,16 +33,32 @@ appVolumeMounts:
emptyDir: true
datasetName: "data"
mountPath: "/data"
hostPathEnabled: true
hostPath: "/tmp"
hostPathEnabled: false
hostPath: ""
test:
enabled: true
emptyDir: true
emptyDir: false
datasetName: "test"
mountPath: "/test"
hostPathEnabled: true
hostPath: "/tmp"
appExtraVolumeMounts:
- name: "extratest1"
enabled: true
emptyDir: true
datasetName: "extratest1"
mountPath: "/extratest1"
hostPathEnabled: false
hostPath: ""
- name: "extratest2"
enabled: true
emptyDir: false
datasetName: "extratest2"
mountPath: "/extratest2"
hostPathEnabled: true
hostPath: "/tmp"
appAdditionalServicesEnabled: true
appAdditionalServices:
extra-tcp:

View File

@ -21,11 +21,27 @@ appVolumeMounts:
hostPath: ""
test:
enabled: true
emptyDir: true
emptyDir: false
datasetName: "test"
mountPath: "/test"
hostPathEnabled: true
hostPath: "/tmp"
appExtraVolumeMounts:
- name: "extratest1"
enabled: true
emptyDir: true
datasetName: "extratest1"
mountPath: "/extratest1"
hostPathEnabled: false
hostPath: ""
- name: "extratest2"
enabled: true
emptyDir: false
datasetName: "extratest2"
mountPath: "/extratest2"
hostPathEnabled: true
hostPath: "/tmp"
appAdditionalServicesEnabled: true
appAdditionalServices:

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

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 -}}

View File

@ -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 }}

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: