Skip to content

Commit

Permalink
Merge pull request #15 from KvalitetsIT/multiple-same-name-volume-mounts
Browse files Browse the repository at this point in the history
Deployment same name volume mounts
  • Loading branch information
NeutraChikara authored Apr 26, 2022
2 parents 2391c9d + e9086ab commit 6b1b704
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion helm/kitcaddy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `_<number>` 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** |
Expand Down
10 changes: 8 additions & 2 deletions helm/kitcaddy/templates/kitcaddy-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ spec:
{{- end }}
{{- range $key, $value := .Values.deployment.extraVolumeMounts }}
- mountPath: {{ $value.mountPath }}
name: {{ $key }}
{{- /* # Remove "_<number>" 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) }}
Expand Down Expand Up @@ -142,4 +148,4 @@ spec:
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions helm/kitcaddyExampleValues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b1b704

Please sign in to comment.