JupyterHub with Kubernetes On Single Bare Metal Instance Tutorial

But what happens when we try to reach the ip address through the browser?It appears that we cannot access Jupyterhub from the outside world.

Let’s dive in deeper.

Let’s check jhub serviceskubectl –namespace jhub get serviceThe proxy-public is looking for an external ip.

Recall that Kubernetes leverages a lot of cloud native services.

This proxy-public typically points to an actual cloud load balancer.

This tutorial focuses on using a single bare-metal instance to build the JupyterHub from the ground up, so we won’t be creating any expensive cloud load balancer.

What we can do is to create an internal software load balancer and have the Kubernetes cluster pointed to it!Configuring Metal Load BalancerTo do this will we use something called “Metal Load Balancer”Read more here: https://metallb.

universe.

tf/Create metal_config.

yaml using the following fileReplace PUBLIC_IP_ADDRESS with the actual public ip address of your instancevi metal_config.

yamlApply the default metallb.

yaml configuration firstkubectl apply -f https://raw.

githubusercontent.

com/google/metallb/v0.

7.

3/manifests/metallb.

yamlApply custom metal load balancer configuration — metal_config.

yamlkubectl apply -f metal_config.

yamlCheck the metal load balancer statuskubectl –namespace=metallb-system get podskubectl logs -l component=speaker -n metallb-systemMost important of all, check that the jhub picks up the external ip addresskubectl –namespace jhub get serviceWell done!.The proxy-public managed to picked up the external IP address with port 80 mapped to 31375 and port 443 mapped to 31208Let’s try accessing from the browser againOpps looks like we still can’t!We can tell that the proxy-public has been expose to the world, just not on port 80.

In this case it is port 31375.

In Kubernetes this is called a node port.

Metal Load Balancer will randomly use any ports from the node port range of 30000–32767To test this theory, you can open up the node port from the security group and access the ip address with the node port.

This will work.

But let’s get it working on port 80Install NGINX reverse proxyWe will now use NGINX as a reverse proxy to redirect request for port 80 into its internal proxy-public endpointCreate an NGINX filevi defaultCopy and paste the values from belowModify the IP_ADDRESS_HERE to the actual public IP addressInstall and configure NGINXsudo apt-get updatesudo apt-get -y install nginxsudo systemctl restart nginxmkdir /root/logscp default /etc/nginx/sites-available/defaultsudo nginx -tsudo systemctl reload nginxNow you may visit the ip address on the browser using port 80You have now successfully configured Jupyterhub with Kubernetes on Single Bare Metal InstanceTearing It All Downhelm delete jhub –purgekubectl delete namespace jhubhelm delete pgdatabase –purgekubectl delete namespace pgdatabasekubectl drain $(hostname) –delete-local-data –force –ignore-daemonsetskubectl delete node $(hostname)kubeadm reset -fiptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -XYou can also find some of the template files in this repository: https://github.

com/gpaw/jupyterhub_with_kubernetes_on_single_bare_metal_instance_tutorial.. More details

Leave a Reply