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