Add support for ephemeral volume (configMap) (#61)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
{{- define "common.customFileConfigmap.tpl" -}}
|
||||
{{- range .Values.volumes }}
|
||||
{{- if .fileName }}
|
||||
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "common.robustName" .fileName }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
data:
|
||||
{{ .fileName }}: |
|
||||
{{- .fileContent | nindent 4 }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -1,6 +1,6 @@
|
||||
{{- define "common.pvc.tpl" -}}
|
||||
{{- range .Values.volumes }}
|
||||
{{- if not (or .existingClaim .hostPath) }}
|
||||
{{- if not (or .existingClaim .hostPath .fileName .emptyDir .existingConfigMap) }}
|
||||
{{- $robustName := include "common.robustName" $.Release.Name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -23,4 +23,4 @@ spec:
|
||||
storage: {{ .size | default "1Gi" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -2,9 +2,21 @@
|
||||
{{- if or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets }}
|
||||
volumeMounts: &volumeMounts
|
||||
{{- range .Values.volumes }}
|
||||
- name: {{ .name }}
|
||||
mountPath: {{ .path }}
|
||||
|
||||
{{- $volumeName := .name -}}
|
||||
{{- if .existingConfigMap }}
|
||||
{{- $volumeName = .existingConfigMap -}}
|
||||
{{- end }}
|
||||
{{- if .fileName }}
|
||||
{{- $volumeName = include "common.robustName" .fileName -}}
|
||||
{{- end }}
|
||||
|
||||
- name: {{ $volumeName }}
|
||||
mountPath: {{ .path }}
|
||||
{{- if .subPath }}
|
||||
subPath: {{ .subPath }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range .Values.sealedFileSecrets }}
|
||||
- name: {{ .name }}
|
||||
mountPath: {{ .path }}
|
||||
@@ -25,3 +37,4 @@ volumeMounts: &volumeMounts
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
@@ -2,9 +2,24 @@
|
||||
{{- if or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets }}
|
||||
volumes:
|
||||
{{- range .Values.volumes }}
|
||||
- name: {{ .name }}
|
||||
|
||||
{{- $volumeName := .name -}}
|
||||
{{- if .existingConfigMap }}
|
||||
{{- $volumeName = .existingConfigMap -}}
|
||||
{{- end }}
|
||||
{{- if .fileName }}
|
||||
{{- $volumeName = include "common.robustName" .fileName -}}
|
||||
{{- end }}
|
||||
|
||||
- name: {{ $volumeName }}
|
||||
{{- if .emptyDir }}
|
||||
emptyDir: {}
|
||||
{{- else if .existingConfigMap }}
|
||||
configMap:
|
||||
name: {{ .existingConfigMap }}
|
||||
{{- else if .fileName }}
|
||||
configMap:
|
||||
name: {{ $volumeName }}
|
||||
{{- else if .hostPath }}
|
||||
hostPath:
|
||||
path: {{ .hostPath.path }}
|
||||
@@ -18,8 +33,8 @@ volumes:
|
||||
{{ else }}
|
||||
claimName: {{ printf "%s-%s" $.Release.Name .name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range .Values.sealedFileSecrets }}
|
||||
- name: {{ .name }}
|
||||
secret:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -115,11 +115,14 @@
|
||||
"uiSchema": {
|
||||
"#/properties/volumes": {
|
||||
"items": {
|
||||
"emptyDir": {
|
||||
"ui:widget": "hidden"
|
||||
"emptyDir": {
|
||||
"ui:widget": "hidden"
|
||||
},
|
||||
"configMapValue": {
|
||||
"ui:widget": "textarea"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"metaData": {
|
||||
"name": "Volumes",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{{- include "common.customFileConfigmap.tpl" . -}}
|
||||
@@ -0,0 +1,22 @@
|
||||
suite: test deployment
|
||||
templates:
|
||||
- custom-file-configmap.yaml
|
||||
tests:
|
||||
- it: Should create configmaps for custom string files
|
||||
set:
|
||||
volumes:
|
||||
- fileName: myFile.conf
|
||||
fileContent: |
|
||||
blablabla
|
||||
bla
|
||||
path: /randomPath/myFile.conf
|
||||
subPath: myFile.conf
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- equal:
|
||||
path: data
|
||||
value:
|
||||
myFile.conf: |
|
||||
blablabla
|
||||
bla
|
||||
@@ -116,3 +116,61 @@ tests:
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /somewhere/over/the/rainbow
|
||||
- it: Should use emptyDir
|
||||
set:
|
||||
volumes:
|
||||
- name: myScratchDisk
|
||||
path: /randomPath
|
||||
emptyDir: true
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: myScratchDisk
|
||||
emptyDir: {}
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: myScratchDisk
|
||||
mountPath: /randomPath
|
||||
- it: Should use a configMap
|
||||
set:
|
||||
volumes:
|
||||
- existingConfigMap: my-configmap
|
||||
path: /randomPath/app.conf
|
||||
subPath: app.conf
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: my-configmap
|
||||
configMap:
|
||||
name: my-configmap
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: my-configmap
|
||||
mountPath: /randomPath/app.conf
|
||||
subPath: app.conf
|
||||
- it: Should use a configmap with custom value
|
||||
set:
|
||||
volumes:
|
||||
- fileName: myfile.conf
|
||||
fileContent: |
|
||||
blablabla
|
||||
bla
|
||||
path: /randomPath/myfile.conf
|
||||
subPath: myfile.conf
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: myfile-conf
|
||||
configMap:
|
||||
name: myfile-conf
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: myfile-conf
|
||||
mountPath: /randomPath/myfile.conf
|
||||
subPath: myfile.conf
|
||||
|
||||
@@ -708,29 +708,30 @@
|
||||
"id": "#/properties/existingFileSecrets/oneOf/0",
|
||||
"title": "existingFileSecrets",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the existing secret to mount",
|
||||
"default": "data"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data"
|
||||
},
|
||||
"subPath": {
|
||||
"type": "string",
|
||||
"title": "SubPath",
|
||||
"description": "The optinal mount subpath inside the container, to only mount a specific file but not a complete directory.",
|
||||
"default": "config.yaml"
|
||||
}
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the existing secret to mount",
|
||||
"default": "data"
|
||||
},
|
||||
"required": [
|
||||
"name", "path"
|
||||
]
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data"
|
||||
},
|
||||
"subPath": {
|
||||
"type": "string",
|
||||
"title": "SubPath",
|
||||
"description": "The optinal mount subpath inside the container, to only mount a specific file but not a complete directory.",
|
||||
"default": "config.yaml"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"path"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -749,49 +750,51 @@
|
||||
"id": "#/properties/volumes/oneOf/0",
|
||||
"title": "Volume",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the volume. Used only to recognize the volumes purpose in the config later on",
|
||||
"default": "data"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data"
|
||||
},
|
||||
"size": {
|
||||
"type": "string",
|
||||
"title": "Size",
|
||||
"description": "eg: 10Gi"
|
||||
},
|
||||
"storageClass": {
|
||||
"type": "string",
|
||||
"title": "Storage Class",
|
||||
"description": "The slug indicating the disk type in your cloud provider. `standard` on Google Cloud, `default` on Azure; `do-block-storage` on Digital Ocean"
|
||||
},
|
||||
"pvcAnnotations": {
|
||||
"type": "object",
|
||||
"title": "Annotations",
|
||||
"description": "Annotations are used to control the persistance claim behavior.",
|
||||
"default": {},
|
||||
"examples": [
|
||||
{
|
||||
"rancher.io/local-path/volume-type": "local"
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
}
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the volume. Used only to recognize the volumes purpose in the config later on",
|
||||
"default": "data"
|
||||
},
|
||||
"required": [
|
||||
"name", "path", "size"
|
||||
]
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data"
|
||||
},
|
||||
"size": {
|
||||
"type": "string",
|
||||
"title": "Size",
|
||||
"description": "eg: 10Gi"
|
||||
},
|
||||
"storageClass": {
|
||||
"type": "string",
|
||||
"title": "Storage Class",
|
||||
"description": "The slug indicating the disk type in your cloud provider. `standard` on Google Cloud, `default` on Azure; `do-block-storage` on Digital Ocean"
|
||||
},
|
||||
"pvcAnnotations": {
|
||||
"type": "object",
|
||||
"title": "Annotations",
|
||||
"description": "Annotations are used to control the persistance claim behavior.",
|
||||
"default": {},
|
||||
"examples": [
|
||||
{
|
||||
"rancher.io/local-path/volume-type": "local"
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"path",
|
||||
"size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "#/properties/volumes/oneOf/1",
|
||||
"title": "Use existing volume claim",
|
||||
"title": "Use an existing volume claim",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
@@ -813,12 +816,14 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name", "path", "existingClaim"
|
||||
"name",
|
||||
"path",
|
||||
"existingClaim"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "#/properties/volumes/oneOf/2",
|
||||
"title": "Use path from the host",
|
||||
"title": "Use a path from the host",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
@@ -840,7 +845,15 @@
|
||||
"type": {
|
||||
"type": "string",
|
||||
"title": "Path Type",
|
||||
"enum": ["DirectoryOrCreate", "Directory", "FileOrCreate", "File", "Socket", "CharDevice", "BlockDevice"]
|
||||
"enum": [
|
||||
"DirectoryOrCreate",
|
||||
"Directory",
|
||||
"FileOrCreate",
|
||||
"File",
|
||||
"Socket",
|
||||
"CharDevice",
|
||||
"BlockDevice"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -855,23 +868,24 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name", "path", "hostPath"
|
||||
"name",
|
||||
"path",
|
||||
"hostPath"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "#/properties/volumes/oneOf/3",
|
||||
"title": "Use a non-persistent disk",
|
||||
"title": "Use an ephemeral volume",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the volume. Used only to recognize the volumes purpose in the config later on",
|
||||
"default": "data"
|
||||
"default": "ephemeral-volume"
|
||||
},
|
||||
"emptyDir": {
|
||||
"type": "boolean",
|
||||
"title": "Non-persistent disk",
|
||||
"title": "ephemeral volume (emptyDir)",
|
||||
"description": "Enable to use a non-persistent disk",
|
||||
"default": true
|
||||
},
|
||||
@@ -883,7 +897,64 @@
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name", "path", "emptyDir"
|
||||
"name",
|
||||
"emptyDir",
|
||||
"path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "#/properties/volumes/oneOf/4",
|
||||
"title": "Mount an existing configMap as a file",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"existingConfigMap": {
|
||||
"type": "string",
|
||||
"title": "Name",
|
||||
"description": "The name of the configMap to mount",
|
||||
"default": "data"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data/dummy.conf"
|
||||
},
|
||||
"subPath": {
|
||||
"type": "string",
|
||||
"title": "subPath",
|
||||
"description": "Mount single file",
|
||||
"default": "dummy.conf"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"existingConfigMap",
|
||||
"path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "#/properties/volumes/oneOf/5",
|
||||
"title": "Custom string to mount as a file",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fileName": {
|
||||
"type": "string",
|
||||
"title": "File name"
|
||||
},
|
||||
"fileContent": {
|
||||
"type": "string",
|
||||
"title": "File content"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"title": "Path",
|
||||
"description": "The mount path inside the container",
|
||||
"default": "/data"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"fileName",
|
||||
"fileContent",
|
||||
"path"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user