From 614135933b3c990253e593e1ca69c8a04708c3d9 Mon Sep 17 00:00:00 2001 From: Lee moon soo Date: Mon, 3 Aug 2020 15:36:59 -0700 Subject: [PATCH] add starod integration --- .staroid/README.md | 18 ++++++++++ .staroid/build.sh | 18 ++++++++++ .staroid/k8s.yaml | 76 ++++++++++++++++++++++++++++++++++++++++++ .staroid/minikube.yaml | 19 +++++++++++ .staroid/skaffold.yaml | 18 ++++++++++ .staroid/staroid.yaml | 35 +++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 .staroid/README.md create mode 100755 .staroid/build.sh create mode 100644 .staroid/k8s.yaml create mode 100644 .staroid/minikube.yaml create mode 100644 .staroid/skaffold.yaml create mode 100644 .staroid/staroid.yaml 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..0d8f9a5 --- /dev/null +++ b/.staroid/build.sh @@ -0,0 +1,18 @@ +#!/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 + +# 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..25d7aee --- /dev/null +++ b/.staroid/k8s.yaml @@ -0,0 +1,76 @@ +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 + pod.staroid.com/spot: "false" + pod.staroid.com/instance-type: gpu-1 + spec: + automountServiceAccountToken: true + securityContext: + runAsUser: 1000 # will be overrided by staroid + 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" + - >- + mkdir -p ~/.ssh && chmod 700 ~/.ssh && + echo -n "$(echo $MLFLOW_TRACKING_URI | sed 's/.*\(mlflow[^:]*\).*/\1/g') " >> ~/.ssh/known_hosts && + echo $MLFLOW_ARTIFACT_STORE_RSA_PUB | base64 --decode >> ~/.ssh/known_hosts && + echo $MLFLOW_ARTIFACT_STORE_RSA_PRI | base64 --decode >> ~/.ssh/id_rsa && + chmod 600 ~/.ssh/* && + jupyter-lab --ip='*' --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*' + env: + - name: JUPYTER_ENABLE_LAB + value: "yes" + envFrom: + - configMapRef: + name: mlflow-env + 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 + storage.staroid.com/file-manager: "1000:100" +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..c251479 --- /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: + - k8s.yaml +profiles: + - name: minikube + patches: + - op: add + path: /deploy/kubectl/manifests/0 + value: minikube.yaml diff --git a/.staroid/staroid.yaml b/.staroid/staroid.yaml new file mode 100644 index 0000000..121c0d1 --- /dev/null +++ b/.staroid/staroid.yaml @@ -0,0 +1,35 @@ +# 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: {} +ingress: +- serviceName: jupyter + port: 8888 +deploy: + dependencies: + - project: open-datastudio/mlflow-server + level: OPTIONAL + 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"]