add scripts and update README for k3d

This commit is contained in:
az 2021-11-04 21:29:09 +01:00
parent dd2ef8ec88
commit c4dde09600
3 changed files with 50 additions and 7 deletions

View file

@ -39,19 +39,27 @@ Note: In case of not being able to connect to "k3stesthost/health", you might ne
### Requirements ### Requirements
* leiningen (install with: `sudo apt install leiningen` ) * leiningen (install with: `sudo apt install leiningen` )
* In the project's root execute: `lein uberjar`
### Deploy
* In the project's root execute:
`lein uberjar`
* Change file "valid-config.edn" according to your settings (e.g. `:fqdn "cloudhost"` and `:restic-repository "s3://k3stesthost:mybucket"`). * Change file "valid-config.edn" according to your settings (e.g. `:fqdn "cloudhost"` and `:restic-repository "s3://k3stesthost:mybucket"`).
### Deploy to k3s
* Create and deploy the k8s yaml: * Create and deploy the k8s yaml:
`java -jar target/uberjar/c4k-nextcloud-standalone.jar valid-config.edn valid-auth.edn | sudo k3s kubectl apply -f -` `java -jar target/uberjar/c4k-nextcloud-standalone.jar valid-config.edn valid-auth.edn | sudo k3s kubectl apply -f -`
Some of the steps may take some min to be effective, but eventually nextcloud should be available at: https://cloudhost Some of the steps may take some min to be effective, but eventually nextcloud should be available at: https://cloudhost
### Deploy to k3d
k3d is a k3s system which is running inside of a container. To install k3d run `curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash` or have a look at https://k3d.io/v5.0.3/ .
* Start a k3d cluster and deploy s3 on it: `./setup-local-s3-on-k3d.sh`
* Create and deploy the c4k yaml for nextcloud (incl. postgres etc):
`java -jar target/uberjar/c4k-nextcloud-standalone.jar valid-config.edn valid-auth.edn | kubectl apply -f -`
* With `kubectl get ingress` you can view the ingress' ip (e.g. 10.0.2.15), add (resp. change if already existing) a line to file "/etc/hosts" e.g. `10.0.2.15 k3stesthost cloudhost`
Some of the steps may take some min to be effective, but eventually nextcloud should be available at: https://cloudhost
# TODO # TODO
* add possibility to use local certificate in dda-backup backup function * add possibility to use local certificate in dda-backup backup function

View file

@ -0,0 +1,34 @@
function main()
{
local bucket_name="${1:-mybucket}"; shift
./start-k3d.sh
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.4/cert-manager.yaml
kubectl apply -f localstack.yaml
until kubectl apply -f certificate.yaml
do
echo "*** Waiting for certificate ... ***"
sleep 10
done
echo
echo
echo "[INFO] Waiting for localstack health endpoint"
until curl --connect-timeout 3 -s -f -o /dev/null "k3stesthost/health"
do
sleep 5
done
echo
kubectl get secret localstack-secret -o jsonpath="{.data.ca\.crt}" | base64 --decode > ca.crt
#aws --endpoint-url=http://localhost s3 mb s3://$bucket_name
export RESTIC_PASSWORD="test-password"
restic init --cacert ca.crt -r s3://k3stesthost/$bucket_name
}
main $@

View file

@ -0,0 +1 @@
k3d cluster create nextcloud --k3s-arg '--tls-san cloudhost@loadbalancer' --port 8080:80@loadbalancer --port 8443:443@loadbalancer --api-port 6443