From e9086ab1ac4c811d45be106056414bf148837894 Mon Sep 17 00:00:00 2001 From: Henrik Eidnes Nielsen Date: Tue, 26 Apr 2022 10:00:45 +0200 Subject: [PATCH] Deployment same name volume mounts --- helm/kitcaddy/README.md | 2 +- helm/kitcaddy/templates/kitcaddy-deployment.yaml | 10 ++++++++-- helm/kitcaddyExampleValues.yaml | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/helm/kitcaddy/README.md b/helm/kitcaddy/README.md index cbefd0b..463e6ca 100644 --- a/helm/kitcaddy/README.md +++ b/helm/kitcaddy/README.md @@ -110,7 +110,7 @@ Parameter | Description | Example **Deployment** | `deployment.containerPort` | Port on web-service | `8080` `deployment.configMapMountPath` | Set value if config map needs to mount on deployment | `/config` -`deplyment.extraVolumeMounts` | Extra volume mounts +`deplyment.extraVolumeMounts` | Extra volume mounts. Due to limitations of Helm, two mounts cannot refer to the same volume. This chart allows to ovecome this by adding `_` to the end of the name. Thus, `myEmptyDir_1` and `myEmptyDir_2` (and `myEmptyDir`) will refer to the same volume, with name `myEmptyDir`. `deplyment.readinessProbe` | Set values under this to config readiness probe `deplyment.livenessProbe` | Set values under this to config liveness probe **Deployment - Environment variables** | diff --git a/helm/kitcaddy/templates/kitcaddy-deployment.yaml b/helm/kitcaddy/templates/kitcaddy-deployment.yaml index bd51c39..7de1ed5 100644 --- a/helm/kitcaddy/templates/kitcaddy-deployment.yaml +++ b/helm/kitcaddy/templates/kitcaddy-deployment.yaml @@ -101,7 +101,13 @@ spec: {{- end }} {{- range $key, $value := .Values.deployment.extraVolumeMounts }} - mountPath: {{ $value.mountPath }} - name: {{ $key }} + {{- /* # Remove "_" at end of string */}} + {{ $underScoreSuffix := regexFind "_\\d+$" $key }} + {{ $newLength := int (sub (len $key) (len $underScoreSuffix)) }} + name: {{ substr 0 $newLength $key }} + {{- if ($value.subPath) }} + subPath: {{ $value.subPath }} + {{- end }} {{- end }} {{- if (.Values.deployment.livenessProbe) }} @@ -142,4 +148,4 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} \ No newline at end of file diff --git a/helm/kitcaddyExampleValues.yaml b/helm/kitcaddyExampleValues.yaml index cb68e55..0757969 100644 --- a/helm/kitcaddyExampleValues.yaml +++ b/helm/kitcaddyExampleValues.yaml @@ -167,9 +167,18 @@ kitcaddy: deployment: configMapMountPath: /config + extraVolumes: + myEmptyDir: | + emtpyDir: {} extraVolumeMounts: test123: mountPath: /123 + myDeploymentEmptyDir: + mountPath: /dir + myDeploymentEmptyDir_1: + mountPath: /dir1 + myDeploymentEmptyDir_2: + mountPath: /dir2 resources: limits: memory: 1Gi