From c4dde09600ea24f380da6287723d6429f474343f Mon Sep 17 00:00:00 2001 From: az Date: Thu, 4 Nov 2021 21:29:09 +0100 Subject: [PATCH] add scripts and update README for k3d --- .../local-integration-test/README.md | 22 ++++++++---- .../setup-local-s3-on-k3d.sh | 34 +++++++++++++++++++ .../local-integration-test/start-k3d.sh | 1 + 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100755 src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh create mode 100755 src/test/resources/local-integration-test/start-k3d.sh diff --git a/src/test/resources/local-integration-test/README.md b/src/test/resources/local-integration-test/README.md index 381b727..6903d60 100644 --- a/src/test/resources/local-integration-test/README.md +++ b/src/test/resources/local-integration-test/README.md @@ -34,24 +34,32 @@ Note: In case of not being able to connect to "k3stesthost/health", you might ne - check files `aws --endpoint-url=http://k3stesthost s3 ls s3://mybucket` -## Deploy nextcloud +## Deploy nextcloud ### Requirements * leiningen (install with: `sudo apt install leiningen` ) - -### Deploy - -* In the project's root execute: -`lein uberjar` - +* 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"`). +### Deploy to k3s + * 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 -` 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 * add possibility to use local certificate in dda-backup backup function diff --git a/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh b/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh new file mode 100755 index 0000000..b445528 --- /dev/null +++ b/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh @@ -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 $@ diff --git a/src/test/resources/local-integration-test/start-k3d.sh b/src/test/resources/local-integration-test/start-k3d.sh new file mode 100755 index 0000000..0fd99ff --- /dev/null +++ b/src/test/resources/local-integration-test/start-k3d.sh @@ -0,0 +1 @@ +k3d cluster create nextcloud --k3s-arg '--tls-san cloudhost@loadbalancer' --port 8080:80@loadbalancer --port 8443:443@loadbalancer --api-port 6443 \ No newline at end of file