Browse Source

Merge pull request #12 from j0hnL/master

adding jupyter hub deployment and fixes for kubernetes v1.15.10
John Lockman 5 years ago
parent
commit
1cb9dcd8d1

+ 16 - 0
roles/startservices/files/jhub-db-pv.yaml

@@ -0,0 +1,16 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: jupyterhub-db-pv
+spec:
+  capacity:
+    storage: 1Gi
+  accessModes:
+  - ReadWriteOnce
+  - ReadOnlyMany
+  - ReadWriteMany
+  nfs:
+    server: 10.0.0.1
+    path: /work/k8s/jhub-db
+  persistentVolumeReclaimPolicy: Retain
+

+ 50 - 0
roles/startservices/files/jupyter-pvc.yaml

@@ -0,0 +1,50 @@
+apiVersion: v1 
+kind: PersistentVolume 
+metadata: 
+  name: jupyter-nfs
+spec: 
+  capacity: 
+    storage: 1Gi 
+  accessModes: 
+    - ReadWriteMany 
+  nfs: 
+    server: 10.0.0.1
+    path: "/work/jupyter1" 
+
+---
+apiVersion: v1 
+kind: PersistentVolume 
+metadata: 
+  name: jupyter-hub-nfs
+spec: 
+  capacity: 
+    storage: 1Gi 
+  accessModes: 
+    - ReadWriteMany 
+  nfs: 
+    server: 10.0.0.1
+    path: "/work/jupyter2" 
+ 
+--- 
+kind: PersistentVolumeClaim 
+apiVersion: v1 
+metadata: 
+  name: jupyter-nfs-pvc
+spec: 
+  accessModes: 
+    - ReadWriteMany 
+  storageClassName: "nfs" 
+  resources: 
+    requests: 
+
+--- 
+kind: PersistentVolumeClaim 
+apiVersion: v1 
+metadata: 
+  name: jupyter-hub-nfs-pvc
+spec: 
+  accessModes: 
+    - ReadWriteMany 
+  storageClassName: "nfs" 
+  resources: 
+    requests: 

+ 62 - 0
roles/startservices/files/jupyter_config.yaml

@@ -0,0 +1,62 @@
+proxy:
+  secretToken: "1c8572f630701e8792bede122ec9c4179d9087f801e1a85ed32cce69887aec1b"
+
+hub:
+  cookieSecret: "1c8572f630701e8792bede122ec9c4179d9087f801e1a85ed32cce69887aec1b"
+  service:
+    type: LoadBalancer
+  db: 
+    type: sqlite-pvc 
+  extraConfig:
+    jupyterlab: |
+      c.Spawner.cmd = ['jupyter-labhub']
+
+singleuser:
+  image:
+    name: jupyter/minimal-notebook
+    tag: 2343e33dec46
+  profileList:
+    - display_name: "Minimal environment"
+      description: "Short and sweet, no bells or whistles, vanilla: Python."
+      default: true
+    - display_name: "Datascience environment"
+      description: "Some additional bells and whistles: Python, R, and Julia."
+      kubespawner_override:
+        image: jupyter/datascience-notebook:2343e33dec46
+    - display_name: "Spark environment"
+      description: "The Jupyter Stacks with Spark"
+      kubespawner_override:
+        image: jupyter/all-spark-notebook:2343e33dec46
+    - display_name: "Learning Data Science"
+      description: "Datascience Environment with Sample Notebooks"
+      kubespawner_override:
+        image: jupyter/datascience-notebook:2343e33dec46
+        lifecycle_hooks:
+          postStart:
+            exec:
+              command:
+                - "sh"
+                - "-c"
+                - >
+                  gitpuller https://github.com/data-8/materials-fa17 master materials-fa;
+    - display_name: "GPU Environment"
+      description: "1 GPU for intro folks"
+      kubespawner_override:
+        image: jupyter/datascience-notebook:2343e33dec46
+        extra_resource_limits:
+          nvidia.com/gpu: "1"
+  storage:
+    dynamic:
+      storageClass: nfs-client
+  cpu:
+    limit: 1
+  memory:
+    limit: 100G
+    guarantee: 1G
+  defaultUrl: "/lab"
+
+
+prePuller:
+  continuous:
+    enabled: true
+

+ 45 - 1
roles/startservices/tasks/main.yml

@@ -1,4 +1,12 @@
 ---
+- name: Kick CoreDNS (needed for kubernetes <= v1.15.10)
+  shell:  kubectl get pods -n kube-system --no-headers=true | awk '/coredns/{print $1}'|xargs kubectl delete -n kube-system pod
+  tags: init
+
+- name: Wait for CoreDNS to restart 
+  shell: kubectl rollout status deployment/coredns -n kube-system
+  tags: init
+
 - name: Deploy MetalLB
   shell: kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml
   tags: init
@@ -23,14 +31,50 @@
   shell: kubectl create serviceaccount --namespace kube-system tiller
   tags: init
 
-- name: Helm - create cluster role Binding
+- name: Helm - create clusterRole Binding for tiller-cluster-rule
   shell: kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
   tags: init
 
+- name: Helm - create clusterRoleBinding for admin
+  shell: kubectl create clusterrolebinding tiller-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
+  tags: init
+
 - name: Helm - init
   shell: helm init  --upgrade
   tags: init
 
+- name: Wait for tiller to start 
+  shell: kubectl rollout status deployment/tiller-deploy -n kube-system
+  tags: init
+
+- name: Helm - patch cluster Role Binding for tiller
+  shell:  kubectl --namespace kube-system patch deploy tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
+  tags: init
+
+- name: Wait for tiller to start 
+  shell: kubectl rollout status deployment/tiller-deploy -n kube-system
+  tags: init
+
 - name: Start K8S Dashboard
   shell: kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml
   tags: init
+
+- name: Start NFS Client Provisioner
+  shell: helm install --name nfs  stable/nfs-client-provisioner --set nfs.server=10.0.0.1 --set nfs.path=/work
+  tags: init
+
+- name: JupyterHub Persistent Volume Creation (files)  
+  copy: src=jhub-db-pv.yaml dest=/root/k8s/jhub-db-pv.yaml owner=root group=root mode=655
+  tags: init
+
+- name: jupyterHub Persistent Volume creation
+  shell: kubectl create -f /root/k8s/jhub-db-pv.yaml
+  tags: init
+
+- name: JupyterHub Custom Config (files)  
+  copy: src=jupyter_config.yaml dest=/root/k8s/jupyter_config.yaml owner=root group=root mode=655
+  tags: init
+ 
+- name: jupyterHub deploy
+  shell: helm install jupyterhub/jupyterhub  --namespace default --version 0.8.2 --values /root/k8s/jupyter_config.yaml
+  tags: init