add support for more flexible volume mounts. Include example values for init container (#314)

add unit tests

add missing braces
This commit is contained in:
georgekaz 2020-07-14 15:23:08 +01:00 committed by GitHub
parent 5110f0f930
commit 8c741f6276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 2 deletions

View file

@ -98,6 +98,9 @@ extra volumes the user may have specified (such as a secret with TLS).
{{- end }}
defaultMode: {{ .defaultMode | default 420 }}
{{- end }}
{{- if .Values.server.volumes }}
{{- toYaml .Values.server.volumes | nindent 8}}
{{- end }}
{{- end -}}
{{/*
@ -160,6 +163,9 @@ based on the mode configured.
readOnly: true
mountPath: {{ .path | default "/vault/userconfig" }}/{{ .name }}
{{- end }}
{{- if .Values.server.volumeMounts }}
{{- toYaml .Values.server.volumeMounts | nindent 12}}
{{- end }}
{{- end -}}
{{/*

View file

@ -225,7 +225,7 @@ load _helpers
#--------------------------------------------------------------------
# extraVolumes
@test "server/standalone-StatefulSet: adds extra volume" {
@test "server/standalone-StatefulSet: server.extraVolumes adds extra volume" {
cd `chart_dir`
# Test that it defines it
@ -293,7 +293,7 @@ load _helpers
[ "${actual}" = "/vault/userconfig/foo" ]
}
@test "server/standalone-StatefulSet: adds extra secret volume" {
@test "server/standalone-StatefulSet: server.extraVolumes adds extra secret volume" {
cd `chart_dir`
# Test that it defines it
@ -370,6 +370,49 @@ load _helpers
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "audit")' | tee /dev/stderr)
}
#--------------------------------------------------------------------
# volumes
@test "server/standalone-StatefulSet: server.volumes adds volume" {
cd `chart_dir`
# Test that it defines it
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.volumes[0].name=plugins' \
--set 'server.volumes[0].emptyDir=\{\}' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "plugins")' | tee /dev/stderr)
local actual=$(echo $object |
yq -r '.emptyDir' | tee /dev/stderr)
[ "${actual}" = "{}" ]
}
#--------------------------------------------------------------------
# volumeMounts
@test "server/standalone-StatefulSet: server.volumeMounts adds volumeMount" {
cd `chart_dir`
# Test that it defines it
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.volumeMounts[0].name=plugins' \
--set 'server.volumeMounts[0].mountPath=/usr/local/libexec/vault' \
--set 'server.volumeMounts[0].readOnly=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "plugins")' | tee /dev/stderr)
local actual=$(echo $object |
yq -r '.mountPath' | tee /dev/stderr)
[ "${actual}" = "/usr/local/libexec/vault" ]
local actual=$(echo $object |
yq -r '.readOnly' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
#--------------------------------------------------------------------
# extraEnvironmentVars

View file

@ -184,6 +184,20 @@ server:
# This is useful if you need to run a script to provision TLS certificates or
# write out configuration files in a dynamic way.
extraInitContainers: null
# # This example installs a plugin pulled from github into the /usr/local/libexec/vault/oauthapp folder,
# # which is defined in the volumes value.
# - name: oauthapp
# image: "alpine"
# command: [sh, -c]
# args:
# - cd /tmp &&
# wget https://github.com/puppetlabs/vault-plugin-secrets-oauthapp/releases/download/v1.2.0/vault-plugin-secrets-oauthapp-v1.2.0-linux-amd64.tar.xz -O oauthapp.xz &&
# tar -xf oauthapp.xz &&
# mv vault-plugin-secrets-oauthapp-v1.2.0-linux-amd64 /usr/local/libexec/vault/oauthapp &&
# chmod +x /usr/local/libexec/vault/oauthapp
# volumeMounts:
# - name: plugins
# mountPath: /usr/local/libexec/vault
# extraContainers is a list of sidecar containers. Specified as a YAML list.
extraContainers: null
@ -239,6 +253,22 @@ server:
# name: my-secret
# path: null # default is `/vault/userconfig`
# volumes is a list of volumes made available to all containers. These are rendered
# via toYaml rather than pre-processed like the extraVolumes value.
# The purpose is to make it easy to share volumes between containers.
volumes: null
# - name: plugins
# emptyDir: {}
# volumeMounts is a list of volumeMounts for the main server container. These are rendered
# via toYaml rather than pre-processed like the extraVolumes value.
# The purpose is to make it easy to share volumes between containers.
volumeMounts: null
# - mountPath: /usr/local/libexec/vault
# name: plugins
# readOnly: true
# Affinity Settings
# Commenting out or setting as empty the affinity variable, will allow
# deployment to single node services such as Minikube