Last active
March 27, 2019 20:11
-
-
Save voatsap/3f5f50374a33e87e3948a537f9b90796 to your computer and use it in GitHub Desktop.
initc-vault.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#echo "deploying kvp from vault with $VAULT_ADDR, $VAULT_ROLE, $VAULT_SECRET" | |
apk update >/dev/null 2>&1 | |
apk add jq >/dev/null 2>&1 | |
KUBE_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | |
VAULT_K8S_LOGIN=$(curl -s --request POST --data '{"jwt": "'"$KUBE_TOKEN"'", "role": "'"$VAULT_ROLE"'"}' $VAULT_ADDR/v1/auth/kubernetes/login) | |
X_VAULT_TOKEN=$(echo $VAULT_K8S_LOGIN | jq -r '.auth.client_token') | |
echo "vault{ | |
address = \"$VAULT_ADDR\" | |
token = \"$X_VAULT_TOKEN\" | |
}" > config.hcl | |
envconsul -pristine -upcase -config="./config.hcl" -secret="$VAULT_SECRET" env | awk -F "=" '{print$1"=\""$2"\""}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment