Advanced use of Kubernetes
Deploying your own Kubernetes clusters¶
We are going to be using Jetstream-2 for this section and will rely on their documentation for Kubernetes deployment
Helm¶
Helm is the package manager that allows users to define, install, and manage K8s applications using Helm Charts, which are packages of pre-configured Kubernetes resources.
Similarly to how Docker users can create their own containers and share them collaborators through DockerHub, Helm Charts are built by users and shared through repositories such as artifacthub. This allows for streamlining deployment and management for complex K8s orchestrations.
Helm example: Zero2JupyterHub¶
-
Install Helm
- Users can install Helm on their own machines by following the official documentation. For this example, we are going to assume that students are using a Unix OS. In that case, the following commands should work:
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null sudo apt-get install apt-transport-https --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list sudo apt-get update sudo apt-get install helm
Info
If you are using the Virtual Machines provided by the CyVerse team, Helm is already installed.
- Users can install Helm on their own machines by following the official documentation. For this example, we are going to assume that students are using a Unix OS. In that case, the following commands should work:
-
Add the JupyterHub Helm repository, which contains the charts needed to deploy JupyterLab.
You can check if the help repository list by doinghelp repo list
. You should see something like - Obtain the
config.yaml
- One can write their own config file, but these take extensive work and deep understanding of charts. What we can do instead, is to pull the values that we need from Jupyterhub and save its output to a file. We can do that with the following command:
- If you were to look inside this yaml file, you will see a long list of configurable lines. These values need not to be changed to execute the jupyterhub, apart from
secretToken
. - Generate the secret token with
openssl rand -hex 32
, copy the hex string and replace thesecretToken
line from thejupyter.yml
file using a text editor (e.g., nano or vim).
- From within the folder, deploy the jupyterhub using the following command (installation should only take a minute):
- Access the JupyterHub through your VM IP address!
Uninstalling the chart
To uninstall the chart simply do
If you also want to remove the repository do The names can get pretty confusing, please understand that the first is uninstalling the chart namedjupyterhub
and the second the repository named jupyterhub
(and this is why you want to keep names unique :) ).
Miniaturized versions of Kubernetes¶
Why use mini versions of Kubernetes?
There are multiple projects developing "light-weight" Kubernetes.
The justification for these projects being that full Kubernetes deployments with all of its functionality increases the cognitive load and the number of configurations and parameters that you must work with when running containers and clusters, particularly at the edge.
Projects that are working on miniaturized versions of K8s:
name | functionality | use cases |
---|---|---|
minikube | ||
microK8s | runs fast, self-healing, and highly available Kubernetes clusters | |
K3s | runs production-level Kubernetes workloads on low resourced and remotely located IoT and Edge devices | |
K3d | lightweight wrapper that runs K3s in a docker container |
Install K3s
¶
Install minikube
¶
Minikube is useful for running K8s on a single node or locally -- its primary use is to teach you how to use K8s.
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
sudo minikube config set vm-driver none