k8s/scripts/immich.sh

22 lines
624 B
Bash
Raw Normal View History

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