mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 12:34:17 -03:00
add volumes and some volume tets
This commit is contained in:
@@ -200,3 +200,137 @@ tests:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.metadata.labels.test
|
||||
value: some_value
|
||||
|
||||
- it: should pass with added emptyDir volume
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
sizeLimit: 1Gi
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
emptyDir:
|
||||
sizeLimit: 1Gi
|
||||
|
||||
- it: should pass with added emptyDir volume and no sizeLimit
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
emptyDir: {}
|
||||
|
||||
- it: should pass with added emptyDir volume memory backed with sizeLimit
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
|
||||
- it: should pass with added emptyDir volume memory backed with sizeLimit via tpl
|
||||
set:
|
||||
some_medium: Memory
|
||||
some_size: 1Gi
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
medium: "{{ .Values.some_medium }}"
|
||||
sizeLimit: "{{ .Values.some_size }}"
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
|
||||
- it: should pass with added emptyDir volume memory backed and no sizeLimit
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
medium: Memory
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
|
||||
- it: should pass with added nfs
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: nfs
|
||||
server: some.server.local
|
||||
path: /nfs/path
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
nfs:
|
||||
server: some.server.local
|
||||
path: /nfs/path
|
||||
|
||||
- it: should pass with added hostPath
|
||||
set:
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: hostpath
|
||||
hostPath: /mnt/pool/test
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
hostPath:
|
||||
path: /mnt/pool/test
|
||||
|
||||
- it: should pass with added hostPath and hostPathType set via tpl
|
||||
set:
|
||||
some_key: Directory
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: hostpath
|
||||
hostPathType: "{{ .Values.some_key }}"
|
||||
hostPath: /mnt/pool/test
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
name: volume1
|
||||
hostPath:
|
||||
path: /mnt/pool/test
|
||||
type: Directory
|
||||
|
||||
TODO: configmap
|
||||
TODO: secret
|
||||
TODO: PVC
|
||||
TODO: ports
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
The pod definition included in the controller.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.controller.pod" -}}
|
||||
{{- with (include "ix.v1.common.controller.volumes" . | trim) }}
|
||||
volumes:
|
||||
{{- . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{/*
|
||||
Ports included in the controller.
|
||||
Ports included by the controller.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.controller.ports" -}}
|
||||
{{ $ports := list }}
|
||||
@@ -12,7 +12,6 @@ Ports included in the controller.
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
Render the list of ports
|
||||
*/}}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{{/*
|
||||
Probes selection logic.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.controller.probes" -}}
|
||||
|
||||
{{- end -}}
|
||||
89
library/common/1.0.0/templates/lib/controller/_volumes.tpl
Normal file
89
library/common/1.0.0/templates/lib/controller/_volumes.tpl
Normal file
@@ -0,0 +1,89 @@
|
||||
{{/*
|
||||
Volumes included by the controller.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.controller.volumes" -}}
|
||||
{{- $persistenceDefault := "pvc" -}}
|
||||
{{- range $index, $persistence := .Values.persistence }}
|
||||
{{- if $persistence.enabled }}
|
||||
{{/* If persistence type is not defined, fallback to $persistenceDefault */}}
|
||||
{{- if not $persistence.type }}
|
||||
{{ $_ := set $persistence "type" $persistenceDefault }}
|
||||
{{- end }}
|
||||
- name: {{ tpl ( toString $index ) $ }}
|
||||
{{/* PVC */}}
|
||||
{{- if eq ($persistence.type | lower) "pvc" }}
|
||||
{{- $pvcName := (include "ix.v1.common.names.fullname" $) -}}
|
||||
{{- if $persistence.existingClaim }}
|
||||
{{/* Always prefer existingClaim if it set */}}
|
||||
{{- $pvcName = $persistence.existingClaim -}}
|
||||
{{- else -}}
|
||||
{{/* Otherwise refer to the PVC name */}}
|
||||
{{- if $persistence.nameOverride -}}
|
||||
{{- if not (eq $persistence.nameOverride "-") -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "ix.v1.common.names.fullname" $) $persistence.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "ix.v1.common.names.fullname" $) $index) -}}
|
||||
{{- end -}}
|
||||
{{- if $persistence.forceName -}}
|
||||
{{- $pvcName = $persistence.forceName }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ tpl $pvcName $ }}
|
||||
{{/* emptyDir */}}
|
||||
{{- else if eq ($persistence.type | lower) "emptydir" }}
|
||||
{{- $emptyDir := dict -}}
|
||||
{{- with $persistence.medium -}}
|
||||
{{- $_ := set $emptyDir "medium" "Memory" -}}
|
||||
{{- end }}
|
||||
{{/*
|
||||
If the `SizeMemoryBackedVolumes` feature gate is enabled,
|
||||
you can specify a size for memory backed volumes.
|
||||
*/}}
|
||||
{{- with $persistence.sizeLimit -}}
|
||||
{{- $_ := set $emptyDir "sizeLimit" . -}}
|
||||
{{- end }}
|
||||
emptyDir: {{- tpl (toYaml $emptyDir) $ | nindent 4 }}
|
||||
{{- else if or (eq ($persistence.type | lower) "configmap") (eq ($persistence.type | lower) "secret") }}
|
||||
{{- $objectName := (required (printf "objectName not set for persistence item %s" $index) $persistence.objectName) }}
|
||||
{{- $objectName = tpl $objectName $ }}
|
||||
{{/* configMap */}}
|
||||
{{- if eq ($persistence.type | lower) "configmap" }}
|
||||
configMap:
|
||||
name: {{ $objectName }}
|
||||
{{- else }}
|
||||
{{/* secret */}}
|
||||
secret:
|
||||
secretName: {{ $objectName }}
|
||||
{{- end }}
|
||||
{{- with $persistence.defaultMode }}
|
||||
defaultMode: {{ tpl . $ }}
|
||||
{{- end }}
|
||||
{{- with $persistence.items }}
|
||||
items:
|
||||
{{- tpl (toYaml .) $ | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- else if eq ($persistence.type | lower) "hostpath" }}
|
||||
{{/* hostPath */}}
|
||||
hostPath:
|
||||
path: {{ required "hostPath not set" $persistence.hostPath }}
|
||||
{{- with $persistence.hostPathType }}
|
||||
type: {{ tpl . $ }}
|
||||
{{- end }}
|
||||
{{- else if eq ($persistence.type | lower) "nfs" }}
|
||||
nfs:
|
||||
server: {{ required "NFS Server not set" $persistence.server }}
|
||||
path: {{ required "NFS Path not set" $persistence.path }}
|
||||
{{/* ix-volumes */}}
|
||||
{{- else if eq ($persistence.type | lower) "ix-volumes" }}
|
||||
{{/* TODO: Implement ix-volumes */}}
|
||||
{{/* Custom, in case we want to add something once */}}
|
||||
{{- else if eq ($persistence.type | lower) "custom" }}
|
||||
{{- tpl ( toYaml $persistence.volumeSpec ) $ | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" $persistence.type) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -48,6 +48,6 @@ spec:
|
||||
{{- with .Values.podLabels }}
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.controller.pod" . | nindent 6 }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.controller.pod" . | nindent 6 }}
|
||||
{{- end }}
|
||||
|
||||
@@ -74,3 +74,154 @@ service:
|
||||
# -- Specify the nodePort value NodePort service types.
|
||||
# [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)
|
||||
nodePort:
|
||||
|
||||
# -- Configure persistence for the chart here.
|
||||
# Additional items can be added by adding a dictionary key similar to the 'pvc-example' key.
|
||||
# @default -- See below
|
||||
persistence:
|
||||
# TODO: Move examples to documentation instead of here
|
||||
pvc-example:
|
||||
# -- Enables or disables the persistence item
|
||||
enabled: false
|
||||
# -- Sets the persistence type
|
||||
# Valid options are: pvc | emptyDir | secret | configMap | hostPath | custom
|
||||
type: pvc
|
||||
# -- Sets an override for the suffix of this volume
|
||||
nameOverride: ""
|
||||
annotationsList: []
|
||||
# - name: somename
|
||||
# value: somevalue
|
||||
# -- Add annotations to PVC object
|
||||
annotations: {}
|
||||
# -- If you want to reuse an existing claim, the name of the existing PVC can be passed here.
|
||||
existingClaim: ""
|
||||
# -- force the complete PVC name
|
||||
# Will not add any prefix or suffix
|
||||
forceName: ""
|
||||
# -- Example of a hostPath mount
|
||||
# [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#hostpath)
|
||||
# @default -- See below
|
||||
host-dev:
|
||||
enabled: false
|
||||
type: hostPath
|
||||
# -- Which path on the host should be mounted.
|
||||
hostPath: /dev
|
||||
# -- Automatic set permissions using chown and chmod
|
||||
setPermissions: false
|
||||
# -- Where to mount the path in the main container.
|
||||
# Defaults to the value of `hostPath`
|
||||
mountPath: # /myDev
|
||||
# -- Specifying a hostPathType adds a check before trying to mount the path.
|
||||
# See Kubernetes documentation for options.
|
||||
hostPathType: ""
|
||||
# -- Specify if the path should be mounted read-only.
|
||||
readOnly: true
|
||||
|
||||
# -- Example of a configmap mount
|
||||
# @default -- See below
|
||||
configmap-example:
|
||||
enabled: false
|
||||
type: configMap
|
||||
# -- Specify the name of the configmap object to be mounted. Helm templates can be used.
|
||||
objectName: myconfig-map
|
||||
# -- Where to mount the volume in the main container.
|
||||
# Defaults to `/<name_of_the_volume>`,
|
||||
# setting to '-' creates the volume but disables the volumeMount.
|
||||
mountPath: # /custom-mount
|
||||
# -- Specify if the volume should be mounted read-only.
|
||||
readOnly: false
|
||||
|
||||
# -- Example of a secret mount
|
||||
# @default -- See below
|
||||
secret-example:
|
||||
enabled: false
|
||||
type: secret
|
||||
# -- Specify the name of the secret object to be mounted. Helm templates can be used.
|
||||
objectName: mysecret
|
||||
# -- Where to mount the volume in the main container.
|
||||
# Defaults to `/<name_of_the_volume>`,
|
||||
# setting to '-' creates the volume but disables the volumeMount.
|
||||
mountPath: # /custom-mount
|
||||
# -- Specify if the volume should be mounted read-only.
|
||||
readOnly: false
|
||||
# -- define the default mount mode for the secret
|
||||
defaultMode: 0644
|
||||
# -- Define the secret items to be mounted
|
||||
items:
|
||||
- key: username
|
||||
path: my-group/my-username
|
||||
|
||||
# -- Example of a nfs mount
|
||||
# @default -- See below
|
||||
nfs-example:
|
||||
enabled: false
|
||||
type: nfs
|
||||
# -- Specify the name of the secret object to be mounted
|
||||
server: 192.168.10.10
|
||||
# -- define the default mount path on the nfs server
|
||||
path: "/somepath"
|
||||
# -- Where to mount the volume in the main container.
|
||||
# Defaults to `/<name_of_the_volume>`,
|
||||
# setting to '-' creates the volume but disables the volumeMount.
|
||||
mountPath: # /custom-mount
|
||||
# -- Specify if the volume should be mounted read-only.
|
||||
readOnly: false
|
||||
|
||||
# -- Create an emptyDir volume to for /dev/shm
|
||||
# [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir)
|
||||
# @default -- See below
|
||||
shm:
|
||||
# TODO: discuss if we enable it by default
|
||||
enabled: false
|
||||
type: emptyDir
|
||||
mountPath: /dev/shm
|
||||
# -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead
|
||||
# of the storage medium that backs the node.
|
||||
medium: Memory
|
||||
# -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can
|
||||
# specify a size for memory backed volumes.
|
||||
sizeLimit: # 1Gi
|
||||
|
||||
# -- Create an emptyDir volume to share between all containers for temporary storage
|
||||
# @default -- See below
|
||||
temp:
|
||||
# TODO: discuss if we enable it by default
|
||||
enabled: false
|
||||
type: emptyDir
|
||||
mountPath: /tmp
|
||||
# -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead
|
||||
# of the storage medium that backs the node.
|
||||
medium: # Memory
|
||||
# -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can
|
||||
# specify a size for memory backed volumes.
|
||||
sizeLimit: # 1Gi
|
||||
|
||||
# -- Create an emptyDir volume to share between all containers
|
||||
# [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir)
|
||||
# @default -- See below
|
||||
varlogs:
|
||||
# TODO: discuss if we enable it by default
|
||||
enabled: false
|
||||
type: emptyDir
|
||||
mountPath: /var/logs
|
||||
# -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead
|
||||
# of the storage medium that backs the node.
|
||||
medium: # Memory
|
||||
# -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can
|
||||
# specify a size for memory backed volumes.
|
||||
sizeLimit: # 1Gi
|
||||
|
||||
# -- Create an emptyDir volume to share between all containers
|
||||
# [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir)
|
||||
# @default -- See below
|
||||
shared:
|
||||
# TODO: discuss if we enable it by default
|
||||
enabled: false
|
||||
type: emptyDir
|
||||
mountPath: /shared
|
||||
# -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead
|
||||
# of the storage medium that backs the node.
|
||||
medium: # Memory
|
||||
# -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can
|
||||
# specify a size for memory backed volumes.
|
||||
sizeLimit: # 1Gi
|
||||
|
||||
Reference in New Issue
Block a user