aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/common/common
diff options
context:
space:
mode:
Diffstat (limited to 'kubernetes/common/common')
-rw-r--r--kubernetes/common/common/templates/_aafconfig.tpl168
-rw-r--r--kubernetes/common/common/templates/_storage.tpl244
2 files changed, 244 insertions, 168 deletions
diff --git a/kubernetes/common/common/templates/_aafconfig.tpl b/kubernetes/common/common/templates/_aafconfig.tpl
index db7cbe8d8d..0c78cc11b9 100644
--- a/kubernetes/common/common/templates/_aafconfig.tpl
+++ b/kubernetes/common/common/templates/_aafconfig.tpl
@@ -18,11 +18,10 @@
common templates to enable aaf configs for applictaions
Parameter for aafConfig to be defined in values.yaml
- aafConfig: --> if a different key is used, call templates with argument (dict "aafRoot" "<yourkey>" "dot" .)
+ aafConfig: --> if a different key is used, call templates with argument (dict "aafRoot" .Values.<yourkey> "dot" .)
# additional scripts can be defined to handle certs
addconfig: true|false
fqdn: "sdnc"
- image: onap/aaf/aaf_agent:2.1.15
app_ns: "org.osaaf.aaf"
fqi: "sdnc@sdnc.onap.org"
fqi_namespace: org.onap.sdnc
@@ -31,19 +30,13 @@
aafDeployPass: demo123456!
cadi_latitude: "38.0"
cadi_longitude: "-72.0"
- persistence:
- enabled: true
- config.volumeReclaimPolicy: Delete
- config.accessMode: ReadWriteMany
- config.size: 40M
- config.storageClass: "manual"
- config.mountPath: "/dockerdata-nfs"
- config.mountSubPath: "sdnc/aaf"
+ secret_uid: &aaf_secret_uid my-component-aaf-deploy-creds
+
# secrets configuration, Note: create a secrets template
secrets:
- - uid: aaf-deploy-creds
+ - uid: *aaf_secret_uid
type: basicAuth
- externalSecret: '{{ ternary (tpl (default "" .Values.aafConfig.aafDeployCredsExternalSecret) .) "aafIsDiabled" .Values.global.aafEnabled }}'
+ externalSecret: '{{ ternary (tpl (default "" .Values.aafConfig.aafDeployCredsExternalSecret) .) "aafIsDisabled" .Values.global.aafEnabled }}'
login: '{{ .Values.aafConfig.aafDeployFqi }}'
password: '{{ .Values.aafConfig.aafDeployPass }}'
passwordPolicy: required
@@ -56,25 +49,18 @@
volumeMounts:
{{- if .Values.global.aafEnabled }}
- mountPath: "/opt/app/osaaf"
- name: {{ include "common.fullname" . }}-aaf-config-vol
+ name: {{ include "common.fullname" . }}-aaf-config
{{- end }}
volumes:
{{- include "common.aaf-config-volumes" . | nindent XX}}
-
- If persistence.enabled = true
- Create pvc:
- {{ include "common.aaf-config-pvc" . }}
- Create pv
- {{ include "common.aaf-config-pv" . }}
-
*/}}
{{- define "common.aaf-config" -}}
-{{- $dot := default . .dot -}}
-{{- $aafRoot := default "aafConfig" .aafRoot -}}
-{{ if .Values.global.aafEnabled }}
-- name: {{ include "common.name" . }}-aaf-readiness
- image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
- imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+{{- $dot := default . .dot -}}
+{{- $aafRoot := default $dot.Values.aafConfig .aafRoot -}}
+{{- if $dot.Values.global.aafEnabled -}}
+- name: {{ include "common.name" $dot }}-aaf-readiness
+ image: "{{ $dot.Values.global.readinessRepository }}/{{ $dot.Values.global.readinessImage }}"
+ imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
command:
- /root/ready.py
args:
@@ -84,143 +70,79 @@
- aaf-cm
- --container-name
- aaf-service
-
env:
- name: NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
-- name: {{ include "common.name" . }}-aaf-config
- image: {{ .Values.global.repository }}/{{index .Values $aafRoot "image" }}
- imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+- name: {{ include "common.name" $dot }}-aaf-config
+ image: {{ (default $dot.Values.repository $dot.Values.global.repository) }}/{{ $dot.Values.global.aafAgentImage }}
+ imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
volumeMounts:
- mountPath: "/opt/app/osaaf"
- name: {{ include "common.fullname" . }}-aaf-config-vol
- {{- if (index .Values $aafRoot "addconfig") }}
+ name: {{ include "common.fullname" $dot }}-aaf-config
+{{- if $aafRoot.addconfig }}
- name: aaf-add-config
mountPath: /opt/app/aaf_config/bin/aaf-add-config.sh
subPath: aaf-add-config.sh
- {{- end }}
+{{- end }}
command:
- sh
- -c
- |
#!/usr/bin/env bash
/opt/app/aaf_config/bin/agent.sh
- {{- if (index .Values $aafRoot "addconfig") }}
+{{- if $aafRoot.addconfig }}
/opt/app/aaf_config/bin/aaf-add-config.sh
- {{- end }}
+{{- end }}
env:
- name: APP_FQI
- value: "{{ index .Values $aafRoot "fqi" }}"
+ value: "{{ $aafRoot.fqi }}"
- name: aaf_locate_url
- value: "https://aaf-locate.{{ .Release.Namespace}}:8095"
+ value: "https://aaf-locate.{{ $dot.Release.Namespace}}:8095"
- name: aaf_locator_container
value: "oom"
- name: aaf_locator_container_ns
- value: "{{ .Release.Namespace }}"
+ value: "{{ $dot.Release.Namespace }}"
- name: aaf_locator_fqdn
- value: "{{ index .Values $aafRoot "fqdn" }}"
+ value: "{{ $aafRoot.fqdn }}"
- name: aaf_locator_app_ns
- value: "{{ index .Values $aafRoot "app_ns" }}"
+ value: "{{ $aafRoot.app_ns }}"
- name: DEPLOY_FQI
- {{- include "common.secret.envFromSecret" (dict "global" . "uid" "aaf-deploy-creds" "key" "login") | indent 6 }}
+ {{- include "common.secret.envFromSecret" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "login") | indent 6 }}
- name: DEPLOY_PASSWORD
- {{- include "common.secret.envFromSecret" (dict "global" . "uid" "aaf-deploy-creds" "key" "password") | indent 6 }}
- #Note: want to put this on Nodes, evenutally
+ {{- include "common.secret.envFromSecret" (dict "global" $dot "uid" $aafRoot.secret_uid "key" "password") | indent 6 }}
+ #Note: want to put this on Nodes, eventually
- name: cadi_longitude
- value: "{{ default "52.3" (index .Values $aafRoot "cadi_longitude") }}"
+ value: "{{ default "52.3" $aafRoot.cadi_longitude }}"
- name: cadi_latitude
- value: "{{ default "13.2" (index .Values $aafRoot "cadi_latitude") }}"
+ value: "{{ default "13.2" $aafRoot.cadi_latitude }}"
#Hello specific. Clients don't don't need this, unless Registering with AAF Locator
- name: aaf_locator_public_fqdn
- value: "{{ (index .Values $aafRoot "public_fqdn") | default "" }}"
-{{- end -}}
+ value: "{{ $aafRoot.public_fqdn | default "" }}"
+{{- end -}}
{{- end -}}
-
{{- define "common.aaf-config-volume-mountpath" -}}
-{{ if .Values.global.aafEnabled }}
+{{- if .Values.global.aafEnabled -}}
- mountPath: "/opt/app/osaaf"
- name: {{ include "common.fullname" . }}-aaf-config-vol
-{{- end -}}
+ name: {{ include "common.fullname" . }}-aaf-config
+{{- end -}}
{{- end -}}
{{- define "common.aaf-config-volumes" -}}
-{{ if .Values.global.aafEnabled }}
-{{- $dot := default . .dot -}}
-{{- $aafRoot := default "aafConfig" .aafRoot -}}
-- name: {{ include "common.fullname" . }}-aaf-config-vol
- persistentVolumeClaim:
- claimName: {{ include "common.fullname" . }}-aaf-config-pvc
-{{- if (index .Values $aafRoot "addconfig") }}
+{{- $dot := default . .dot -}}
+{{- $aafRoot := default $dot.Values.aafConfig .aafRoot -}}
+{{- if $dot.Values.global.aafEnabled -}}
+- name: {{ include "common.fullname" $dot }}-aaf-config
+ emptyDir:
+ medium: Memory
+{{- if $aafRoot.addconfig }}
- name: aaf-add-config
configMap:
- name: {{ include "common.fullname" . }}-aaf-add-config
+ name: {{ include "common.fullname" $dot }}-aaf-add-config
defaultMode: 0700
-{{- end }}
-{{- end -}}
-{{- end }}
-
-{{- define "common.aaf-config-pv" -}}
-{{- $dot := default . .dot -}}
-{{- $aafRoot := default "aafConfig" .aafRoot -}}
-metadata:
- name: {{ include "common.fullname" . }}-aaf-config-pv
- namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.name" . }}-aaf-config-pv
- chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
- release: "{{ .Release.Name }}"
- heritage: "{{ .Release.Service }}"
- name: {{ include "common.fullname" . }}
-spec:
- capacity:
- storage: {{ index .Values $aafRoot "persistence" "config" "size"}}
- accessModes:
- - {{ index .Values $aafRoot "persistence" "config" "accessMode" }}
- persistentVolumeReclaimPolicy: {{ index .Values $aafRoot "persistence" "config" "volumeReclaimPolicy" }}
- hostPath:
- path: {{ index .Values $aafRoot "persistence" "config" "mountPath" }}/{{ .Release.Name }}/{{ index .Values $aafRoot "persistence" "config" "mountSubPath" }}
-{{- if (index .Values $aafRoot "persistence" "config" "storageClass") }}
-{{- if (eq "-" (index .Values $aafRoot "persistence" "config" "storageClass")) }}
- storageClassName: ""
-{{- else }}
- storageClassName: "{{ index .Values $aafRoot "persistence" "config" "storageClass" }}"
-{{- end }}
-{{- end }}
-{{- end -}}
-
-{{- define "common.aaf-config-pvc" -}}
-{{- $dot := default . .dot -}}
-{{- $aafRoot := default "aafConfig" .aafRoot -}}
-metadata:
- name: {{ include "common.fullname" . }}-aaf-config-pvc
- namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.name" . }}
- chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
- release: "{{ .Release.Name }}"
- heritage: "{{ .Release.Service }}"
-{{- if (index .Values $aafRoot "persistence" "annotations") }}
- annotations:
-{{ toYaml (index .Values $aafRoot "persistence" "annotations" ) | indent 4 }}
-{{- end }}
-spec:
- selector:
- matchLabels:
- app: {{ include "common.name" . }}-aaf-config-pv
- accessModes:
- - {{ index .Values $aafRoot "persistence" "config" "accessMode" }}
- resources:
- requests:
- storage: {{ index .Values $aafRoot "persistence" "config" "size" }}
-{{- if (index .Values $aafRoot "persistence" "config" "storageClass") }}
-{{- if (eq "-" (index .Values $aafRoot "persistence" "config" "storageClass")) }}
- storageClassName: ""
-{{- else }}
- storageClassName: "{{ index .Values $aafRoot "persistence" "config" "storageClass" }}"
-{{- end }}
-{{- end }}
+{{- end -}}
+{{- end -}}
{{- end -}}
diff --git a/kubernetes/common/common/templates/_storage.tpl b/kubernetes/common/common/templates/_storage.tpl
index 45c8b7504a..2114d677e6 100644
--- a/kubernetes/common/common/templates/_storage.tpl
+++ b/kubernetes/common/common/templates/_storage.tpl
@@ -16,9 +16,20 @@
{{/*
Give the root folder for ONAP when using host pathes
+
+ The function takes up to two arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .subPath: the sub path to use, default to
+ ".Values.persistence.mountSubPath"
+
+ Example calls:
+ {{ include "common.storageClass" . }}
+ {{ include "common.storageClass" (dict "dot" . "subPath" "my-awesome-subPath") }}
*/}}
{{- define "common.persistencePath" -}}
-{{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ include "common.release" . }}/{{ .Values.persistence.mountSubPath }}
+{{- $dot := default . .dot -}}
+{{- $subPath := default $dot.Values.persistence.mountSubPath .subPath -}}
+{{ $dot.Values.global.persistence.mountPath | default $dot.Values.persistence.mountPath }}/{{ include "common.release" $dot }}/{{ $subPath }}
{{- end -}}
{{/*
@@ -26,28 +37,61 @@
The value "common.fullname"-data is used by default,
unless either override mechanism is used.
- - .Values.global.persistence.storageClass : override default storageClass for all charts
- - .Values.persistence.storageClassOverride : override global and default storage class on a per chart basis
- - .Values.persistence.storageClass : override default storage class on a per chart basis
+ - .Values.global.persistence.storageClass : override default storageClass for
+ all charts
+ - .Values.persistence.storageClassOverride : override global and default
+ storage class on a per chart
+ basis
+ - .Values.persistence.storageClass : override default storage class on
+ per chart basis
+
+ The function takes up to two arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .suffix: suffix to name. if not set, default to "data" when no override
+ mechanism is used.
+ - .persistenceInfos: the persitence values to use, default to
+ `.Values.persistence`.
+ Need to be the dict key from `.Values` in string
+ format.
+ let's say you have:
+
+ persistence:
+ logs:
+ enabled: true
+ size: 100Mi
+ accessMode: ReadWriteOnce
+ ...
+
+ then you have to put `.Values.persitence.logs` in
+ order to use it.
+
+
+ Example calls:
+ {{ include "common.storageClass" . }}
+ {{ include "common.storageClass" (dict "dot" . "suffix" "my-awesome-suffix") }}
+ {{ include "common.storageClass" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
*/}}
{{- define "common.storageClass" -}}
- {{- if .Values.persistence.storageClassOverride -}}
- {{- if ne "-" .Values.persistence.storageClassOverride -}}
- {{- printf "%s" .Values.persistence.storageClassOverride -}}
+{{- $dot := default . .dot -}}
+{{- $suffix := default "data" .suffix -}}
+{{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
+ {{- if $persistenceInfos.storageClassOverride -}}
+ {{- if ne "-" $persistenceInfos.storageClassOverride -}}
+ {{- $persistenceInfos.storageClassOverride -}}
{{- else -}}
{{- $storage_class := "" -}}
{{- printf "%q" $storage_class -}}
{{- end -}}
{{- else -}}
- {{- if or .Values.persistence.storageClass .Values.global.persistence.storageClass }}
- {{- if ne "-" (default .Values.persistence.storageClass .Values.global.persistence.storageClass) -}}
- {{- printf "%s" (default .Values.persistence.storageClass .Values.global.persistence.storageClass) -}}
+ {{- if or $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass }}
+ {{- if ne "-" (default $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass) -}}
+ {{- default $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass -}}
{{- else -}}
{{- $storage_class := "" -}}
{{- printf "%q" $storage_class -}}
{{- end -}}
{{- else -}}
- {{- printf "%s-data" (include "common.fullname" .) -}}
+ {{- printf "%s-%s" (include "common.fullname" $dot) $suffix -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -63,53 +107,104 @@
{{/*
Generate a PV
+
+ The function takes up to three arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .suffix: suffix to name. if not set, default to "data".
+ - .persistenceInfos: the persitence values to use, default to
+ `.Values.persistence`.
+ Need to be the dict key from `.Values` in string
+ format.
+ let's say you have:
+
+ persistence:
+ logs:
+ enabled: true
+ size: 100Mi
+ accessMode: ReadWriteOnce
+ ...
+
+ then you have to put `.Values.persitence.logs` in
+ order to use it.
+
+ Example calls:
+ {{ include "common.PV" . }}
+ {{ include "common.PV" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos".Values.persistenceLog ) }}
+ {{ include "common.PV" (dict "dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
*/}}
{{- define "common.PV" -}}
-{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
-{{- if (include "common.needPV" .) -}}
+{{- $dot := default . .dot -}}
+{{- $suffix := default "data" .suffix -}}
+{{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
+{{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
+{{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
+{{- if (include "common.needPV" $dot) -}}
kind: PersistentVolume
apiVersion: v1
-metadata:
- name: {{ include "common.fullname" . }}-data
- namespace: {{ include "common.namespace" . }}
- labels: {{- include "common.labels" . | nindent 4 }}
+metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $suffix "labels" $persistenceInfos.labels) | nindent 2 }}
spec:
capacity:
- storage: {{ .Values.persistence.size }}
+ storage: {{ $persistenceInfos.size }}
accessModes:
- - {{ .Values.persistence.accessMode }}
- storageClassName: "{{ include "common.fullname" . }}-data"
- persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
+ - {{ $persistenceInfos.accessMode }}
+ persistentVolumeReclaimPolicy: {{ $persistenceInfos.volumeReclaimPolicy }}
+ storageClassName: "{{ include "common.fullname" $dot }}-{{ $suffix }}"
hostPath:
- path: {{ include "common.persistencePath" . }}
+ path: {{ include "common.persistencePath" (dict "dot" $dot "subPath" $persistenceInfos.mountSubPath) }}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Generate N PV for a statefulset
+
+ The function takes up to two arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .suffix: suffix to name. if not set, default to "data".
+ - .persistenceInfos: the persitence values to use, default to
+ `.Values.persistence`.
+ Need to be the dict key from `.Values` in string
+ format.
+ let's say you have:
+
+ persistence:
+ logs:
+ enabled: true
+ size: 100Mi
+ accessMode: ReadWriteOnce
+ ...
+
+ then you have to put `.Values.persitence.logs` in
+ order to use it.
+
+ Example calls:
+ {{ include "common.replicaPV" . }}
+ {{ include "common.replicaPV" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
+ {{ include "common.replicaPV" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
*/}}
{{- define "common.replicaPV" -}}
-{{- $global := . }}
-{{- if and $global.Values.persistence.enabled (not $global.Values.persistence.existingClaim) }}
-{{- if (include "common.needPV" .) -}}
-{{- range $i := until (int $global.Values.replicaCount)}}
+{{- $dot := default . .dot -}}
+{{- $suffix := default "data" .suffix -}}
+{{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
+{{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
+{{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
+{{- if (include "common.needPV" $dot) -}}
+{{/* TODO: see if we can use "common.PV" after branching F release */}}
+{{- range $i := until (int $dot.Values.replicaCount) }}
+{{- $range_suffix := printf "%s-%d" $metadata_suffix $i }}
---
kind: PersistentVolume
apiVersion: v1
-metadata:
- name: {{ include "common.fullname" $global }}-data-{{$i}}
- namespace: {{ include "common.namespace" $global }}
- labels: {{- include "common.labels" $global | nindent 4 }}
+metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $range_suffix "labels" $persistenceInfos.labels) | nindent 2 }}
spec:
capacity:
- storage: {{ $global.Values.persistence.size}}
+ storage: {{ $persistenceInfos.size }}
accessModes:
- - {{ $global.Values.persistence.accessMode }}
- persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
- storageClassName: "{{ include "common.fullname" $global }}-data"
+ - {{ $persistenceInfos.accessMode }}
+ persistentVolumeReclaimPolicy: {{ $persistenceInfos.volumeReclaimPolicy }}
+ storageClassName: "{{ include "common.fullname" $dot }}-{{ $suffix }}"
hostPath:
- path: {{ include "common.persistencePath" $global }}-{{$i}}
+ path: {{ include "common.persistencePath" (dict "dot" $dot "subPath" $persistenceInfos.mountSubPath) }}-{{ $i }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -117,22 +212,81 @@ spec:
{{/*
Generate a PVC
+
+ The function takes up to two arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .suffix: suffix to name. if not set, default to "data".
+ - .persistenceInfos: the persitence values to use, default to
+ `.Values.persistence`.
+ Need to be the dict key from `.Values` in string
+ format.
+ let's say you have:
+
+ persistence:
+ logs:
+ enabled: true
+ size: 100Mi
+ accessMode: ReadWriteOnce
+ ...
+
+ then you have to put `.Values.persitence.logs` in
+ order to use it.
+
+ Example calls:
+ {{ include "common.PVC" . }}
+ {{ include "common.PVC" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
+ {{ include "common.PVC" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
*/}}
{{- define "common.PVC" -}}
-{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
+{{- $dot := default . .dot -}}
+{{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
+{{- $suffix := default "data" .suffix -}}
+{{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
+{{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
-metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
-{{- if .Values.persistence.annotations }}
- annotations:
-{{ toYaml .Values.persistence.annotations | indent 4 }}
-{{- end }}
+{{ include "common.PVCTemplate" (dict "dot" $dot "suffix" $suffix "persistenceInfos" $persistenceInfos) }}
+{{- end -}}
+{{- end -}}
+
+{{/*
+ Generate a PVC template for a statefulset
+
+ The function takes up to two arguments (inside a dictionary):
+ - .dot : environment (.)
+ - .suffix: suffix to name. if not set, default to "data".
+ - .persistenceInfos: the persitence values to use, default to
+ `.Values.persistence`.
+ Need to be the dict key from `.Values` in string
+ format.
+ let's say you have:
+
+ persistence:
+ logs:
+ enabled: true
+ size: 100Mi
+ accessMode: ReadWriteOnce
+ ...
+
+ then you have to put `.Values.persitence.logs` in
+ order to use it.
+
+ Example calls:
+ {{ include "common.PVCTemplate" . }}
+ {{ include "common.PVCTemplate" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
+ {{ include "common.PVCTemplate" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
+*/}}
+{{- define "common.PVCTemplate" -}}
+{{- $dot := default . .dot -}}
+{{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
+{{- $suffix := default "data" .suffix -}}
+{{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
+metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $metadata_suffix "annotations" $persistenceInfos.annotations) | nindent 2 }}
spec:
accessModes:
- - {{ .Values.persistence.accessMode }}
- storageClassName: {{ include "common.storageClass" . }}
+ - {{ $persistenceInfos.accessMode }}
+ storageClassName: {{ include "common.storageClass" (dict "dot" $dot "suffix" $suffix "persistenceInfos" $persistenceInfos ) }}
resources:
requests:
- storage: {{ .Values.persistence.size }}
-{{- end -}}
+ storage: {{ $persistenceInfos.size }}
{{- end -}}