Skip to content

Commit

Permalink
Merge pull request #1336 from neicnordic/feature/k3d-ingress
Browse files Browse the repository at this point in the history
[Test] Add NGINX to k3d
  • Loading branch information
jbygdell authored Feb 10, 2025
2 parents a4ce140 + 81229e8 commit 5431014
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
16 changes: 13 additions & 3 deletions .github/integration/scripts/charts/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ random-string() {
}

if [ "$1" == "local" ]; then
if [ ! "$(command crypt4gh)" ]; then
if [ ! "$(command crypt4gh --version)" ]; then
echo "crypt4gh not installed, get it from here: https://github.com/neicnordic/crypt4gh/releases/latest"
exit 1
elif [ "$(crypt4gh --version | cut -d ' ' -f1)" == "GA4GH" ]; then
Expand All @@ -18,10 +18,20 @@ if [ "$1" == "local" ]; then
exit 1
fi

if [ ! "$(command yq)" ]; then
if [ ! "$(command yq --version)" ]; then
echo "yq not installed, get it from here: https://github.com/mikefarah/yq/releases/latest"
exit 1
fi

if [ ! "$(command jq --version)" ]; then
echo "jq not installed"
exit 1
fi

if [ ! "$(command xxd --version 2>&1)" ]; then
echo "xxd not installed"
exit 1
fi
else
sudo curl --retry 100 -sL "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -o /usr/bin/yq &&
sudo chmod +x /usr/bin/yq
Expand Down Expand Up @@ -104,4 +114,4 @@ yq -i '
.releasetest.secrets.accessToken = strenv(TEST_TOKEN)
' "$values_file"

kubectl create secret generic api-rbac --from-file=".github/integration/sda/rbac.json"
kubectl create secret generic api-rbac --from-file=".github/integration/sda/rbac.json"
1 change: 1 addition & 0 deletions .github/integration/scripts/charts/deploy_charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if [ "$1" == "sda-mq" ]; then
--set image.pullPolicy=IfNotPresent \
--set global.adminPassword="$ADMINPASS" \
--set global.adminUser=admin \
--set global.ingress.hostName=broker.127.0.0.1.nip.io \
--set global.tls.enabled="$3" \
--set global.tls.clusterIssuer=cert-issuer \
--set persistence.enabled=false \
Expand Down
11 changes: 6 additions & 5 deletions .github/integration/scripts/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
global:
schemaType: "isolated"
ingress:
deploy: false
deploy: true
hostName:
api: pipeline-sda-svc-api
auth: pipeline-sda-svc-auth
download: pipeline-sda-svc-download
s3Inbox: pipeline-sda-svc-inbox
api: api.127.0.0.1.nip.io
auth: auth.127.0.0.1.nip.io
download: download.127.0.0.1.nip.io
s3Inbox: inbox.127.0.0.1.nip.io
syncapi: sync-api.127.0.0.1.nip.io
log:
level: "debug"
tls:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ k3d-version-check:
echo "kubectl is missing";\
fi
k3d-create-cluster:
@k3d cluster create
@k3d cluster create --k3s-arg "--disable=traefik@server:0" --port "80:80@loadbalancer" --port "443:443@loadbalancer"; \
helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace
k3d-delete-cluster:
@k3d cluster delete
k3d-deploy-dependencies:
Expand Down
56 changes: 24 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,33 +176,34 @@ wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
```

Once installed a cluster named `test-cluster` can be created as such:
#### Install kubectl

If `kubectl` is not installed, run the following command to download the latest stable version. (substitue `linux/amd64` with `darwin/arm64` if you are using a Mac).

```sh
k3d cluster create test-cluster
curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
```

Or by using the `make k3d-create-cluster` command, you can create a cluster named `k3s-default`.
#### Create a cluster

Once installed a cluster can be created using the `make k3d-create-cluster` command, you can create a cluster named `k3s-default`.
The new cluster's connection details will automatically be merged into your default kubeconfig and activated. The command below should show the created node.
```sh
kubectl get nodes
```
Removing the cluster can be done using the `make k3d-delete-cluster` command or as shown below if a specific name is used during creation.
The Nginx ingress controller is deployed and will bind to ports 80 and 443 of the host system. A deployed service with an ingress definition can then be targeted by setting the `Host: HOSTNAME` header for that service.
```sh
k3d cluster delete test-cluster
curl -H "Host: test" http://localhost/
```
#### Install kubectl
For testing ingress endpoints with other applications like a web browser, the hostname in the ingress definition should have the `.127.0.0.1.nip.io` ending in order to not have to modify the `/etc/hosts` file, ex. `app.127.0.0.1.nip.io`.
If `kubectl` is not installed, run the following command to download the latest stable version. (substitue `linux/amd64` with `darwin/arm64` if you are using a Mac).
#### Remove the cluster
```sh
curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
```
Removing the cluster can be done using the `make k3d-delete-cluster` command or as shown below if a specific name is used during creation.
### Deploy the components
Expand All @@ -220,37 +221,28 @@ Deployment of the charts can be done as describe below in more detail, or by usi
#### Bootstrap the dependencies
This script requires [yq](https://github.com/mikefarah/yq/releases/latest) and the GO version of [crypt4gh](https://github.com/neicnordic/crypt4gh/releases/latest)
This script requires [yq](https://github.com/mikefarah/yq/releases/latest), the GO version of [crypt4gh](https://github.com/neicnordic/crypt4gh/releases/latest) as well as [xxd](https://manpages.org/xxd) and [jq](https://manpages.org/jq) to be installed.
```sh
bash .github/integration/scripts/charts/dependencies.sh local
```
Bootstrap the dependencies with the command: `make k3d-deploy-dependencies`.
#### Deploy the Sensitive Data Archive components
Start by building the required containers using the `make build-all` command, once that has completed the images can be imported to the cluster.
Start by building and importing the required containers using the `make k3d-import-images`.
```sh
bash .github/integration/scripts/charts/import_local_images.sh <CLUTER_NAME>
```
The Postgres and RabbitMQ Needs to be deployed first using the following commands: `make k3d-deplploy-postgres` and `make k3d-deploy-rabbitmq`.
The Postgres and RabbitMQ Needs to be deployed first, the bool at the end specifies if TLS should be enabled or not for the deployes services.
Replace `sda-db` in the example below with the helmc hart that shuld be installed. (`sda-db` or `sda-mq`)
Once the DB and MQ are installed the SDA stack can be installed, here the desired storage backend needs to specified as well (`posix` or `s3`), `make k3d-deplpoy-sda-posix` or `make k3d-deplpoy-sda-s3`.
```sh
bash .github/integration/scripts/charts/deploy_charts.sh sda-db "$(date +%F)" false
```
#### Testing with ingress
Once the DB and MQ are installed the SDA stack can be installed, here the desired storage backend needs to specified as well (`posix` or `s3`)
Once everything is deployed it is posible to interact with the services using the following hostnames:
```sh
bash .github/integration/scripts/charts/deploy_charts.sh sda-svc "$(date +%F)" false s3
```
- api.127.0.0.1.nip.io
- auth.127.0.0.1.nip.io
- broker.127.0.0.1.nip.io
- download.127.0.0.1.nip.io
- inbox.127.0.0.1.nip.io
#### Cleanup all deployed components
Once the testing is concluded all deployed components can be removed.
```sh
bash .github/integration/scripts/charts/cleanup.sh
```
Once the testing is concluded all deployed components can be removed with the command `make k3d-cleanup-all-deployments`

0 comments on commit 5431014

Please sign in to comment.