This repository has been archived by the owner on Jun 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubernetes-jupyterhub-install.bash
executable file
·54 lines (39 loc) · 2.18 KB
/
kubernetes-jupyterhub-install.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
# Set up a cluster (this uses the OpenNebula API through a Python interface):
python3 -m pip install oca
python3 create-new-cluster.py 3
# create-new-cluster also updates hosts.ini, ~/.ssh/config and ~/.ssh/known_hosts
# Give the cluster machines some time to really get started and update themselves
sleep 15
# Get the Ip of the client machine (the controller)
# On MacOS:
clientip=$(ipconfig getifaddr en0)
# On Linux:
#clientip=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
# Update intnet_vars.yml, to include the correct control machine IP for the firewall on the controller
sed "s/\${clientip}/${clientip}/" intnet_vars_local.yml > intnet_vars.yml
# Run the Ansible playbook to install the necessary software on the nodes, and open the necessary ports in the firewall.
# Turn off confirmation for ssh-ing into unknown hosts
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook -i hosts.ini --become --user ubuntu playbook.yml -vv
# nodes are named knode0, knode1 etc in ~/.ssh/config
# Copy the kube config to the local machine:
scp knode0:.kube/config ~/.kube/config
# Install Helm & Tiller: helm-tiller-installation.txt
sh helm-tiller-install.sh
# Create some data dirs persistentvolumes as storage for pods:
# Note: /mnt/data/pv-user created in the ansible playbook
ssh knode2 sudo mkdir /mnt/data/pv-hub
kubectl apply -f storage.yaml
# Create and adjust JupyterHub configuration file: jupyterhub-config.yaml
# Install JupyterHub via Helm: helm-jupyterhub-install.txt
sh helm-jupyterhub-install.sh
# Find the internal IP JupyterHub's proxy-public
pp_internalIP=$(kubectl get svc -n jhub -lapp=jupyterhub,component=proxy-public -o=jsonpath="{.items[0]['spec']['clusterIP']}")
# Substitue this IP into the Nginx default template, copy it over, and restart nginx
sed "s/\${pp_internalIP}/${pp_internalIP}/" nginx_default_template > nginx_default
scp nginx_default knode0:/tmp/nginx_default
ssh knode0 sudo cp /tmp/nginx_default /etc/nginx/sites-available/default
ssh knode0 sudo systemctl restart nginx
frontendip=$(sed -n 's/^node0 ansible_host=\(..*\)$/\1/p' hosts.ini)
echo "Done. Find your JupyterHub at http://controller.eucp-nlesc.surf-hosted.nl or at http://${frontendip}"