avatarsaurs saurav

Summary

The web content provides a comprehensive guide on setting up JupyterHub with Nginx Ingress on Google Kubernetes Engine (GKE) using Helm for deploying the Nginx controller.

Abstract

The article outlines a step-by-step process for deploying JupyterHub on Google Kubernetes Engine with Nginx Ingress. It begins by detailing the prerequisites, including a GCP project with Kubernetes Engine API enabled, Helm for deploying the Nginx controller, and basic knowledge of Ingress, Kubernetes, and JupyterHub. The guide is structured into four parts: installing Helm and Tiller with RBAC, deploying the JupyterHub application, setting up the NGINX Ingress controller using Helm, and configuring the Ingress Resource to route traffic to JupyterHub. The author emphasizes the challenges faced due to outdated or error-prone resources available online and presents this guide as a solution to successfully run a JupyterHub application with Nginx Ingress on GKE. The article concludes with the author acknowledging their newbie status in Kubernetes and hinting at future content covering HTTP and HTTPS configurations on Ingress.

Opinions

  • The author found existing online resources for setting up Nginx Ingress on Google Kubernetes Engine to be outdated or error-prone.
  • The guide is presented as a reliable solution after numerous attempts and research by the author.
  • The author identifies as a newbie to Kubernetes, suggesting that the guide is tailored for those with basic knowledge and is meant to be clear and accessible to learners.
  • There is an implication that the author plans to expand their expertise and share further insights, particularly on handling HTTP and HTTPS on Ingress in future blog posts.
  • The author endorses an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4), indicating a preference or positive experience with this service.

JupyterHub with Nginx Ingress on Google Kubernetes Engine.

After going through many blogs, documents and videos, I still had a hard time for setting up Nginx Ingress on Google Kubernetes and run a simple Hello-world app on it. Some were outdated, others were error prone. But After many attempts i finally managed to not only run a simple app but a jupyterhub with nginx-ingress-controller forwarding outside traffic to jupyterhub’s service.

This guide will help to run jupyterhub with nginx ingress on Google kubernetes Engine. As usual before starting, you guys need the following things.

  1. GCP project with Kubernetes Engine API enabled.
  2. Helm (only use for deploying nginx-controller)
  3. Basic Knowledge in Ingress, Kubernetes, Jupyterhub.

This guide is divided into four parts. If you go through all parts and its steps, you will be up and running jupyterhub app on kubernetes.

Part One : Install a Helm And Tiller with RBAC

Long story short, Helm is like apt/yum/homebrew for Kubernetes. We will only use helm for deploying nginx-controller.

  1. You can install the helm client in Cloud Shell using the following commands:
curl -o get_helm.sh https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get
chmod +x get_helm.sh
./get_helm.sh

The script above fetches the latest version of helm client and installs it locally in Cloud Shell.

-------------------------------OUTPUT-------------------------------Downloading https://kubernetes-helm.storage.googleapis.com/helm-v2.8.1-linux-amd64.tar.gzPreparing to install into /usr/local/bin
helm installed into /usr/local/bin/helm
Run 'helm init' to configure helm.

2. Run the following command to install the server side tiller to the Kubernetes cluster with RBAC enabled.

kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
      
helm init --service-account tiller --upgrade
helm init

3. You can also confirm that tiller is running by checking for the tiller_deploy Deployment in the kube-systemnamespace. Run the following command:

kubectl get deployments -n kube-system

Part Two : Deploy JupyterHub App

  1. Create a jupyterhub-app.yaml

2. Deploy the jupyterhub app

Kubectl create -f jupyterhub-app.yaml

3. Expose the jupyterhub Deployment as a Service by running the following command:

kubectl expose deployment jupyterhub

Part Three : Deploying the NGINX Ingress Controller via Helm

  1. Deploy an NGINX controller Deployment and Service by running the following command:
helm install --name nginx-ingress stable/nginx-ingress

In the output you should see,

==> v1/Service
NAME                           TYPE          CLUSTER-IP    EXTERNAL-IP  PORT(S)                     AGE
nginx-ingress-controller       LoadBalancer  10.7.248.226  pending      80:30890/TCP,443:30258/TCP  1s
nginx-ingress-default-backend  ClusterIP     10.7.245.75   none         80/TCP                      1s

2. Confirm that the nginx-ingress-controllerService has been deployed and that you have an external IP address associated with the service. Run the following command:

kubectl get service nginx-ingress-controller

Notice the second service, nginx-ingress-default-backend. The default backend is a Service which handles all URL paths and hosts the NGINX controller doesn’t understand (i.e., all the requests that are not mapped with an Ingress Resource). The default backend exposes two URLs:

  • /healthz that returns 200
  • / that returns 404

Part Four : Configure Ingress Resource to use NGINX Ingress Controller

  1. Create ingress-resource.yaml

The kind: Ingress dictates it is an Ingress Resource object. This Ingress Resource defines an inbound L7 rule for path / to service jupyterhub on port 8000.

2. Deploy Ingress Resource.

kubectl apply -f ingress-resource.yaml
=== output ===
NAME               HOSTS     ADDRESS   PORTS     AGE
ingress-resource   *                   80        `

3. Get a External IP nginx-ingress-controller

kubectl get service nginx-ingress-controller

You should now be able to access the jupyterhub application by going to the EXTERNAL-IP address of the NGINX ingress controller.

Of course, this app will not spawn any jupyter-notebook as no config is been attached. For that others guides can help.

Conclusion

I am newbie to Kubernetes

Maybe In next blog i will be handling HTTP and HTTPS on Ingress.

Kubernetes
Google Cloud Platform
Nginx
Ingress
Jupyter
Recommended from ReadMedium