Add volume claim annotations (#364)
* Add templates for annotations to apply to PV. * Fix spacing for template injection. * Fix template logic, add unit tests.
This commit is contained in:
parent
0faf7cf21a
commit
622690e68b
3 changed files with 80 additions and 0 deletions
|
@ -179,6 +179,7 @@ storage might be desired by the user.
|
||||||
{{- if and (eq (.Values.server.dataStorage.enabled | toString) "true") (or (eq .mode "standalone") (eq (.Values.server.ha.raft.enabled | toString ) "true" )) }}
|
{{- if and (eq (.Values.server.dataStorage.enabled | toString) "true") (or (eq .mode "standalone") (eq (.Values.server.ha.raft.enabled | toString ) "true" )) }}
|
||||||
- metadata:
|
- metadata:
|
||||||
name: data
|
name: data
|
||||||
|
{{- include "vault.dataVolumeClaim.annotations" . | nindent 6 }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- {{ .Values.server.dataStorage.accessMode | default "ReadWriteOnce" }}
|
- {{ .Values.server.dataStorage.accessMode | default "ReadWriteOnce" }}
|
||||||
|
@ -192,6 +193,7 @@ storage might be desired by the user.
|
||||||
{{- if eq (.Values.server.auditStorage.enabled | toString) "true" }}
|
{{- if eq (.Values.server.auditStorage.enabled | toString) "true" }}
|
||||||
- metadata:
|
- metadata:
|
||||||
name: audit
|
name: audit
|
||||||
|
{{- include "vault.auditVolumeClaim.annotations" . | nindent 6 }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- {{ .Values.server.auditStorage.accessMode | default "ReadWriteOnce" }}
|
- {{ .Values.server.auditStorage.accessMode | default "ReadWriteOnce" }}
|
||||||
|
@ -395,6 +397,36 @@ Sets extra statefulset annotations
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Sets VolumeClaim annotations for data volume
|
||||||
|
*/}}
|
||||||
|
{{- define "vault.dataVolumeClaim.annotations" -}}
|
||||||
|
{{- if and (ne .mode "dev") (.Values.server.dataStorage.enabled) (.Values.server.dataStorage.annotations) }}
|
||||||
|
annotations:
|
||||||
|
{{- $tp := typeOf .Values.server.dataStorage.annotations }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{- tpl .Values.server.dataStorage.annotations . | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.server.dataStorage.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Sets VolumeClaim annotations for audit volume
|
||||||
|
*/}}
|
||||||
|
{{- define "vault.auditVolumeClaim.annotations" -}}
|
||||||
|
{{- if and (ne .mode "dev") (.Values.server.auditStorage.enabled) (.Values.server.auditStorage.annotations) }}
|
||||||
|
annotations:
|
||||||
|
{{- $tp := typeOf .Values.server.auditStorage.annotations }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{- tpl .Values.server.auditStorage.annotations . | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.server.auditStorage.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Set's the container resources if the user has set any.
|
Set's the container resources if the user has set any.
|
||||||
*/}}
|
*/}}
|
||||||
|
|
|
@ -1090,6 +1090,50 @@ load _helpers
|
||||||
[ "${actual}" = "true" ]
|
[ "${actual}" = "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "server/standalone-StatefulSet: auditStorage volumeClaim annotations string" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-statefulset.yaml \
|
||||||
|
--set 'server.auditStorage.enabled=true' \
|
||||||
|
--set 'server.auditStorage.annotations=vaultIsAwesome: true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.volumeClaimTemplates[1].metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/standalone-StatefulSet: dataStorage volumeClaim annotations string" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-statefulset.yaml \
|
||||||
|
--set 'server.dataStorage.enabled=true' \
|
||||||
|
--set 'server.dataStorage.annotations=vaultIsAwesome: true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.volumeClaimTemplates[0].metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/standalone-StatefulSet: auditStorage volumeClaim annotations yaml" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-statefulset.yaml \
|
||||||
|
--set 'server.auditStorage.enabled=true' \
|
||||||
|
--set 'server.auditStorage.annotations.vaultIsAwesome=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.volumeClaimTemplates[1].metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/standalone-StatefulSet: dataStorage volumeClaim annotations yaml" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-statefulset.yaml \
|
||||||
|
--set 'server.dataStorage.enabled=true' \
|
||||||
|
--set 'server.dataStorage.annotations.vaultIsAwesome=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.volumeClaimTemplates[0].metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "server/ha-standby-Service: generic annotations yaml" {
|
@test "server/ha-standby-Service: generic annotations yaml" {
|
||||||
cd `chart_dir`
|
cd `chart_dir`
|
||||||
local actual=$(helm template \
|
local actual=$(helm template \
|
||||||
|
|
|
@ -346,6 +346,8 @@ server:
|
||||||
storageClass: null
|
storageClass: null
|
||||||
# Access Mode of the storage device being used for the PVC
|
# Access Mode of the storage device being used for the PVC
|
||||||
accessMode: ReadWriteOnce
|
accessMode: ReadWriteOnce
|
||||||
|
# Annotations to apply to the PVC
|
||||||
|
annotations: {}
|
||||||
|
|
||||||
# This configures the Vault Statefulset to create a PVC for audit
|
# This configures the Vault Statefulset to create a PVC for audit
|
||||||
# logs. Once Vault is deployed, initialized and unseal, Vault must
|
# logs. Once Vault is deployed, initialized and unseal, Vault must
|
||||||
|
@ -361,6 +363,8 @@ server:
|
||||||
storageClass: null
|
storageClass: null
|
||||||
# Access Mode of the storage device being used for the PVC
|
# Access Mode of the storage device being used for the PVC
|
||||||
accessMode: ReadWriteOnce
|
accessMode: ReadWriteOnce
|
||||||
|
# Annotations to apply to the PVC
|
||||||
|
annotations: {}
|
||||||
|
|
||||||
# Run Vault in "dev" mode. This requires no further setup, no state management,
|
# Run Vault in "dev" mode. This requires no further setup, no state management,
|
||||||
# and no initialization. This is useful for experimenting with Vault without
|
# and no initialization. This is useful for experimenting with Vault without
|
||||||
|
|
Loading…
Reference in a new issue