k8s/scripts/wallabag-vault.sh

21 lines
608 B
Bash
Raw Normal View History

2023-07-11 17:38:32 +00:00
#!/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