Skip to content

Commit 13ef8db

Browse files
Add configurable mountPath for audit/data storage (#393)
1 parent c16905e commit 13ef8db

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

templates/_helpers.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ based on the mode configured.
146146
{{- define "vault.mounts" -}}
147147
{{ if eq (.Values.server.auditStorage.enabled | toString) "true" }}
148148
- name: audit
149-
mountPath: /vault/audit
149+
mountPath: {{ .Values.server.auditStorage.mountPath }}
150150
{{ end }}
151151
{{ if or (eq .mode "standalone") (and (eq .mode "ha") (eq (.Values.server.ha.raft.enabled | toString) "true")) }}
152152
{{ if eq (.Values.server.dataStorage.enabled | toString) "true" }}
153153
- name: data
154-
mountPath: /vault/data
154+
mountPath: {{ .Values.server.dataStorage.mountPath }}
155155
{{ end }}
156156
{{ end }}
157157
{{ if and (ne .mode "dev") (or (.Values.server.standalone.config) (.Values.server.ha.config)) }}

test/unit/server-statefulset.bats

+50
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,56 @@ load _helpers
604604
[ "${actual}" = "0" ]
605605
}
606606

607+
@test "server/standalone-StatefulSet: default audit storage mount path" {
608+
cd `chart_dir`
609+
local object=$(helm template \
610+
--show-only templates/server-statefulset.yaml \
611+
--set 'server.auditStorage.enabled=true' \
612+
. | tee /dev/stderr |
613+
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "audit")' | tee /dev/stderr)
614+
615+
local actual=$(echo $object | yq -r '.mountPath' | tee /dev/stderr)
616+
[ "${actual}" = "/vault/audit" ]
617+
}
618+
619+
@test "server/standalone-StatefulSet: can configure audit storage mount path" {
620+
cd `chart_dir`
621+
local object=$(helm template \
622+
--show-only templates/server-statefulset.yaml \
623+
--set 'server.auditStorage.enabled=true' \
624+
--set 'server.auditStorage.mountPath=/var/log/vault' \
625+
. | tee /dev/stderr |
626+
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "audit")' | tee /dev/stderr)
627+
628+
local actual=$(echo $object | yq -r '.mountPath' | tee /dev/stderr)
629+
[ "${actual}" = "/var/log/vault" ]
630+
}
631+
632+
@test "server/standalone-StatefulSet: default data storage mount path" {
633+
cd `chart_dir`
634+
local object=$(helm template \
635+
--show-only templates/server-statefulset.yaml \
636+
--set 'server.dataStorage.enabled=true' \
637+
. | tee /dev/stderr |
638+
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "data")' | tee /dev/stderr)
639+
640+
local actual=$(echo $object | yq -r '.mountPath' | tee /dev/stderr)
641+
[ "${actual}" = "/vault/data" ]
642+
}
643+
644+
@test "server/standalone-StatefulSet: can configure data storage mount path" {
645+
cd `chart_dir`
646+
local object=$(helm template \
647+
--show-only templates/server-statefulset.yaml \
648+
--set 'server.dataStorage.enabled=true' \
649+
--set 'server.dataStorage.mountPath=/opt/vault' \
650+
. | tee /dev/stderr |
651+
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "data")' | tee /dev/stderr)
652+
653+
local actual=$(echo $object | yq -r '.mountPath' | tee /dev/stderr)
654+
[ "${actual}" = "/opt/vault" ]
655+
}
656+
607657
@test "server/standalone-StatefulSet: affinity is set by default" {
608658
cd `chart_dir`
609659
local actual=$(helm template \

values.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ server:
369369
enabled: true
370370
# Size of the PVC created
371371
size: 10Gi
372+
# Location where the PVC will be mounted.
373+
mountPath: "/vault/data"
372374
# Name of the storage class to use. If null it will use the
373375
# configured default Storage Class.
374376
storageClass: null
@@ -386,6 +388,8 @@ server:
386388
enabled: false
387389
# Size of the PVC created
388390
size: 10Gi
391+
# Location where the PVC will be mounted.
392+
mountPath: "/vault/audit"
389393
# Name of the storage class to use. If null it will use the
390394
# configured default Storage Class.
391395
storageClass: null

0 commit comments

Comments
 (0)