Adding server.enterpriseLicense (#547)
Sets up a vault-enterprise license for autoloading on vault startup. Mounts an existing secret to /vault/license and sets VAULT_LICENSE_PATH appropriately.
This commit is contained in:
parent
bb63d73b5a
commit
4d23074cd3
7 changed files with 104 additions and 4 deletions
|
@ -103,6 +103,12 @@ extra volumes the user may have specified (such as a secret with TLS).
|
|||
{{- if .Values.server.volumes }}
|
||||
{{- toYaml .Values.server.volumes | nindent 8}}
|
||||
{{- end }}
|
||||
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey) }}
|
||||
- name: vault-license
|
||||
secret:
|
||||
secretName: {{ .Values.server.enterpriseLicense.secretName }}
|
||||
defaultMode: 0440
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
|
@ -166,6 +172,11 @@ based on the mode configured.
|
|||
{{- if .Values.server.volumeMounts }}
|
||||
{{- toYaml .Values.server.volumeMounts | nindent 12}}
|
||||
{{- end }}
|
||||
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey) }}
|
||||
- name: vault-license
|
||||
mountPath: /vault/license
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
|
|
|
@ -125,6 +125,10 @@ spec:
|
|||
- name: VAULT_LOG_FORMAT
|
||||
value: "{{ .Values.server.logFormat }}"
|
||||
{{- end }}
|
||||
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey) }}
|
||||
- name: VAULT_LICENSE_PATH
|
||||
value: /vault/license/{{ .Values.server.enterpriseLicense.secretKey }}
|
||||
{{- end }}
|
||||
{{ template "vault.envs" . }}
|
||||
{{- include "vault.extraEnvironmentVars" .Values.server | nindent 12 }}
|
||||
{{- include "vault.extraSecretEnvironmentVars" .Values.server | nindent 12 }}
|
||||
|
|
|
@ -10,7 +10,8 @@ load _helpers
|
|||
--set='server.image.tag=1.7.2_ent' \
|
||||
--set='injector.enabled=false' \
|
||||
--set='server.ha.enabled=true' \
|
||||
--set='server.ha.raft.enabled=true' .
|
||||
--set='server.ha.raft.enabled=true' \
|
||||
--set='server.enterpriseLicense.secretName=vault-license' .
|
||||
wait_for_running "$(name_prefix)-east-0"
|
||||
|
||||
# Sealed, not initialized
|
||||
|
@ -78,7 +79,8 @@ load _helpers
|
|||
--set='server.image.repository=hashicorp/vault-enterprise' \
|
||||
--set='server.image.tag=1.7.2_ent' \
|
||||
--set='server.ha.enabled=true' \
|
||||
--set='server.ha.raft.enabled=true' .
|
||||
--set='server.ha.raft.enabled=true' \
|
||||
--set='server.enterpriseLicense.secretName=vault-license' .
|
||||
wait_for_running "$(name_prefix)-west-0"
|
||||
|
||||
# Sealed, not initialized
|
||||
|
@ -153,6 +155,7 @@ setup() {
|
|||
kubectl delete namespace acceptance --ignore-not-found=true
|
||||
kubectl create namespace acceptance
|
||||
kubectl config set-context --current --namespace=acceptance
|
||||
kubectl create secret generic vault-license --from-literal license=$VAULT_LICENSE_CI
|
||||
}
|
||||
|
||||
#cleanup
|
||||
|
|
|
@ -10,7 +10,8 @@ load _helpers
|
|||
--set='server.image.repository=hashicorp/vault-enterprise' \
|
||||
--set='server.image.tag=1.7.2_ent' \
|
||||
--set='server.ha.enabled=true' \
|
||||
--set='server.ha.raft.enabled=true' .
|
||||
--set='server.ha.raft.enabled=true' \
|
||||
--set='server.enterpriseLicense.secretName=vault-license' .
|
||||
wait_for_running "$(name_prefix)-east-0"
|
||||
|
||||
# Sealed, not initialized
|
||||
|
@ -78,7 +79,8 @@ load _helpers
|
|||
--set='server.image.repository=hashicorp/vault-enterprise' \
|
||||
--set='server.image.tag=1.7.2_ent' \
|
||||
--set='server.ha.enabled=true' \
|
||||
--set='server.ha.raft.enabled=true' .
|
||||
--set='server.ha.raft.enabled=true' \
|
||||
--set='server.enterpriseLicense.secretName=vault-license' .
|
||||
wait_for_running "$(name_prefix)-west-0"
|
||||
|
||||
# Sealed, not initialized
|
||||
|
@ -151,6 +153,7 @@ setup() {
|
|||
kubectl delete namespace acceptance --ignore-not-found=true
|
||||
kubectl create namespace acceptance
|
||||
kubectl config set-context --current --namespace=acceptance
|
||||
kubectl create secret generic vault-license --from-literal license=$VAULT_LICENSE_CI
|
||||
}
|
||||
|
||||
#cleanup
|
||||
|
|
|
@ -1566,3 +1566,59 @@ load _helpers
|
|||
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# enterprise license autoload support
|
||||
@test "server/StatefulSet: adds volume for license secret when enterprise license secret name and key are provided" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-s templates/server-statefulset.yaml \
|
||||
--set 'server.enterpriseLicense.secretName=foo' \
|
||||
--set 'server.enterpriseLicense.secretKey=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r -c '.spec.template.spec.volumes[] | select(.name == "vault-license")' | tee /dev/stderr)
|
||||
[ "${actual}" = '{"name":"vault-license","secret":{"secretName":"foo","defaultMode":288}}' ]
|
||||
}
|
||||
|
||||
@test "server/StatefulSet: adds volume mount for license secret when enterprise license secret name and key are provided" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-s templates/server-statefulset.yaml \
|
||||
--set 'server.enterpriseLicense.secretName=foo' \
|
||||
--set 'server.enterpriseLicense.secretKey=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r -c '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "vault-license")' | tee /dev/stderr)
|
||||
[ "${actual}" = '{"name":"vault-license","mountPath":"/vault/license","readOnly":true}' ]
|
||||
}
|
||||
|
||||
@test "server/StatefulSet: adds env var for license path when enterprise license secret name and key are provided" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-s templates/server-statefulset.yaml \
|
||||
--set 'server.enterpriseLicense.secretName=foo' \
|
||||
--set 'server.enterpriseLicense.secretKey=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r -c '.spec.template.spec.containers[0].env[] | select(.name == "VAULT_LICENSE_PATH")' | tee /dev/stderr)
|
||||
[ "${actual}" = '{"name":"VAULT_LICENSE_PATH","value":"/vault/license/bar"}' ]
|
||||
}
|
||||
|
||||
@test "server/StatefulSet: blank secretName does not set env var" {
|
||||
cd `chart_dir`
|
||||
|
||||
# setting secretName=null
|
||||
local actual=$(helm template \
|
||||
-s templates/server-statefulset.yaml \
|
||||
--set 'server.enterpriseLicense.secretName=null' \
|
||||
--set 'server.enterpriseLicense.secretKey=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r -c '.spec.template.spec.containers[0].env[] | select(.name == "VAULT_LICENSE_PATH")' | tee /dev/stderr)
|
||||
[ "${actual}" = '' ]
|
||||
|
||||
# omitting secretName
|
||||
local actual=$(helm template \
|
||||
-s templates/server-statefulset.yaml \
|
||||
--set 'server.enterpriseLicense.secretKey=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r -c '.spec.template.spec.containers[0].env[] | select(.name == "VAULT_LICENSE_PATH")' | tee /dev/stderr)
|
||||
[ "${actual}" = '' ]
|
||||
}
|
||||
|
|
|
@ -438,6 +438,17 @@
|
|||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"enterpriseLicense": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"secretKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretName": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extraArgs": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
12
values.yaml
12
values.yaml
|
@ -198,6 +198,18 @@ server:
|
|||
# If not set to true, Vault server will not be installed. See vault.mode in _helpers.tpl for implementation details
|
||||
enabled: true
|
||||
|
||||
# [Enterprise Only] This value refers to a Kubernetes secret that you have
|
||||
# created that contains your enterprise license. If you are not using an
|
||||
# enterprise image or if you plan to introduce the license key via another
|
||||
# route, then leave secretName blank ("") or set it to null.
|
||||
# Requires Vault Enterprise 1.8 or later.
|
||||
enterpriseLicense:
|
||||
# The name of the Kubernetes secret that holds the enterprise license. The
|
||||
# secret must be in the same namespace that Vault is installed into.
|
||||
secretName: ""
|
||||
# The key within the Kubernetes secret that holds the enterprise license.
|
||||
secretKey: "license"
|
||||
|
||||
# Resource requests, limits, etc. for the server cluster placement. This
|
||||
# should map directly to the value of the resources field for a PodSpec.
|
||||
# By default no direct resource request is made.
|
||||
|
|
Loading…
Reference in a new issue