From 96fa8aac97cb9081c46ab9120cf27eceb4e5c9fb Mon Sep 17 00:00:00 2001 From: Simon Adorf Date: Tue, 6 Sep 2022 17:31:29 +0200 Subject: [PATCH 1/3] Provide instructions for testing on a local Minikube k8s cluster. --- README.md | 4 ++++ k8s/README.md | 38 ++++++++++++++++++++++++++++++++++++++ k8s/helm-install.sh | 13 +++++++++++++ k8s/values.dev.yml | 7 +++++++ 4 files changed, 62 insertions(+) create mode 100644 k8s/README.md create mode 100755 k8s/helm-install.sh create mode 100644 k8s/values.dev.yml diff --git a/README.md b/README.md index 7deb5c73..d39d708e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,10 @@ This will update the README.md file, make a commit, tag it, and then push both t To create a _special_ release, simply tag it with a tag name of your choice with the exception that it cannot start with the character `v`. +### Deploy AiiDAlab on Kubernetes + +Please see [here](k8s/README.md) for instructions on how to deploy AiiDAlab on Kubernetes. + ## Deploy AiiDAlab with AiiDAlab Launch The `aiidalab-launch` tool provides a convenient and robust method of both launching and managing one or multiple AiiDAlab instances on your computer. diff --git a/k8s/README.md b/k8s/README.md new file mode 100644 index 00000000..fb9979a2 --- /dev/null +++ b/k8s/README.md @@ -0,0 +1,38 @@ +# AiiDAlab on Kubernetes + +## Deploy on a local Minikube (Kubernetes) cluster for testing + +Here we provide instructions on how to run the stack on a local [Minikube Kubernetes cluster](https://minikube.sigs.k8s.io) for testing. + +Using Minikube is one approach to deploy a small local Kubernetes cluster, however alternatives exist (e.g. [kind](https://kind.sigs.k8s.io/), k3s, colima). +If you are not using Minikube you may have to adjust the instructions provided here slightly. + +First, [install Minikube](https://k8s-docs.netlify.app/en/docs/tasks/tools/install-minikube/) in your test environment and then start it, e.g., with `minikube start`. + +If you want to test locally built images, make sure to build them within your test environment, with +```console +eval $(minikube docker-env) +doit build +``` + +Before installing the deployment for the first time, execute: + +```console +helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ +helm repo update +``` + +Then execute `./k8s/helm-install.sh` to install AiiDAlab on the cluster. + +To expose the web server, you need to create a tunnel with +```console +minikube tunnel +``` + +You should then be able to access the server at the address shown by +```console +kubectl get svc proxy-public +``` + +Tip: Use ngrok to forward the server to the internet and access it from a different machine. +**Please be advised that this approach carries significant security risk and should only be used for testing!** diff --git a/k8s/helm-install.sh b/k8s/helm-install.sh new file mode 100755 index 00000000..5b18d202 --- /dev/null +++ b/k8s/helm-install.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e +set -u + +VERSION=$(dunamai from git --dirty | sed 's/+/_/g') + +helm upgrade aiidalab \ + jupyterhub/jupyterhub \ + --version=1.1.4 \ + --values k8s/values.dev.yml \ + --set singleuser.image.tag="${VERSION}" \ + --cleanup-on-fail \ + --install $@ diff --git a/k8s/values.dev.yml b/k8s/values.dev.yml new file mode 100644 index 00000000..51c34766 --- /dev/null +++ b/k8s/values.dev.yml @@ -0,0 +1,7 @@ +--- +singleuser: + image: + name: "aiidalab/full-stack" + tag: "latest" + pullPolicy: Never # To use locally built images + cmd: start-singleuser.sh From 13240b08c9f064ae45aec76f9bc81efcfd2c667b Mon Sep 17 00:00:00 2001 From: Simon Adorf Date: Tue, 13 Sep 2022 15:54:07 +0200 Subject: [PATCH 2/3] Increase timeout for singleuser-server startup. --- k8s/values.dev.yml | 4 ++++ tests/conftest.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/k8s/values.dev.yml b/k8s/values.dev.yml index 51c34766..a689f38e 100644 --- a/k8s/values.dev.yml +++ b/k8s/values.dev.yml @@ -5,3 +5,7 @@ singleuser: tag: "latest" pullPolicy: Never # To use locally built images cmd: start-singleuser.sh +hub: + extraConfig: + myConfig: | + c.KubeSpawner.http_timeout = 60 diff --git a/tests/conftest.py b/tests/conftest.py index 47206df2..1624811d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,7 +32,7 @@ def notebook_service(docker_ip, docker_services): port = docker_services.port_for("aiidalab", 8888) url = f"http://{docker_ip}:{port}" docker_services.wait_until_responsive( - timeout=30.0, pause=0.1, check=lambda: is_responsive(url) + timeout=60.0, pause=0.1, check=lambda: is_responsive(url) ) return url From 0f116a719504d875088c9074acdd4ecade5483e1 Mon Sep 17 00:00:00 2001 From: Simon Adorf Date: Thu, 15 Sep 2022 19:36:19 +0200 Subject: [PATCH 3/3] Add show-version task to doit. --- dodo.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dodo.py b/dodo.py index 9ca34bb5..755ae46f 100644 --- a/dodo.py +++ b/dodo.py @@ -35,6 +35,20 @@ } +def task_show_version(): + """Print the version for this repository.""" + + def show_version(version): + print(version) + + return { + "basename": "show-version", + "actions": [show_version], + "params": [_VERSION_PARAM], + "verbosity": 2, + } + + def task_build(): """Build all docker images."""