Setting up Minikube and Accessing Minikube Dashboard Remotely

Aris Munawar, S. T., M. Sc.
5 min readDec 2, 2023

--

In the previous article (Installing Minikube on Ubuntu 20.04 LTS Focal Fossa), we have successfully installed Minikube on Ubuntu server. Before being able to use it, we have to set up several things. This article focuses on setting up Minikube for first use and then activating and accessing the Minikube dashboard.

  • Step 1. Managing Addons on Minikube

By default, several addons have been enable during the Minikube instalallation. To see the addons of Minikube, run the following command:

$ minikube addons list

To enable an addon, use the following command:

minikube addons enable <addon-name>

For example we want to enable ingress addon:

$ minikube addons enable ingress

To disable addons, simply use the negation of enable command “disable”

$ minikube addons disable <addon-name>
  • Step 2. Enabling and Accessing Minikube Dashboard

Minikube dashboard is the Kubernetes dashboard. Using Kubernetes dashboard we can manage all resources within Kubernetes using web-based GUI instead of CLI. To enable Minikube dashboard, execute the following command:

$ minikube dashboard
🔌 Enabling dashboard ...
▪ Using image docker.io/kubernetesui/dashboard:v2.7.0
▪ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
💡 Some dashboard features require the metrics-server addon. To enable all features please run:

minikube addons enable metrics-server


🤔 Verifying dashboard health ...
🚀 Launching proxy ...
🤔 Verifying proxy health ...
http://127.0.0.1:46873/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

The above command is enabling dashboard addon and directly set access to it. We can see from the command response, the dashboard is accessible through URL http://127.0.0.1:46873/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/, but to access this link you have to remote your server desktop and open the link using web browser. But it is going to be a problem if your server is only installed with the command line interface (without desktop). By the way, to confirm that the dashboard is really running, you can use curl <link> from terminal.

curl http://127.0.0.1:46873/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
  • Step 3. Accessing Dashboard remotely

Note that running command minikube dashboard will automatically run proxy to access the dashboard but with random port at the localhost (in the above example we get port number 46873). We know that the dashboard addon has been enabled and we just need a proxy to access it from a static port. Stop the dashboard proxy by pressing button CTRL + C / Command + C for Mac, after that type command kubectl proxy and press enter

$ kubectl proxy
Starting to serve on 127.0.0.1:8001

The Kubernetes APIs are now served through port 8001 (default port for Kubernetes API). Now your dashboard is accessible through port 8001 together with all Kubernetes APIs. The URL for the dashboard is now http://127.0.0.1:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/, but again this URL is only accessible by local access.

To access it remotely, you can utilize the SSH to your server, using -L option. Open terminal/command prompt on your local PC/laptop and type the following command:

ssh -L 12345:localhost:8001 root@<ip-of-your-server>

Replace <ip-of-your-server> with your server IP, now you can access the dashboard remotely from your local browser using localhost / 127.0.0.1 at port 12345. The link for the dashboard is now http://localhost:12345/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/. Your local port 12345 will be tied up with the server at port 8001 as long as the SSH connection is connected. Following is the Kubernetes dashboard, accessed remotely from local machine.

  • Step 4. Installing Minikube as service

Last but not least, yet it is very important. In the previous article, Installing Minikube on Ubuntu 20.04 LTS Focal Fossa we have learnt how to install Minikube and start it so that we can access the dashboard and Kubernetes service. But keep in mind that the Minikube is not started as service yet. It means that every time we reboot our machine, the Minikube is not started and we have to start it all over again. To start it as service we will write two .service files, minikube.service and minitunnel.service to start minikube and minikube tunnel respectively.

Create the minikube.service

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

Then paste the following script:

[Unit]
Description=minikube
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
WorkingDirectory=/root
ExecStart=/usr/local/bin/minikube start --driver=docker --force
ExecStop=/usr/local/bin/minikube stop
User=root
Group=root

[Install]
WantedBy=multi-user.target

Save the script using CTRL + O, ENTER and CTRL + X, then run the following command to enable and start minikube service respectively.

$ systemctl enable minikube
$ systemctl start minikube

Once finished, check the service status using systemctl status minikube, now you can confirm your Minikube status using command minikube status.

The second service is minitunnel.service which will start the minikube tunnel process. This process is required by the Kubernetes service objects to create external IP address (we will learn about this later in the next article).

$ nano /usr/lib/systemd/system/minitunnel.service

Then paste the following script:

[Unit]
Description=minitunnel
After=network-online.target minikube.service
Wants=network-online.target minikube.service
Requires=minikube.service

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/root
ExecStart=/usr/local/bin/minikube tunnel
ExecStop=/usr/local/bin/minikube stop
User=root
Group=root

[Install]
WantedBy=multi-user.target

Save the script by pressing CTRL + O, ENTER and CTRL + X, then run the following command to enable and start minitunnel service respectively.

$ systemctl enable minitunnel
$ systemctl start minitunnel

The status of this “minikube tunnel” cannot be checked, but we will learn the effect in the next article.

Now, you can try to reboot your machine and run command minikube status to check that Minikube is running. If the service is successfully run, you will see the following response:

$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

In the next article, we will learn about how to Writing and Deploying Your First App on Minikube.

--

--

Aris Munawar, S. T., M. Sc.

Lecturer, Fullstack Software Developer, Proficient on Desktop/Mobile Automation, Dynamic Programming & Instrument Interfacing