Install Kubernetes on X96 Max+

Muhammad Yunus
5 min readMar 20, 2022

Kubernetes (sometimes shortened to K8s with the 8 standing for the number of letters between the “K” and the “s”) is an open source system to deploy, scale, and manage containerized applications anywhere [google].

In this story we will try to install Kubernetes on X96 Max+with Diet-Pi OS installed on it. To do this, we need to flash X96 Max+ with the latest Diet-Pi OS version. Please check this link to follow.

To make everything easy to learn the Kubernetes, we will use minikube for this case.

minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes. [minikube]

What will you need,

  • 2 CPUs or more
  • 2GB of free memory
  • 20GB of free disk space
  • Internet connection
  • Docker

Hardware Setup

X96 Max+ (Remote Machine)  <--------->  Our Laptop (Local Machine)

Docker Installation

Since minikube need a Docker Container to run, we need to install it first,

curl -fsSL https://get.docker.com -o get-docker.sh
sh ./get-docker.sh

Create the docker group and add your user to the docker group.

sudo groupadd docker
sudo usermod -aG docker $USER

Minikube Installation

To install the latest minikube stable release on ARM64 Linux using Debian package

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_arm64.deb
sudo dpkg -i minikube_latest_arm64.deb

Start your cluster,

minikube start

Setup kubectl alias,

echo 'alias kubectl="minikube kubectl --' >> ~/.bashrc

Reload setup,

source ~/.bashrc 

Then run command below to see all service running in our minikube cluster,

kubectl get po -A 

The result should look like this,

Then we can run Kubernetes Dashboard to help us managing and monitoring our cluster from the web UI.

minikube dashboard 

The result should look like this,

Since we are running the Kubernetes Dashboard in X96 Max+ as remote machine. Wee need to expose the dashboard through the kubectl proxy in port 8001, so later we will be able to access it through the local machine (our laptop),

kubectl proxy --address='0.0.0.0' --disable-filter=true

Then open the browser from our local machine and open this URL,

http://<_YOUR_SERVER_IP_ADDR_>:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

Change <_YOUR_SERVER_IP_ADDR_> to your X96 Max+ IP Address in your local network. Then you should see the web UI that look like this,

Deploy Sample Applications

Since the echoserver hello-minikube is only for amd64 architecture, so we can’t using that image sample. But there is echoserver created by community to be able to run in arm64 architecture. The image is preslavmihaylov/ kubehelloworld:latest.

Create a sample deployment and expose it on port 3000:

kubectl create deployment hello-minikube --image=preslavmihaylov/kubehelloworld:latest
kubectl expose deployment hello-minikube --type=NodePort --port=3000

Check status by running,

kubectl get services hello-minikube

The result should look like this,

We also able to see the status via Kubernetes Dashboard,

Since the application is run using IP and Port inside Docker that run on X96 Max+ machine, to be able to access that service from our local machine we need to use kubectl to forward the port to 3030,

kubectl port-forward service/hello-minikube 3030:3000 --address=0.0.0.0

Then open the browser in our local machine and open this URL,

http://192.168.0.105:3030/

The result should look like this,

The result indicate that we able to run the sample application inside minikube cluster on X96 Max+ machine running Diet-Pi OS.

Kubernetes VS Code Extension

If you are using Visual Studio Code to develop application, it’s recommended to install Kubernetes Extension which help us to build applications easily.

If extension installed successfully, then you should see Kubernetes Icon in the left panel,

Autostart Minikube Cluster

We can make minikube run automatically after the X96 Max+ boot by starting it using systemd.

Create systemd service file called minikube.service,

sudo nano /usr/lib/systemd/system/minikube.service

Then paste this script inside that,

[Unit]
Description=Runs minikube on startup
After=network-online.target firewalld.service containerd.service docker.service
Wants=network-online.target docker.service
Requires=docker.socket containerd.service docker.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/minikube start
ExecStop=/usr/bin/minikube stop
User=dietpi
Group=dietpi

[Install]
WantedBy=multi-user.target

Save and exit above script,

Reload the service,

sudo systemctl daemon-reload

To enable your service start on boot,

sudo systemctl enable minikube.service

Reboot X96 Max+ machine, after machine up and running, execute this command,

sudo systemctl status minikube.service

Then we can see that minikube running automatically,

To start and stop the service manually, we can use this command,

Start Service,

sudo systemctl start minikube.service

Stop Service

sudo systemctl stop minikube.service

--

--

Muhammad Yunus

IoT Engineer, Software Developer & Machine Learning Enthusiast