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