Where are you using WebAssembly?
Wasm promises to let developers build once and run anywhere. Are you using it yet?
At work, for production apps
At work, but not for production apps
I don’t use WebAssembly but expect to when the technology matures
I have no plans to use WebAssembly
No plans and I get mad whenever I see the buzzword
Kubernetes / Linux

Kubernetes 101: Install Kubernetes on Rocky Linux

Kubernetes on Linux: This tutorial will walk you through the process of installing MicroK8s on Rocky Linux 9.
Dec 4th, 2022 3:00am by
Featued image for: Kubernetes 101: Install Kubernetes on Rocky Linux

Kubernetes is an incredibly powerful container orchestrator that can deploy and manage containerized applications at scale with more power and flexibility than any other tool on the market.

Thing is, Kubernetes is hard. Really hard. With so many moving pieces, developing an application or service to be deployed to a Kubernetes cluster can be an overwhelming challenge. It takes a lot of skill and patience to get this right.

Given that Kubernetes container development itself is such a challenge, you probably don’t want to have to deal with yet more obstacles to get things up and running. Guess what, installing Kubernetes on a Linux server isn’t exactly the easiest thing either.

Once upon a time, it was much simpler, thanks to distributions like Ubuntu and the Docker container runtime. However, the Kubernetes team decided to strip Docker support from Kubernetes, which makes using it on some operating systems a bit more challenging. Kubernetes is an open source project of the Cloud Native Computing Foundation.

Of course, given this is all open source, other companies stepped up to the plate, creating applications that make getting a Kubernetes deployment up and running less challenging than it could be.

One such tool is called MicroK8s, which is just as powerful and flexible as other takes on Kubernetes (such as OpenShift, Azure Kubernetes Service, Rancher, and the official Google Kubernetes Engine).

Microk8s is easier to deploy, secure, has a small footprint, and offers a comprehensive collection of manifests for things like Ingress, DNS, Dashboard, and more. And finally, Microk8s is a solid replacement for upstream Kubernetes, so it will work seamlessly for your container orchestration.

I want to walk you through the process of installing MicroK8s on Rocky Linux 9. Why Rocky Linux 9? Simply put, it’s a high-performing server-centric Linux distribution that’s up to the task. Yes, you can install Microk8s on an OS like Ubuntu (and the process is very similar), but I wanted to show you how it’s done on a distribution that doesn’t include Snap out of the box. Because … fun!

Let’s get to work.

What You’ll Need

In order to make this work, you’ll need at least three instances of Rocky Linux 9. These can be installed on bare metal, as virtual machines, or on a cloud host (such as Amazon Web Services, Google Cloud, or Azure). You’ll also need each server to have assigned a static IP address and have a user with sudo privileges.

Time to make this happen.

Install Snap on Rocky Linux

The first thing we must do is install Snap on Rocky Linux. To do that, you must first add the EPEL repository with the command:

When that finishes, install Snap with:

That should be all you need to have Snap up and running. However, if you find you cannot successfully install Microk8s with Snap, you might have to take care of the following issues.

Create a symbolic link that will enable Snap classic support. This is done with the command:

Export the Snap $PATH with the command:

Make sure the system is aware of the change with:

Enable the Snap service with the command:

Change the SELinux Mode

For Microk8s to work properly, we need to switch SELinux to permissive mode, which can be accomplished with the following two commands:

The first command sets SELinux to permissive mode temporarily and the second command sets it such that it will remain even after a reboot of the system.

Install Microk8s

We can now install Micrk8s with the command:

We then have to add our user to the microk8s group with the command;

Create a new directory with mkdir ~/.kube. Change the ownership of the ~/.kube directory with the command:

Log out and log back in so the changes apply. Once you’ve logged in, verify the installation with the command:

The only line in the output that matters will be:

With MicroK8s installed, you also have access to the kubectl command. For example, you can check the status of your nodes with:

Change the Hostname and Edit the Hosts File

We now need to change the hostname of the controller and edit the hosts file so we can map the IP addresses to host names for all nodes on the cluster. First, we’re going to change the hostname of the controller with the command:

Next, map the hostname to the controller’s IP address in the /etc/hosts file. Open that file for editing with the command:

At the bottom of the file, you’ll add a line like this:

Save and close the file.

At this point, you now have a Microk8s controller ready to start working with nodes. Next week we’ll learn how to create and add our nodes to the controller for better performance and high availability. Yes, you could use a single-node Microk8s deployment but it wouldn’t scale very well.

Enjoy that single-node Kubernetes cluster until then.

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