Skip to content

Commit

Permalink
Jupyterlab baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
wreis committed Nov 24, 2023
1 parent 546bae8 commit fcd2ddc
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 18 deletions.
17 changes: 4 additions & 13 deletions addons.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
microk8s-addons:
description: "My awesome demo repository."
addons:
- name: "python-hello-k8s"
description: "Demo addon implemented in python"
version: "1.0.0"
check_status: "deployment.apps/python-demo-nginx"
- name: "jupyterlab"
description: "Jupyterlab Workspace"
version: "0.0.1"
check_status: "statefulset.apps/jupyterlab"
supported_architectures:
- arm64
- amd64

- name: "bash-hello-k8s"
description: "Bash based demo addon"
version: "1.0.0"
check_status: "deployment.apps/bash-demo-nginx"
supported_architectures:
- amd64
- arm64
- s390x
11 changes: 11 additions & 0 deletions addons/jupyterlab/disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -e
set -e

HELM="${SNAP}/microk8s-helm.wrapper"
NAMESPACE="jupyterlab"

echo "Disabling jupyterlab workspace"

"${HELM}" uninstall jupyterlab -n "${NAMESPACE}"

echo "Disabled jupyterlab workspace"
17 changes: 17 additions & 0 deletions addons/jupyterlab/enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

HELM="${SNAP}/microk8s-helm.wrapper"

NAMESPACE="jupyterlab"
VERSION=0.0.1

echo "Enabling jupyterlab workspace"

"${HELM}" package --destination /tmp/microk8s-charts --version ${VERSION} ./addons/jupyterlab/jupyterlab
"${HELM}" upgrade -n "${NAMESPACE}" jupyterlab /tmp/microk8s-charts/jupyterlab-${VERSION}.tgz --install --create-namespace "$@"

echo "
jupyterlab has been installed.
"
6 changes: 6 additions & 0 deletions addons/jupyterlab/jupyterlab/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: jupyterlab
description: A Helm chart for jupyterlab application
type: application
version: 0.0.1
appVersion: 1.5.11-6
4 changes: 4 additions & 0 deletions addons/jupyterlab/jupyterlab/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- define "labels" }}
app.kubernetes.io/name: jupyterlab
app.kubernetes.io/managed-by: Helm
{{- end -}}
65 changes: 65 additions & 0 deletions addons/jupyterlab/jupyterlab/templates/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: jupyterlab
namespace: {{ .Release.Namespace }}
labels:
{{- include "labels" . | indent 2 }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: jupyterlab
serviceName: jupyterlab-headless
template:
metadata:
name:
labels:
{{- include "labels" . | indent 6 }}
spec:
enableServiceLinks: false
terminationGracePeriodSeconds: 5
containers:
- name: jupyterlab
image: docker.io/cschranz/gpu-jupyter:v1.5_cuda-11.6_ubuntu-20.04
imagePullPolicy: IfNotPresent
args:
- start.sh
- jupyter
- lab
- "--ServerApp.token=''"
- "--ContentsManager.allow_hidden=True"
env:
- name: JUPYTER_ENABLE_LAB
value: "yes"
- name: GRANT_SUDO
value: "yes"
- name: CHOWN_HOME
value: "yes"
- name: CHOWN_HOME_OPTS
value: "-R"
- name: CHOWN_EXTRA
value: "/var/run/secrets/eks.amazonaws.com,/var/run/secrets/kubernetes.io"
ports:
- name: http
containerPort: 8888
workingDir: /home/jovyan
volumeMounts:
- mountPath: /dev/shm
name: shm
- name: jupyterlab
mountPath: /home/jovyan
readOnly: false
volumes:
- name: shm
emptyDir:
medium: Memory
volumeClaimTemplates:
- metadata:
name: jupyterlab
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.storageSize | default "5G" }}
31 changes: 31 additions & 0 deletions addons/jupyterlab/jupyterlab/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
kind: Service
apiVersion: v1
metadata:
name: jupyterlab
namespace: {{ .Release.Namespace }}
labels:
{{- include "labels" . | indent 2 }}
spec:
selector:
app.kubernetes.io/name: jupyterlab
type: ClusterIP
ports:
- targetPort: http
port: 8888
---
apiVersion: v1
kind: Service
metadata:
name: jupyterlab-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "labels" . | indent 2 }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
selector:
app.kubernetes.io/name: jupyterlab
ports:
- targetPort: http
port: 8888
1 change: 1 addition & 0 deletions addons/jupyterlab/jupyterlab/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storageSize:
16 changes: 11 additions & 5 deletions tests/test-addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@


class TestAddons(object):
def test_python_demo_nginx(self):
microk8s_enable("python-hello-k8s")
wait_for_pod_state("", "default", "running", label="app=python-demo-nginx")
def test_jupyterlab(self):
microk8s_enable("jupyterlab")
wait_for_pod_state(
pod="",
namespace="default",
desired_state="running",
label="app.kubernetes.io/name=jupyterlab",
timeout_insec=1200,
)
status = yaml.load(sh.microk8s.status(format="yaml"))
expected = {"python-hello-k8s": "enabled"}
microk8s_disable("python-hello-k8s")
expected = {"jupyterlab": "enabled"}
microk8s_disable("jupyterlab")

0 comments on commit fcd2ddc

Please sign in to comment.