Skip to content

Commit

Permalink
Add configmapFiles option that mounts single files vs a whole directo…
Browse files Browse the repository at this point in the history
…ry (#46)

* Add configmapFiles option that mounts single files vs a whole directory

* Bump version

* Add the configmap files to other containers + fix the configmap syntax
  • Loading branch information
cmmarslender authored Apr 5, 2024
1 parent bc94ddb commit c938d6b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/generic/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: generic
description: A generic helm chart that handles a bunch of common application deploy cases
type: application
version: 1.7.0
version: 1.8.0
11 changes: 11 additions & 0 deletions charts/generic/templates/configmap-files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Release.Name }}-files"
labels:
{{- include "generic.labels" . | nindent 4 }}
data:
{{- range $.Values.configmapFiles }}
{{ .filename }}: |
{{- .content | nindent 4 }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/generic/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
{{- range $.Values.configmapFiles }}
- name: configmap-files
mountPath: {{ .mountPath }}/{{ .filename }}
subPath: {{ .filename }}
{{- end }}
{{- end }}
{{- end }}
containers:
Expand Down Expand Up @@ -165,6 +170,11 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
{{- range $.Values.configmapFiles }}
- name: configmap-files
mountPath: {{ .mountPath }}/{{ .filename }}
subPath: {{ .filename }}
{{- end }}
{{- with .Values.deployment.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -231,6 +241,11 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
{{- range $.Values.configmapFiles }}
- name: configmap-files
mountPath: {{ .mountPath }}/{{ .filename }}
subPath: {{ .filename }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.sharedEmptyDirs }}
Expand All @@ -243,6 +258,14 @@ spec:
- name: configmap-file
configMap:
name: "{{ .Release.Name }}-file"
- name: configmap-files
configMap:
name: "{{ .Release.Name }}-files"
{{- range $.Values.configmapFiles }}
items:
- key: {{ .filename }}
path: {{ .filename }}
{{- end }}
{{- range .Values.volumes }}
- name: {{ .name }}
persistentVolumeClaim:
Expand Down
11 changes: 11 additions & 0 deletions charts/generic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ configmapFile:
values: {}
# filename: "file content"

# This is the newer alternative to configmapFile that mounts each file in the secret as a single file
# rather than overtaking the whole mountPath directory and deleting any files that may have existed there prior
# This also allows the flexibility of mounting many files to different mountpaths, since the mountpath is controlled
# per file
configmapFiles: []
# - mountPath: /etc/config
# filename: .env
# content: |
# file=content
# goes=here

volumes: []
# - name: example-volume
# mountPath: /my-example-volume
Expand Down

0 comments on commit c938d6b

Please sign in to comment.