- Prerequisites
- Installation of Required Tools
- Kubernetes Cluster Setup
- Networking Setup
- Kubernetes Dashboard Installation
- JupyterHub Installation
- Accessing Services
- Troubleshooting
- A Linux system (Ubuntu 20.04 or later recommended)
sudo
access- Internet connection
-
Update the package index:
sudo apt-get update
-
Install packages to allow apt to use a repository over HTTPS:
sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release
-
Add Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-
Set up the stable repository:
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Install Docker Engine:
sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io
-
Verify that Docker Engine is installed correctly:
sudo docker run hello-world
-
Download the latest release:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
-
Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
-
Verify the installation:
kubectl version --client
-
Update the apt package index and install packages needed to use the Kubernetes apt repository:
sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl
-
Download the public signing key:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
-
Add the Kubernetes apt repository:
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
-
Update apt package index, install kubeadm, kubelet and kubectl, and pin their version:
sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl
-
Download the Helm installation script:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
-
Make the script executable:
chmod 700 get_helm.sh
-
Run the script:
./get_helm.sh
-
Verify the installation:
helm version
-
Disable swap:
sudo swapoff -a
-
Initialize the Kubernetes cluster:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --cri-socket=unix:///var/run/cri-dockerd.sock
-
Set up kubectl for the current user:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
-
Untaint the control-plane node to allow pod scheduling:
kubectl taint nodes $(hostname) node-role.kubernetes.io/control-plane-
-
Apply Flannel network plugin:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
-
Verify that all pods are running:
kubectl get pods --all-namespaces
-
Add the Kubernetes Dashboard Helm repository:
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
-
Install the Kubernetes Dashboard:
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard \ --create-namespace --namespace kubernetes-dashboard
-
Create a dashboard admin account:
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard kubectl create clusterrolebinding dashboard-admin \ --clusterrole=cluster-admin \ --serviceaccount=kubernetes-dashboard:dashboard-admin
-
Get the token for dashboard access:
kubectl -n kubernetes-dashboard create token dashboard-admin
-
Add the JupyterHub Helm repository:
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ helm repo update
-
Create a
jupyterhub-config.yaml
file with the following content:hub: config: Spawner: cpu_limit: 4 mem_limit: '16G' JupyterHub: auth: type: dummy dummy: password: 'set-a-secure-password' extraConfig: proxy: secretToken: "generate-a-secret-token-here" singleuser: extraResource: guarantees: cpu: "1" memory: 4Gi limits: cpu: "4" memory: 16Gi nvidia.com/gpu: "1" profileList: - display_name: "Small Instance" description: "Minimum resources for light workloads" kubespawner_override: cpu_guarantee: 1 cpu_limit: 2 mem_guarantee: "4G" mem_limit: "8G" - display_name: "GPU Instance" description: "Instance with GPU" kubespawner_override: cpu_guarantee: 2 cpu_limit: 4 mem_guarantee: "16G" mem_limit: "32G" extra_resource_limits: nvidia.com/gpu: "1" proxy: secretToken: "generate-a-secret-token-here" scheduling: userScheduler: enabled: true podPriority: enabled: true userPlaceholder: enabled: true replicas: 2 cull: enabled: true timeout: 3600 every: 300 singleuser: storage: type: dynamic dynamic: storageClass: local-storage capacity: 10Gi
-
Install JupyterHub using Helm:
helm install jhub jupyterhub/jupyterhub \ --namespace jhub \ --create-namespace \ --version=3.3.8 \ --values jupyterhub-config.yaml
-
Verify the installation:
kubectl get pods -n jhub
- Start the proxy:
kubectl -n kubernetes-dashboard port-forward --address 0.0.0.0 svc/kubernetes-dashboard-kong-proxy 8443:443
- Access the dashboard at
https://<your-ip>:8443
- Use the token generated earlier for authentication
- Start the proxy:
kubectl port-forward --address 0.0.0.0 -n jhub svc/proxy-public 8888:80
- Access JupyterHub at
http://<your-ip>:8888
-
If pods are stuck in Pending state, check node status and ensure resources are available:
kubectl describe node <node-name>
-
For networking issues, verify that the Flannel network plugin is properly installed and running:
kubectl get pods -n kube-system | grep flannel
-
Check logs of specific pods using:
kubectl logs -n <namespace> <pod-name>
-
For persistent volume issues, ensure that the storage class is properly configured and available:
kubectl get sc kubectl describe sc local-storage
-
If JupyterHub is not accessible, check the status of the jhub release:
helm status jhub -n jhub
-
To check the events in a namespace for troubleshooting:
kubectl get events -n <namespace>
Remember to replace placeholders like <your-ip>
, <node-name>
, and generate-a-secret-token-here
with your actual values.
For security reasons, make sure to change default passwords and tokens, and consider implementing more robust authentication methods in a production environment.