diff --git a/.staroid/Dockerfile.staroid b/.staroid/Dockerfile.staroid new file mode 100644 index 0000000..b2aa97e --- /dev/null +++ b/.staroid/Dockerfile.staroid @@ -0,0 +1 @@ +RUN conda install cudnn=7.6.5 --yes diff --git a/.staroid/README.md b/.staroid/README.md new file mode 100644 index 0000000..d60c611 --- /dev/null +++ b/.staroid/README.md @@ -0,0 +1,18 @@ +## gpu-jupyter on staroid + +This directory contains files to deploy gpu-jupyter project on [staroid](https://staroid.com). + +[![Run](https://staroid.com/api/run/button.svg)](https://staroid.com/api/run) + + +## Development + +Run locally with [skaffold](https://skaffold.dev) command. + +``` +$ git clone https://github.com/iot-salzburg/gpu-jupyter.git +$ cd gpu-jupyter +$ skaffold dev -f .staroid/skaffold.yaml --port-forward -p minikube +``` + +and browse `http://localhost:8888` diff --git a/.staroid/build.sh b/.staroid/build.sh new file mode 100755 index 0000000..b3c8f80 --- /dev/null +++ b/.staroid/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Custom builder script for Skaffold +# https://skaffold.dev/docs/pipeline-stages/builders/custom/ +# + +# generate Dockerfile +./generate-Dockerfile.sh -s --no-datascience-notebook --no-useful-packages +cd .build + +# apply staroid patch +cat ../.staroid/Dockerfile.staroid >> Dockerfile + +# print Dockerfile +cat Dockerfile + +# build +docker build -f Dockerfile -t $IMAGE . + +if $PUSH_IMAGE; then + docker push $IMAGE +fi diff --git a/.staroid/k8s.yaml b/.staroid/k8s.yaml new file mode 100644 index 0000000..a705a62 --- /dev/null +++ b/.staroid/k8s.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jupyter-deployment +spec: + replicas: 1 + strategy: + type: "Recreate" + selector: + matchLabels: + app: jupyter + template: + metadata: + labels: + app: jupyter + pod.staroid.com/isolation: dedicated # see https://docs.staroid.com/ske/pod.html#pod for more available options + pod.staroid.com/spot: "false" + pod.staroid.com/instance-type: gpu-1 + spec: + automountServiceAccountToken: true + securityContext: + runAsUser: 1000 # staroid requires non-root container + runAsGroup: 100 # writable directories are accessible with GID 100. see https://github.com/jupyter/docker-stacks/blob/master/base-notebook/Dockerfile + containers: + - name: jupyter + image: jupyter + command: + - "bash" + - "-c" + - >- + jupyter-lab --ip='*' --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*' + env: + - name: JUPYTER_ENABLE_LAB + value: "yes" + volumeMounts: + - name: work-volume + mountPath: /home/jovyan/work + volumes: + - name: work-volume + persistentVolumeClaim: + claimName: work +--- +kind: Service +apiVersion: v1 +metadata: + name: jupyter +spec: + ports: + - name: http + port: 8888 + selector: + app: jupyter +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: work + annotations: + storage.staroid.com/scope: Instance # see https://docs.staroid.com/ske/storage.html for available scope + storage.staroid.com/file-manager: "1000:100" # of file manager pod. This will display file manager button on staroid management console +spec: + storageClassName: nfs + accessModes: + - ReadWriteMany + volumeMode: Filesystem + resources: + requests: + storage: 1Gi diff --git a/.staroid/minikube.yaml b/.staroid/minikube.yaml new file mode 100644 index 0000000..c0c39ef --- /dev/null +++ b/.staroid/minikube.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jupyter-work-pv +spec: + accessModes: + - ReadWriteMany + capacity: + storage: 1Gi + hostPath: + path: ./jupyter-work-pv +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: nfs + labels: + addonmanager.kubernetes.io/mode: EnsureExists +provisioner: k8s.io/minikube-hostpath diff --git a/.staroid/skaffold.yaml b/.staroid/skaffold.yaml new file mode 100644 index 0000000..a54a56e --- /dev/null +++ b/.staroid/skaffold.yaml @@ -0,0 +1,18 @@ +apiVersion: skaffold/v2beta1 +kind: Config +build: + artifacts: + - image: jupyter + context: . + custom: + buildCommand: .staroid/build.sh +deploy: + kubectl: + manifests: + - .staroid/k8s.yaml +profiles: + - name: minikube + patches: + - op: add + path: /deploy/kubectl/manifests/0 + value: .staroid/minikube.yaml diff --git a/.staroid/staroid.yaml b/.staroid/staroid.yaml new file mode 100644 index 0000000..5b76fae --- /dev/null +++ b/.staroid/staroid.yaml @@ -0,0 +1,33 @@ +# See https://docs.staroid.com/references/staroid_yaml.html for more configuration detail +apiVersion: beta/v1 +starRank: + rate: 1.0 # set community rate here. https://staroid.com/site/starrank +build: + skaffold: + file: .staroid/skaffold.yaml +ingress: +- serviceName: jupyter + port: 8888 +deploy: + paramGroups: + - name: Configurations + params: + - name: "Instance type" + description: "GPU instance is supported only in AWS for now" + type: STRING + defaultValue: gpu-1 + options: + - name: gpu-1 (8CPU, 61GB Mem, 1 GPU - Tesla V100 16GB Mem) + value: gpu-1 + paths: + - Deployment:jupyter-deployment:spec.template.metadata.labels["pod.staroid.com/instance-type"] + - name: "Spot instance" + type: STRING + defaultValue: "false" + options: + - name: "false" + value: "false" + - name: "true" + value: "true" + paths: + - Deployment:jupyter-deployment:spec.template.metadata.labels["pod.staroid.com/spot"]