k8s/scripts/wallabag-vault.sh

20 lines
608 B
Bash
Executable file

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