diff --git a/charts/common/templates/_volumesRef.yaml b/charts/common/templates/_volumesRef.yaml index c8b2182..28ebd6f 100644 --- a/charts/common/templates/_volumesRef.yaml +++ b/charts/common/templates/_volumesRef.yaml @@ -3,8 +3,16 @@ volumes: {{- range .Values.volumes }} - name: {{ .name }} - {{- if .emptyDir }} + {{- if and (and (not .emptyDir.medium) (not .emptyDir.sizeLimit)) .emptyDir.enabled }} emptyDir: {} + {{- else if and (or (.emptyDir.medium) (.emptyDir.sizeLimit)) .emptyDir.enabled }} + emptyDir: + {{- if .emptyDir.medium }} + medium: {{ .emptyDir.medium }} + {{- end }} + {{- if .emptyDir.sizeLimit }} + sizeLimit: {{ .emptyDir.sizeLimit }} + {{- end }} {{- else if .existingConfigMap }} configMap: name: {{ .existingConfigMap }} diff --git a/charts/onechart/tests/deployment_volumes_test.yaml b/charts/onechart/tests/deployment_volumes_test.yaml index d95543b..6c42327 100644 --- a/charts/onechart/tests/deployment_volumes_test.yaml +++ b/charts/onechart/tests/deployment_volumes_test.yaml @@ -86,12 +86,13 @@ tests: - name: data persistentVolumeClaim: claimName: my-static-claim - - it: Should use emptyDir + - it: Should use the default emptyDir set: volumes: - name: data path: /var/lib/1clickinfra/data - emptyDir: true + emptyDir: + enabled: true asserts: - template: deployment.yaml documentIndex: 0 @@ -100,6 +101,25 @@ tests: value: - name: data emptyDir: {} + - it: Should use emptyDir with custom params + set: + volumes: + - name: data + path: /var/lib/1clickinfra/data + emptyDir: + enabled: true + sizeLimit: 500Mi + medium: Memory + asserts: + - template: deployment.yaml + documentIndex: 0 + equal: + path: spec.template.spec.volumes + value: + - name: data + emptyDir: + sizeLimit: 500Mi + medium: Memory - it: Should use hostPath set: volumes: @@ -134,12 +154,13 @@ tests: - name: data hostPath: path: /somewhere/over/the/rainbow - - it: Should use emptyDir + - it: Should use default emptyDir set: volumes: - name: myScratchDisk path: /randomPath - emptyDir: true + emptyDir: + enabled: true asserts: - template: deployment.yaml documentIndex: 0 diff --git a/charts/onechart/values.schema.json b/charts/onechart/values.schema.json index 32dad5e..a4dd045 100644 --- a/charts/onechart/values.schema.json +++ b/charts/onechart/values.schema.json @@ -1034,10 +1034,24 @@ "default": "ephemeral-volume" }, "emptyDir": { - "type": "boolean", + "type": "object", "title": "ephemeral volume (emptyDir)", "description": "Enable to use a non-persistent disk", - "default": true + "properties": { + "enabled": { + "type": "boolean", + "title": "enabled", + "default": true + }, + "sizeLimit": { + "type": "string", + "title": "Size Limit" + }, + "medium": { + "type": "string", + "title": "enabled" + } + } }, "path": { "type": "string",