diff --git a/docs/common/values/persistence.md b/docs/common/values/persistence.md new file mode 100644 index 0000000000..5c79cb9d3c --- /dev/null +++ b/docs/common/values/persistence.md @@ -0,0 +1,113 @@ +# Persistence + +## Key: persistence + +- Type: `dict` +- Default: + + ```yaml + shared: + enabled: true + type: emptyDir + mountPath: /shared + + varlogs: + enabled: true + type: emptyDir + mountPath: /var/logs + + tmp: + enabled: true + type: emptyDir + mountPath: /tmp + ``` + +- Helm Template: ❌ + +Can be defined in: + +- `.Values`.persistence + +--- + +Examples: + +```yaml +persistence: + # emptyDir + emptyDir-vol: + enabled: true + mountPath: /some/container/path + # Optional: When set, it won't automatically + # mount the volume to the main container. + # Useful if the volume is supposed to be mounted on + # another container only, default false + noMount: true + # Optional + mountPropagation: HostToContainer + # Optional + readOnly: false + # Optional, useful for secret and configmap volumes + subPath: subpath + # Above keys apply to all types + type: emptyDir + # Optional: Defaults to Memory + medium: Memory + # Optional: Only applies if set + sizeLimit: 1G + + nfs-vol: + enabled: true + mountPath: /some/container/path + type: nfs + server: 192.168.1.100 + path: /path/to/nfs/share + + hotsPath-vol: + enabled: true + mountPath: /some/container/path + type: hostPath + hostPath: /path/to/host + # Optional + hostPathType: DirectoryOrCreate + # Optional, defaults to .Values.global.defaults.validateHostPath + # It can be overwritten per volume too + validateHostPath: false + + ixVolume-vol: + enabled: true + mountPath: /some/container/path + type: ixVolume + datasetName: populated-from-refs + # Optional + hostPathType: DirectoryOrCreate + + configmap-vol: + enabled: true + mountPath: /some/container/path + type: configmap + # Optional: Must be a string with 4 digits + # If passed as integer, it will result in a different value + # Because of how k8s does the conversion to octal + defaultMode: "0600" + items: + - key: key-from-the-configmap + path: path-in-the-container (usually the filename) + + secret-vol: + enabled: true + mountPath: /some/container/path + type: configmap + # Optional: Must be a string with 4 digits + # If passed as integer, it will result in a different value + # Because of how k8s does the conversion to octal + defaultMode: "0600" + items: + - key: key-from-the-configmap + path: path-in-the-container (usually the filename) + + pvc-vol: + enabled: true + mountPath: /some/container/path + type: pvc +``` diff --git a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl index 1e71ef3b5e..79d2b98c22 100644 --- a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl +++ b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl @@ -19,7 +19,6 @@ {{- end -}} {{- end -}} - {{/* TODO: write tests when statefulset is ready */}} {{- if eq $root.Values.controller.type "StatefulSet" -}} {{- range $index, $vct := $root.Values.volumeClaimTemplates -}} {{- include "ix.v1.common.container.volumeMount" (dict "root" $root diff --git a/library/common/1.0.0/templates/lib/pod/_volumes.tpl b/library/common/1.0.0/templates/lib/pod/_volumes.tpl index d47fb5a80e..a2f2e69ccc 100644 --- a/library/common/1.0.0/templates/lib/pod/_volumes.tpl +++ b/library/common/1.0.0/templates/lib/pod/_volumes.tpl @@ -1,4 +1,3 @@ - {{/* Volumes included by the controller. */}} {{- define "ix.v1.common.controller.volumes" -}} {{- $root := .root -}} diff --git a/library/common/1.0.0/templates/lib/pod/volumes/_secret.tpl b/library/common/1.0.0/templates/lib/pod/volumes/_secret.tpl index ae64757228..da16be4142 100644 --- a/library/common/1.0.0/templates/lib/pod/volumes/_secret.tpl +++ b/library/common/1.0.0/templates/lib/pod/volumes/_secret.tpl @@ -8,8 +8,8 @@ secretName: {{ $objectName }} {{- with $vol.defaultMode }} {{- $defMode := tpl (toString .) $root -}} - {{- if (mustRegexMatch "^[0-9]{4}$" $defMode) }} {{/* TODO: Document that "0700" equals to 448 in octal, k8s accepts both */}} - defaultMode: {{ $defMode }} {{/* TODO: But because when octal values pass from go variables they covert to octal, we require them as string to avoid confusion */}} + {{- if (mustRegexMatch "^[0-9]{4}$" $defMode) }} + defaultMode: {{ $defMode }} {{- else -}} {{- fail (printf " (%s, converted to octal) is not valid format. Valid format is string with 4 digits <0777>." $defMode) -}} {{- end -}} diff --git a/library/common/1.0.0/values.yaml b/library/common/1.0.0/values.yaml index ee767046c6..771593cad5 100644 --- a/library/common/1.0.0/values.yaml +++ b/library/common/1.0.0/values.yaml @@ -337,6 +337,30 @@ securityContext: drop: - ALL +# TODO: Discuss if we are going to add defaults like: + # - /dev/shm +persistence: + # -- Create an emptyDir volume dedicated to be shared between all containers + # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) + shared: + enabled: true + type: emptyDir + mountPath: /shared + + # -- Create an emptyDir volume to share between all containers + # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) + varlogs: + enabled: true + type: emptyDir + mountPath: /var/logs + + # -- Create an emptyDir volume (shared between all containers) for temporary storage + # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) + tmp: + enabled: true + type: emptyDir + mountPath: /tmp + ###### - Everything bellow needs documentation ##### # Injected from middleware @@ -378,30 +402,6 @@ service: # [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) nodePort: -# TODO: Discuss if we are going to add defaults like: - # - /dev/shm -persistence: - # -- Create an emptyDir volume dedicated to be shared between all containers - # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) - shared: - enabled: true - type: emptyDir - mountPath: /shared - - # -- Create an emptyDir volume to share between all containers - # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) - varlogs: - enabled: true - type: emptyDir - mountPath: /var/logs - - # -- Create an emptyDir volume (shared between all containers) for temporary storage - # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) - tmp: - enabled: true - type: emptyDir - mountPath: /tmp - # -- Used in conjunction with `controller.type: StatefulSet` to create individual disks for each instance. volumeClaimTemplates: {} # data: