TNS
VOXPOP
Will JavaScript type annotations kill TypeScript?
The creators of Svelte and Turbo 8 both dropped TS recently saying that "it's not worth it".
Yes: If JavaScript gets type annotations then there's no reason for TypeScript to exist.
0%
No: TypeScript remains the best language for structuring large enterprise applications.
0%
TBD: The existing user base and its corpensource owner means that TypeScript isn’t likely to reach EOL without a putting up a fight.
0%
I hope they both die. I mean, if you really need strong types in the browser then you could leverage WASM and use a real programming language.
0%
I don’t know and I don’t care.
0%
Containers / Kubernetes / Software Development

Deploy Microk8s and the Kubernetes Dashboard for K8s Development

Microk8s is easy to get up and running, so you won't have to waste precious time deploying multiple servers.
Feb 12th, 2022 9:00am by
Featued image for: Deploy Microk8s and the Kubernetes Dashboard for K8s Development
Image by skylarvision from Pixabay. 

So you want to start developing for Kubernetes, but you don’t want to have to exert the effort to deploy a full-blown Kubernetes cluster to do so. That’s a pretty common problem. And with Kubernetes retiring the support for Docker, you might find a lot of documentation on deploying a Kubernetes cluster to no longer function. On top of that, you might only have a single machine to work with (so deploying an entire cluster can be a challenge).

What do you do? When you only have a single desktop machine, and you need to get this up fast, you can always turn to Microk8s, which is a Cloud Native Computing Foundation-certified upstream Kubernetes platform that you can run from a workstation. Microk8s is easy to get up and running, so you won’t have to waste precious time deploying multiple servers.

Understand, however, Microk8s isn’t what you’d run your apps and services on for public consumption. This should be considered a development environment first and foremost.

With that said, what we’re going to do is deploy both Microk8s and the Kubernetes Dashboard, so you can enjoy a GUI tool to help you work more efficiently.

I’ll be demonstrating on Ubuntu Desktop 20.04, so you’ll want to have at least that version of Ubuntu Desktop up and running. And because the Kubernetes Dashboard is only accessible from within the cluster (at least not without some serious tweaking), your instance of Ubuntu must have a desktop GUI (so don’t try this on a headless server).

Outstanding. Let’s get to work.

Installing Microk8s

The first thing we’re going to do is install Microk8s. Log into your desktop, open a terminal window, and issue the command:

sudo snap install micro8ks --classic

After the installation completes, you must then add your user to the Microk8s group and change the ownership of a newly-created directory. First, add yourself to the group with the command:

sudo usermod -a -G microk8s $USER

Next, you need to make the system aware that you’ve been added to the new group with the command (to avoid having to reboot your machine):

newgrp microk8s

Finally, change the ownership of the .kube folder with:

sudo chown -f -R $USER ~/.kube

Deploying the Kubernetes Dashboard

We can now install the Kubernetes Dashboard (along with a few other addons) with the command:

microk8s enable dns dashboard storage

After this command runs, you need to discover the IP address assigned to the Dashboard. This is done with the command:

microk8s kubectl get all --all-namespaces

You should see quite a bit of output, which will include a listing for the Dashboard that looks like:


This tells us the IP address of the Dashboard and the port. The values assigned to your Dashboard will differ.

You’ll need to wait a few minutes before the dashboard becomes available. If you open a web browser on the same desktop you deployed Microk8s and point it to https://IP:443 (where IP is the IP address assigned to the Dashboard), you’ll need to accept the risk (because the Dashboard uses a self-signed certificate). If the connection times out, wait a few more minutes for the service to become available.

Eventually, you’ll be greeted with the Dashboard login window (Figure 1).

The dashboard log-in window

Figure 1: The Dashboard service is ready to be logged into.

Before you can log into the Dashboard, you must first generate an authentication token. Go back to the terminal window and issue the command:

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) microk8s kubectl -n kube-system describe secret $token

You will be presented with a long string of characters. Copy that string and then paste it into the text area of the Dashboard log in the window (making sure to select Token). Click Sign in and, upon successful authentication, you’ll find yourself on the main Kubernetes Dashboard window (Figure 2).

GUI: The Kubernetes dashboard.

Figure 2: The Kubernetes Dashboard is ready for use.

Deploy a Container

Click on the + button in the top left corner of the main window. On the resulting page, click Create from form and then fill out the necessary information as shown in Figure 3).

GUI: Deploy a test container

Figure 3: Deploying a test NGINX container named test.

You should immediately be directed to a page that lists your new deployment (Figure 4).

GUI: Deployment running.

Figure 4: Our newly created deployment is up and running.

Click the name of the entry (in this case, tns) to view the details of the deployment (Figure 5).

GUI: Container info

Figure 5: Here you’ll find plenty of information about the running NGINX container.

Go back to the terminal window and issue the command:

microk8s kubectl get all --all-namespaces

You should see an IP address associated with the tns container. Copy and paste that IP address (along with port 8080) into your browser and the NGINX welcome page should appear.

Congratulations, you’ve just deployed Microk8s and the Kubernetes Dashboard to serve as an efficient and simple Kubernetes development platform.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Docker.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.