get nc working with localstack
- use 2 different hostnames for localstack resp. nextcloud - upd README
This commit is contained in:
parent
5e9db34b26
commit
abfa94b499
5 changed files with 34 additions and 16 deletions
|
@ -1,19 +1,20 @@
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
* Restic
|
* Restic (install with: `sudo apt install restic` )
|
||||||
* (optional) AWS-CLI
|
* (optional) AWS-CLI
|
||||||
|
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
`setup-local-s3.sh [BUCKET_NAME]`:
|
`setup-local-s3.sh [BUCKET_NAME]`:
|
||||||
|
- [BUCKET_NAME] is optional, "mybucket" will be used if not specified
|
||||||
- sets up a k3s instance
|
- sets up a k3s instance
|
||||||
- installs a localstack pod
|
- installs a localstack pod
|
||||||
- creates http and https routing to localstack via localhost
|
- creates http and https routing to localstack via localhost
|
||||||
- saves the self-signed certificate as ca.crt
|
- saves the self-signed certificate as ca.crt
|
||||||
- uses the certificate to initialize a restic repo at `https://localhost/BUCKET_NAME`
|
- uses the certificate to initialize a restic repo at `https://k3stesthost/BUCKET_NAME`
|
||||||
|
|
||||||
Note: In case of not being able to connect to "localhost/health", you might need to ensure that the ip of localhost matches with the ingress' ip. (See file /etc/hosts). With `sudo k3s kubectl get ingress` you can show the ingress' ip.
|
Note: In case of not being able to connect to "k3stesthost/health", you might need to ensure that the ingress' ip matches with the required host names: k3stesthost and cloudhost. With `sudo k3s kubectl get ingress` you can view the ingress' ip (e.g. 10.0.2.15), then add a line to file "/etc/hosts" e.g. `10.0.2.15 k3stesthost cloudhost`
|
||||||
|
|
||||||
`start-k3s.sh`:
|
`start-k3s.sh`:
|
||||||
- creates and starts a k3s instance
|
- creates and starts a k3s instance
|
||||||
|
@ -23,16 +24,32 @@ Note: In case of not being able to connect to "localhost/health", you might need
|
||||||
|
|
||||||
## Other useful commands
|
## Other useful commands
|
||||||
- `sudo k3s kubectl get pods`
|
- `sudo k3s kubectl get pods`
|
||||||
- `curl localhost/health`
|
- `curl k3stesthost/health`
|
||||||
expected: `{"services": {"s3": "running"}, "features": {"persistence": "disabled", "initScripts": "initialized"}}`
|
expected: `{"services": {"s3": "running"}, "features": {"persistence": "disabled", "initScripts": "initialized"}}`
|
||||||
|
|
||||||
#### Requires AWS-CLI
|
#### Requires AWS-CLI
|
||||||
- create bucket `aws --endpoint-url=http://localhost s3 mb s3://mybucket`
|
- create bucket `aws --endpoint-url=http://k3stesthost s3 mb s3://mybucket`
|
||||||
- list buckets `aws --endpoint-url=http://localhost s3 ls`
|
- list buckets `aws --endpoint-url=http://k3stesthost s3 ls`
|
||||||
- upload something `aws --endpoint-url=http://localhost s3 cp test.txt s3://mybucket`
|
- upload something `aws --endpoint-url=http://k3stesthost s3 cp test.txt s3://mybucket`
|
||||||
- check files `aws --endpoint-url=http://localhost s3 ls s3://mybucket`
|
- check files `aws --endpoint-url=http://k3stesthost s3 ls s3://mybucket`
|
||||||
|
|
||||||
|
|
||||||
|
## Deploy nextcloud
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
* leiningen (install with: `sudo apt install leiningen` )
|
||||||
|
|
||||||
|
### 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"`).
|
||||||
|
|
||||||
|
* 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 -`
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
* add possibility to use local certificate in dda-backup backup function
|
* add possibility to use local certificate in dda-backup backup function
|
||||||
|
|
|
@ -5,9 +5,9 @@ metadata:
|
||||||
namespace: default
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
secretName: localstack-secret
|
secretName: localstack-secret
|
||||||
commonName: localhost
|
commonName: k3stesthost
|
||||||
dnsNames:
|
dnsNames:
|
||||||
- localhost
|
- k3stesthost
|
||||||
issuerRef:
|
issuerRef:
|
||||||
name: selfsigning-issuer
|
name: selfsigning-issuer
|
||||||
kind: ClusterIssuer
|
kind: ClusterIssuer
|
||||||
|
|
|
@ -50,10 +50,10 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- localhost
|
- k3stesthost
|
||||||
secretName: localstack-secret
|
secretName: localstack-secret
|
||||||
rules:
|
rules:
|
||||||
- host: localhost
|
- host: k3stesthost
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
|
|
|
@ -10,13 +10,14 @@ function main()
|
||||||
|
|
||||||
until sudo k3s kubectl apply -f certificate.yaml
|
until sudo k3s kubectl apply -f certificate.yaml
|
||||||
do
|
do
|
||||||
|
echo "*** Waiting for certificate ... ***"
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "[INFO] Waiting for localstack health endpoint"
|
echo "[INFO] Waiting for localstack health endpoint"
|
||||||
until curl --connect-timeout 3 -s -f -o /dev/null "localhost/health"
|
until curl --connect-timeout 3 -s -f -o /dev/null "k3stesthost/health"
|
||||||
do
|
do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
@ -25,8 +26,8 @@ function main()
|
||||||
sudo k3s kubectl get secret localstack-secret -o jsonpath="{.data.ca\.crt}" | base64 --decode > ca.crt
|
sudo k3s kubectl get secret localstack-secret -o jsonpath="{.data.ca\.crt}" | base64 --decode > ca.crt
|
||||||
|
|
||||||
#aws --endpoint-url=http://localhost s3 mb s3://$bucket_name
|
#aws --endpoint-url=http://localhost s3 mb s3://$bucket_name
|
||||||
export RESTIC_PASSWORD="temporary-test-password"
|
export RESTIC_PASSWORD="test-password"
|
||||||
restic init --cacert ca.crt -r s3://localhost/$bucket_name
|
restic init --cacert ca.crt -r s3://k3stesthost/$bucket_name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
curl -sfL https://get.k3s.io | K3S_NODE_NAME=localhost sh -
|
curl -sfL https://get.k3s.io | K3S_NODE_NAME=k3stesthost INSTALL_K3S_EXEC='--tls-san cloudhost' sh -
|
||||||
|
|
Loading…
Reference in a new issue