k8s/helm/nextcloud/install.sh

40 lines
1.1 KiB
Bash
Raw Normal View History

2022-12-31 03:00:39 +00:00
#!/bin/bash
CHART_VERSION=3.3.6
NAMESPACE=nextcloud
VAULT_AUTH_NAMESPACE="k8s-teapot"
helm repo add nextcloud https://nextcloud.github.io/helm/
helm repo update
kubectl create ns nextcloud
kubectl create serviceaccount -n ${NAMESPACE} nextcloud
cat << EOH > nextcloud.hcl
path "kv/data/nextcloud" {
capabilities = ["read"]
}
EOH
vault policy write nextcloud nextcloud.hcl
rm nextcloud.hcl
HOST_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
TOKEN="$(kubectl get secret serviceaccounttoken -n nextcloud -o go-template='{{ .data.token }}' | base64 -d)"
vault write auth/${VAULT_AUTH_NAMESPACE}/role/nextcloud \
bound_service_account_names=nextcloud \
bound_service_account_namespaces=nextcloud \
policies=nextcloud \
ttl=24h
vault write auth/${VAULT_AUTH_NAMESPACE}/login role=nextcloud jwt=${TOKEN} iss=https://${HOST_IP}:6443
kubectl apply -n ${NAMESPACE} -f external-secrets.yaml
kubectl apply -n ${NAMESPACE} -f pvc.yaml
helm upgrade --install \
nextcloud \
nextcloud/nextcloud \
-f values.yaml \
-n ${NAMESPACE} \
--version ${CHART_VERSION} \
--cleanup-on-fail