Setting up a Kubernetes Cluster on Jetson Nano (with k3s)
The Jetson Nano is an easily accessible, yet powerful single board computer built to deploy machine learning applications and more. Kubernetes is the most popular orchestration system used to manage and automate your application deployment, through a Kubernetes Cluster. K3s is the more lightweight version of Kubernetes.
This week we look at setting up a Kubernetes cluster on two Jetson Nanos, although you can do it with as many worker nanos as you’d like. It can be tricky to do, especially with no guide that outlines how to do it specifically for the Jetson Nano’s unique architecture. Although there are many other guides out there, this one is specifically for the Nano and will address any specific issues that come with that.
What We Will Use:
- 2 fresh Jetson Nanos running Ubuntu 18.04, with Jetpack SDK 4.5 installed.
The first thing we need to decide is which jetson will be our master node, and which one(s) will be our worker nodes. The master node is the nano that you will deploy the cluster from, and the worker node(s) will join the cluster. Name them accordingly. I have named mine master and node1.
Then, use SSH to work on all the Nanos easily. Use this:
And then login as you normally would on the nano you are SSHing into.
We will need curl for this, so Use this to install curl on all nanos.
To make things easier, I recommend running “sudo su” to avoid having to type sudo before everything.
1. Installing Master Node:
We will now configure the Master Node. On your master nano only, run:
This installs k3s and starts it, deploys a cluster, and sets this node as the master.
You can view that your master node is online by running:
You should see your “k3s-master-01” node is the only one in the cluster.
For the next step, which is installing the worker nodes, we will need the master node’s token. To get it, run this:
And copy the token for the next step.
2. Installing Worker Node(s):
We will now configure the Worker Nodes. Do this on all the worker nodes you have.
Replace <IP> and <TOKEN> with the master node’s ip address (you can get this by running ifconfig) and the token you previously saved.
Now, when you run “kubectl get nodes” on the master node, you can see that the worker has joined.
3. Bringing up the dashboard
At this step, you’re pretty much done, your cluster is up, and you can begin deploying containers. I will show you now how to bring up the dashboard to view all your containers once they are deployed.
First, run this on the master node. This will deploy the kubernetes dashboard.
Now we have to create a few files:
- Dashboard.admin-user.yml (do
vim dashboard.admin-user.yml), press i to enter insert mode, and paste the following.
Press esc then
:x to exit the vim editor and save.
- Dashboard.admin-user-role.yml (do
vim dashboard.admin-user-role.yml), press i to enter insert mode, and paste the following.
Save the file the same way as the previous one.
Now we will deploy the admin-user configuration. Run:
Now we will access the token needed to access the dashboard locally in a web browser. Run:
And keep note of the very long token.
Now we will create a secure channel to the cluster. To do this, run:
You should see:
This means that the dashboard is being served at 127.0.0.1, on port 8001. At this link you will find your dashboard:
It will prompt you for the token we copied in the previous step. Paste it here, and you will have access to the kubernetes dashboard.
And you’re done! Once you deploy containerized apps, you will be able to see and manage them in the dashboard.
Other useful commands
To shut off your cluster, run:
To delete your dashboard, run:
To restart the cluster later, run:
In next week’s blog post, we will look at containerizing apps and deploying them. We will also look at managing them between nodes, and using the dashboard more.