deploy jupyter from kubernetes

4/2/2018

I am trying to deploy a jupyter notebook from Kubernetes; however, when I start jupyter and it prints a local host link, I am unable to open it on my computer because it's a "local host." Hence, it needs to be opened within the container.

However, I was unable to find any type of GUI desktop for kubernetes and I'm unsure how to open a browser to fire up the link. I saw some things about minikube. Is there a way to do this without using minikube?

The reason I am trying to install without minikube is because minikube requires hyper V and I have Windows 10 Home which is not compatible with hyper V.

-- Jonathan
jupyter-notebook
kubernetes

1 Answer

4/3/2018

The most common way to access an application in a pod is to use Service.

After creation, a Service object is assigned with a unique IP address (ClusterIP) which remains the same during the whole lifespan of the Service object. Pods can use this ClusterIP and port to access a subset of pods with labels matched to Service selector. When several pods are matched, Service chooses one of them as a destination by round-robin principle.

For example:

You can create a Service for your 2 nginx replicas with kubectl expose:

$ kubectl expose deployment/my-nginx 
service "my-nginx" exposed 

This is equivalent to kubectl create -f nginx-svc.yaml

with nginx-svc.yaml content as:

apiVersion: v1 
kind: Service 
metadata: 
 name: my-nginx 
 labels: 
   run: my-nginx 
spec: 
 ports: 
 - port: 80 
   protocol: TCP 
 selector: 
   run: my-nginx 

How to check your Service:

$ kubectl get svc my-nginx 
NAME       CLUSTER-IP    EXTERNAL-IP PORT(S)   AGE 
my-nginx   10.0.162.149   <none> 80/TCP    21s  

In some parts of your applications, you may want to expose Service onto an external IP address. Kubernetes supports two ways of doing this: NodePorts and LoadBalancers.
NodePort mode reserves one port on all cluster nodes and forwards traffic coming to this port to the pod which is matched to the selector.
In LoadBalancer mode, Service creates cloud load balancer and forwards traffic from the load balancer to the pod which is matched to the selector.
You can read more about it in the document Connecting Applications with Services

To avoid creating all these objects manually, you can use helm to generate and run objects based on a template for a particular application. Here is helm repository for jupiter notebook:

https://github.com/UNINETT/helm-charts

Kubernetes has WebUI called Dashboard. It doesn´t deploy by default, but it´s easy to deploy when you need it.

To deploy Dashboard, execute the following command:

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml 

To access Dashboard from your local workstation, you must create a secure channel to your Kubernetes cluster. Run the following command:

$ kubectl proxy 

Now access Dashboard at:

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.

To find out how to create sample user and log in, follow Creating sample user guide.

Since version 1.7 Dashboard by default has a minimal set of privileges and can only be accessed over HTTPS. Access Control guide can help you to extend user permissions.

In case you are limited with OS version, you can use free Oracle VirtualBox for minikube.

-- VAS
Source: StackOverflow