feat(common): add configmap and secret persistence objects (#1368)

* feat(common): add configmap and secret persistence objects

* also port configmap layer

* add values.yaml for integrated configmap
This commit is contained in:
Kjeld Schouten-Lebbing
2021-11-21 18:45:03 +01:00
committed by GitHub
parent 5a2fba8f45
commit 3378258a3b
5 changed files with 124 additions and 2 deletions
+1 -1
View File
@@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 8.6.5
version: 8.6.6
@@ -0,0 +1,19 @@
{{/*
Renders the configMap objects required by the chart.
*/}}
{{- define "common.configmap" -}}
{{- /* Generate named configMaps as required */ -}}
{{- range $name, $configmap := .Values.configmap }}
{{- if $configmap.enabled -}}
{{- $configmapValues := $configmap -}}
{{/* set the default nameOverride to the configMap name */}}
{{- if not $configmapValues.nameOverride -}}
{{- $_ := set $configmapValues "nameOverride" $name -}}
{{ end -}}
{{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}}
{{- include "common.classes.configmap" $ }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,37 @@
{{/*
This template serves as a blueprint for all configMap objects that are created
within the common library.
*/}}
{{- define "common.classes.configmap" -}}
{{- $fullName := include "common.names.fullname" . -}}
{{- $configMapName := $fullName -}}
{{- $values := .Values.configmap -}}
{{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.configmap -}}
{{- $values = . -}}
{{- end -}}
{{ end -}}
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
{{- $configMapName = printf "%v-%v" $configMapName $values.nameOverride -}}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $configMapName }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with $values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{- with $values.data }}
{{- tpl (toYaml .) $ | nindent 2 }}
{{- end }}
{{- end }}
@@ -34,6 +34,23 @@ Volumes included by the controller.
{{- $_ := set $emptyDir "sizeLimit" . -}}
{{- end }}
emptyDir: {{- $emptyDir | toYaml | nindent 4 }}
{{- else if or (eq $persistence.type "configMap") (eq $persistence.type "secret") }}
{{- $objectName := (required (printf "objectName not set for persistence item %s" $index) $persistence.objectName) }}
{{- $objectName = tpl $objectName $ }}
{{- if eq $persistence.type "configMap" }}
configMap:
name: {{ $objectName }}
{{- else }}
secret:
secretName: {{ $objectName }}
{{- end }}
{{- with $persistence.defaultMode }}
defaultMode: {{ . }}
{{- end }}
{{- with $persistence.items }}
items:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- else if eq $persistence.type "hostPath" }}
hostPath:
path: {{ required "hostPath not set" $persistence.hostPath }}
+50 -1
View File
@@ -541,6 +541,21 @@ deviceList: []
# @default -- []
persistenceList: []
# -- Configure configMaps for the chart here.
# Additional configMaps can be added by adding a dictionary key similar to the 'config' object.
# @default -- See below
configmap:
config:
# -- Enables or disables the configMap
enabled: false
# -- Labels to add to the configMap
labels: {}
# -- Annotations to add to the configMap
annotations: {}
# -- configMap data content. Helm template enabled.
data: {}
# foo: bar
# -- Configure persistence for the chart here.
# Additional items can be added by adding a dictionary key similar to the 'config' key.
# @default -- See below
@@ -565,7 +580,7 @@ persistence:
labels: {}
# -- Sets the persistence type
# Valid options are: simplePVC, simpleHP, pvc, emptyDir, hostPath or custom
# Valid options are: simplePVC, simpleHP, pvc, emptyDir, secret, configMap, hostPath or custom
type: pvc
# -- force the complete PVC name
@@ -723,6 +738,40 @@ persistence:
# defaultMode: 420
# name: my-settings
# -- Example of a configmap mount
# @default -- See below
configmap-example:
enabled: false
type: configmap
# -- Specify the name of the configmap object to be mounted
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
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: 777
# -- Define the secret items to be mounted
items:
- key: username
path: my-group/my-username
# -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance.
volumeClaimTemplates: []
# data: