k8s/scripts/chartmuseum-vault.sh

20 lines
641 B
Bash
Executable file

#!/bin/bash
cat << EOH > chartmuseum.hcl
path "kv/data/chartmuseum" {
capabilities = ["read"]
}
EOH
vault policy write chartmuseum chartmuseum.hcl
rm chartmuseum.hcl
HOST_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
TOKEN="$(kubectl get secret serviceaccounttoken -n chartmuseum -o go-template='{{ .data.token }}' | base64 -d)"
vault write auth/${VAULT_AUTH_NAMESPACE}/role/chartmuseum \
bound_service_account_names=chartmuseum \
bound_service_account_namespaces=chartmuseum \
policies=chartmuseum \
ttl=24h
vault write auth/${VAULT_AUTH_NAMESPACE}/login role=chartmuseum jwt=${TOKEN} iss=https://${HOST_IP}:6443