From 9728b623a796fcd73fba15bc396c39ebaab8366b Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Sun, 14 Jul 2024 00:07:04 +0200 Subject: [PATCH 1/3] added default path for config maps path --- charts/microservice-chart/templates/deployments.yaml | 7 ++++--- charts/microservice-chart/values.yaml | 9 ++++++++- tests/v5-java-helm-complete-test-foo/helm/Chart.lock | 6 +++--- tests/v5-java-helm-complete-test-foo/helm/Chart.yaml | 2 +- .../helm/values-devopslab-dev.yaml | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/charts/microservice-chart/templates/deployments.yaml b/charts/microservice-chart/templates/deployments.yaml index 12b34ff..5c1e14b 100644 --- a/charts/microservice-chart/templates/deployments.yaml +++ b/charts/microservice-chart/templates/deployments.yaml @@ -1,4 +1,5 @@ {{- if .Values.deployment.create -}} +{{- $root := . }} apiVersion: apps/v1 kind: Deployment metadata: @@ -154,7 +155,7 @@ spec: {{- if .Values.configMapFromFile }} {{- range $key, $val := .Values.configMapFromFile }} - name: file-config - mountPath: "/mnt/file-config/{{ $key }}" + mountPath: "{{ $root.Values.configMapFromFileCustomPath }}/{{ $key }}" subPath: {{ $key }} readOnly: true {{- end }} @@ -162,7 +163,7 @@ spec: {{- if .Values.externalConfigMapFiles.create }} {{- range $i, $v := .Values.externalConfigMapFiles.configMaps }} - name: {{ $v.name }}-{{ $i }} - mountPath: "/mnt/file-config-external/{{ $v.name }}/{{ $v.key }}" + mountPath: "{{ $root.Values.externalConfigMapFilesCustomPath}}/{{ $v.name }}/{{ $v.key }}" subPath: {{ $v.key }} readOnly: true {{- end }} @@ -170,7 +171,7 @@ spec: {{- if .Values.providedVolumeMount.create }} {{- range $i, $v := .Values.providedVolumeMount.folders }} - name: file-azure-{{ $v.name }} - mountPath: "/mnt/file-azure/{{ $v.name }}" + mountPath: "{{ $root.Values.providedVolumeMountCustomPath }}/{{ $v.name }}" {{- end }} {{- end }} env: diff --git a/charts/microservice-chart/values.yaml b/charts/microservice-chart/values.yaml index 5952199..2fc1153 100644 --- a/charts/microservice-chart/values.yaml +++ b/charts/microservice-chart/values.yaml @@ -151,8 +151,10 @@ envConfig: {} # -- Load secrets as environment variables from kv envSecret: {} -# -- Configure files to mount as config maps +# -- Configure files to mount as config map. This files definition are inside the values*.yaml file configMapFromFile: {} +# -- CustomPath to allow to choose where to put your files +configMapFromFileCustomPath: "/mnt/file-config" # -- Environment config from k8s metadata envFieldRef: {} @@ -163,6 +165,9 @@ externalConfigMapFiles: create: false # -- (list) Config maps to mount as files: e.g. [{name: "configmap", key: "user.xml"}] configMaps: [] +# -- CustomPath to allow to choose where to put your files +externalConfigMapFilesCustomPath: "/mnt/file-config-external" + externalConfigMapValues: # -- (list) Config maps to mount as files: e.g. [{name: "configmap", key: "mykey"}] @@ -178,6 +183,8 @@ providedVolumeMount: create: false envSecret: {} folders: [] +# -- CustomPath to allow to choose where to put your files +providedVolumeMountCustomPath: "/mnt/file-azure" # -- Configure optional tmp volume to mount (Use instance storage) tmpVolumeMount: diff --git a/tests/v5-java-helm-complete-test-foo/helm/Chart.lock b/tests/v5-java-helm-complete-test-foo/helm/Chart.lock index 0f4cb74..1203b3c 100644 --- a/tests/v5-java-helm-complete-test-foo/helm/Chart.lock +++ b/tests/v5-java-helm-complete-test-foo/helm/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: microservice-chart repository: file://../../../charts/microservice-chart - version: 5.9.1 -digest: sha256:16387a60e66fc6d5437dbd006ca32f917f50cbf9f8e16d8afd3a9790e7caddc4 -generated: "2024-06-12T22:55:34.585351+02:00" + version: 5.10.0 +digest: sha256:48165ac976c5c7969df1ed0101896cd9c84e8fe2cbd0614f3ce2a8ed8dc7647b +generated: "2024-07-13T22:56:31.538446+02:00" diff --git a/tests/v5-java-helm-complete-test-foo/helm/Chart.yaml b/tests/v5-java-helm-complete-test-foo/helm/Chart.yaml index 4f6737d..c0e1356 100644 --- a/tests/v5-java-helm-complete-test-foo/helm/Chart.yaml +++ b/tests/v5-java-helm-complete-test-foo/helm/Chart.yaml @@ -6,5 +6,5 @@ version: 1.0.0 appVersion: 1.0.0 dependencies: - name: microservice-chart - version: 5.9.1 + version: 5.10.0 repository: file://../../../charts/microservice-chart diff --git a/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml b/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml index f10beb2..efb6e4e 100644 --- a/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml +++ b/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml @@ -17,6 +17,7 @@ microservice-chart: configMaps: - name: v5-complete-foo-configmap-files key: game.properties + mountPath: "/config/games.properties" - name: v5-complete-foo-configmap-files key: user-interface.xml From 5dbcc09a086f216ae3e782cddac155e8ad54d50b Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Sun, 14 Jul 2024 00:24:54 +0200 Subject: [PATCH 2/3] added mountPath inside externalConfigMapFiles --- README.md | 2 ++ charts/microservice-chart/templates/deployments.yaml | 6 +++++- charts/microservice-chart/values.yaml | 8 +++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 73ae50b..3b30554 100644 --- a/README.md +++ b/README.md @@ -212,12 +212,14 @@ All the files are created inside the path: `/mnt/file-config-external/ key: + mountPath: #(Optional) externalConfigMapFiles: create: true configMaps: - name: external-configmap-files key: game.properties + mountPath: "/config/game.properties" - name: external-configmap-files key: user-interface.xml ``` diff --git a/charts/microservice-chart/templates/deployments.yaml b/charts/microservice-chart/templates/deployments.yaml index 5c1e14b..df56a80 100644 --- a/charts/microservice-chart/templates/deployments.yaml +++ b/charts/microservice-chart/templates/deployments.yaml @@ -163,7 +163,11 @@ spec: {{- if .Values.externalConfigMapFiles.create }} {{- range $i, $v := .Values.externalConfigMapFiles.configMaps }} - name: {{ $v.name }}-{{ $i }} + {{- if $v.mountPath }} + mountPath: "{{ $v.mountPath }}" + {{- else }} mountPath: "{{ $root.Values.externalConfigMapFilesCustomPath}}/{{ $v.name }}/{{ $v.key }}" + {{- end }} subPath: {{ $v.key }} readOnly: true {{- end }} @@ -171,7 +175,7 @@ spec: {{- if .Values.providedVolumeMount.create }} {{- range $i, $v := .Values.providedVolumeMount.folders }} - name: file-azure-{{ $v.name }} - mountPath: "{{ $root.Values.providedVolumeMountCustomPath }}/{{ $v.name }}" + mountPath: "/mnt/file-azure/{{ $v.name }}" {{- end }} {{- end }} env: diff --git a/charts/microservice-chart/values.yaml b/charts/microservice-chart/values.yaml index 2fc1153..f42aa72 100644 --- a/charts/microservice-chart/values.yaml +++ b/charts/microservice-chart/values.yaml @@ -163,7 +163,7 @@ envFieldRef: {} # @default -- {} externalConfigMapFiles: create: false - # -- (list) Config maps to mount as files: e.g. [{name: "configmap", key: "user.xml"}] + # -- (list) Config maps to mount as files: e.g. [{name: "configmap", key: "user.xml", mountPath: "/config/user.xml" }] configMaps: [] # -- CustomPath to allow to choose where to put your files externalConfigMapFilesCustomPath: "/mnt/file-config-external" @@ -177,14 +177,12 @@ externalConfigMapValues: # Volumes # -# -- Configure mounted volumes with secrets needed to mount them +# -- Configure how secrets taken from SecretS storage Class are mounted inside the pod # @default -- {} providedVolumeMount: create: false envSecret: {} folders: [] -# -- CustomPath to allow to choose where to put your files -providedVolumeMountCustomPath: "/mnt/file-azure" # -- Configure optional tmp volume to mount (Use instance storage) tmpVolumeMount: @@ -194,7 +192,7 @@ tmpVolumeMount: - name: tmp mountPath: /tmp -# -- Configure optional volume that mount using a PVC +# -- Configure optional volume that will be mount (using a PVC) persistentVolumeClaimsMounts: create: false # -- (list) Mounts with pvc volume: (e.g. [{name: "tmp", mountPath: "/tmp", pvcName: "xyz"}]]) From 077ed69af6ba3939a1e4c43c172252a8c7445ff8 Mon Sep 17 00:00:00 2001 From: diegoitaliait Date: Sun, 14 Jul 2024 00:25:04 +0200 Subject: [PATCH 3/3] added mountPath inside externalConfigMapFiles --- .../helm/values-devopslab-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml b/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml index efb6e4e..67b6eeb 100644 --- a/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml +++ b/tests/v5-java-helm-complete-test-foo/helm/values-devopslab-dev.yaml @@ -17,7 +17,7 @@ microservice-chart: configMaps: - name: v5-complete-foo-configmap-files key: game.properties - mountPath: "/config/games.properties" + mountPath: "/config/game.properties" - name: v5-complete-foo-configmap-files key: user-interface.xml