Add support for setting VAULT_RAFT_NODE_ID environment variable (#269)

* Add support for setting VAULT_RAFT_NODE_ID environment variable

* Update server-statefulset.yaml

* Update server-ha-statefulset.bats
This commit is contained in:
Yong Wen Chua 2020-04-27 23:38:26 +08:00 committed by GitHub
parent accbd222ec
commit 8cc3fdb167
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 7 deletions

View file

@ -87,6 +87,12 @@ spec:
fieldPath: metadata.name
- name: VAULT_CLUSTER_ADDR
value: "https://$(HOSTNAME).{{ template "vault.fullname" . }}-internal:8201"
{{- if and (eq (.Values.server.ha.raft.enabled | toString) "true") (eq (.Values.server.ha.raft.setNodeId | toString) "true") }}
- name: VAULT_RAFT_NODE_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- end }}
{{ template "vault.envs" . }}
{{- include "vault.extraEnvironmentVars" .Values.server | nindent 12 }}
{{- include "vault.extraSecretEnvironmentVars" .Values.server | nindent 12 }}

View file

@ -403,7 +403,6 @@ load _helpers
[ "${actual}" = "secret_key_1" ]
}
#--------------------------------------------------------------------
# VAULT_CLUSTER_ADDR renders
@ -425,6 +424,28 @@ load _helpers
[ "${actual}" = 'https://$(HOSTNAME).RELEASE-NAME-vault-internal:8201' ]
}
#--------------------------------------------------------------------
# VAULT_RAFT_NODE_ID renders
@test "server/ha-StatefulSet: raft node ID renders" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.ha.enabled=true' \
--set 'server.ha.raft.enabled=true' \
--set 'server.ha.raft.setNodeId=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)
local actual=$(echo $object |
yq -r '.[10].name' | tee /dev/stderr)
[ "${actual}" = "VAULT_RAFT_NODE_ID" ]
local actual=$(echo $object |
yq -r '.[10].valueFrom.fieldRef.fieldPath' | tee /dev/stderr)
[ "${actual}" = 'metadata.name' ]
}
#--------------------------------------------------------------------
# storage class

View file

@ -351,6 +351,8 @@ server:
# Enables Raft integrated storage
enabled: false
# Set the Node Raft ID to the name of the pod
setNodeId: false
config: |
ui = true