Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault with multiple mount_points, roles and policies #154

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions charts/validators/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ data:
if [[ "$REIMPORT" = "true" ]]; then
# Authorization in Vault
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${VAULT_ADDR}/v1/sys/health)" != "200" ]]; do echo "Waiting for the vault to become available..." && sleep 5; done'
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
ROLE="${NAMESPACE}-${SERVICE_ACCOUNT}"
KUBE_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
VAULT_CLIENT=`curl --silent --request POST --data '{"jwt": "'"${KUBE_TOKEN}"'", "role": "'"${SERVICE_ACCOUNT}"'"}' ${VAULT_ADDR}/v1/auth/kubernetes/login`
VAULT_CLIENT=`curl --silent --request POST --data '{"jwt": "'"${KUBE_TOKEN}"'", "role": "'"${ROLE}"'"}' ${VAULT_ADDR}/v1/auth/kubernetes/login`
export VAULT_TOKEN="$(echo ${VAULT_CLIENT} | jq -r '.auth.client_token')"

# Get keystores password
rm -rf ${VAULT} || true && mkdir -p ${VAULT_KEYSTORES}
PASSWORD=$(vault kv get -field=password.txt -version=1 validators/${SERVICE_ACCOUNT}/password)
PASSWORD=$(vault kv get -field=password.txt -version=1 ${NAMESPACE}/${SERVICE_ACCOUNT}/password)
echo ${PASSWORD} > ${VAULT_PASSWORD}

# Preparing keystores for import
echo "$(vault kv get -version=1 validators/${SERVICE_ACCOUNT}/keystores)" > ${VAULT}/keystores.txt
echo "$(vault kv get -version=1 ${NAMESPACE}/${SERVICE_ACCOUNT}/keystores)" > ${VAULT}/keystores.txt
while read line; do
if [[ "$line" =~ ^keystore.* ]]; then
echo $line | awk '{ print substr($0, index($0,$2)) }' > ${VAULT_KEYSTORES}/`echo $line | awk '{print $1}'`
Expand Down