Exploring the Possibilities of Local Kubernetes Solutions

By Robert Boseanu

When you say container orchestration, you might immediately think of Kubernetes, which has lately become the go-to practice for managing your containerized apps. But if you’re new to Kubernetes, it can be quite daunting at first, as moving and managing your apps into clusters can raise a few challenges. Luckily, there are ways that can make your life easy – tools to help you learn the terminology, and implementations of Kubernetes that support you in learning to apply the concepts.

Context

Recently we were faced with a request to setup a lightweight local infrastructure for one of our development teams working on a micro-service payment gateway. They needed a quicker tear-down and setup time, with a reduced physical resource load, but continued compatibility with non-development environments running full-fledged Kubernetes.

If you’ve taken any interest in Kubernetes up until now, then you’ve probably found out that it is also available as a local solution.

Setting out on our research path, we took a sample .NET web application and used it to test out various local implementations of Kubernetes. Some worked, some failed, but we really liked two alternatives – Minikube and Kind. Overall, this entire research effort revealed quite a few insights, which we’re happy to share.

What is Minikube?

Minikube is a lightweight Kubernetes tool developed by the Kubernetes main project, which enables developers and DevOps engineers to run clusters on their local machine. By default, Minikube creates a single node cluster, although it can be configured for multi-node configurations as well.

Its main appeal consists in the fact that no server or cloud provider is required, all you need is a laptop and a minimum of resources. While other K8s tools deploy clusters in Docker containers, Minikube uses VMs.

What can Minikube do?

Aside from being a straightforward and easy-to-install tool, Minikube also has a considerable list of add-ons that can be enabled to provide a more granular access into your cluster. Features such as storage provisioner, ingress, helm and monitoring dashboards are provided by Minikube right off the bat. If that’s not enough, Minikube also provides a sandbox experience (since it is open source under Apache 2.0), which allows developers and architects to expand their clusters and add additional features.

Minikube provides the perfect Kubernetes learning experience, so regardless if you’re new to this or if you already have some experience with creating and managing your own clusters, you’ll find that you have more than enough options to play around with.

What is Kind?

Kind is an open-source tool primarily used to quickly create Kubernetes clusters using Docker container “nodes”. While it was initially designed with the idea of testing Kubernetes itself, it has since proven a more than capable tool for local development and CI pipelines.

To understand how Kind clusters work, think of a single Docker container that runs a control plane node and worker nodes that form the cluster. Kind creates a single image or node image that contains all the required Kubernetes components in order to create single-node or multi-node clusters.

What makes Kind special?

One of the biggest advantages that Kind has over its competitors is its simplicity. It facilitates an easy to set up Kubernetes environment without having to use virtual machines or any other additional tool – all you need is Docker. This also means that Kind can start up a Kubernetes cluster considerably faster than other tools, like Minikube for example.

Another advantage is that Kind is customizable, and clusters can be configured to run in a multi-node setup where you can also simulate high availability by adding multiple control planes. Also, aside from being extremely easy to create and delete clusters using a single command, you can load local container images into your cluster without having to setup a registry to push images.

If you need a local solution tool that is simple and flexible, then Kind is definitely a more than capable contender to consider.

Setting up Kubernetes on your computer

Just so you can get an idea of how easy it is to configure your own Kubernetes cluster, I will show you two simple setups for Minikube and Kind. With easy-to-follow steps and plenty of documentation and community support, you’ll find that these tools are worth looking into.

Minikube cluster setup

Getting things started with Minikube is very easy, after installing the Minikube CLI, you’ll need to install kubectl, a tool that enables you to interact with your clusters. After all is said and done, you need to run Minikube start, Minikube will then create your VM and start up your cluster.

As you can see, we’re running this on a Linux machine using Docker to create our cluster. Alternatively you can configure Minikube to use VirtualBox or KVM2 (on Windows you can also use Hyper-V Manager).

Now that our cluster is up and running, we will create a simple nginx deployment and expose it on port 80.

To check the port where our deployment is up, we can use minikube service <servicename> or kubectl get svc. We can also make the deployment available to localhost by using port forwarding.

When it comes to creating a cluster, it really doesn’t get any easier than with Minikube, just a few commands in your terminal and you’re good to go.

Kind cluster setup

For Kind, we’ll do something a little different. We’ll deploy a very basic .NET application which has a single controller that returns two values.

After installing Kind and all the necessary prerequisites, you’ll first need to create your cluster. Here’s an example of a quick single-node configuration and how to initialize the cluster.

Now that our cluster is up and running, we can go ahead and create our pod.

Afterwards we have to create a service to interact with our pod and an Ingress to be able to reach our application from our localhost. However, unlike Minikube, Kind doesn’t come with an out of the box Ingress service, so we’ll have to manually install it using the following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingressnginx/main/deploy/static/provider/kind/deploy.yaml

Here’s how our service and Ingress will look like.

Now if we’ll call http://localhost followed by the path of the controller (say http://localhost/api/values), we’ll get a 200 OK and the value set initially.

What should you choose?

We’re not going to tell you to use one tool or the other. At the end of the day, these solutions have a single purpose, which is making our lives easier. Whether it is getting to know the initial how-to of Kubernetes, experimenting with new features, or easing development, each tool has its own advantages and constraints. Also, don’t limit yourself to Minikube and Kind either, there are multiple solutions out there to explore like K3s, MicroK8s and Docker for Windows to name a few.

Whether you’re new to Kubernetes and you’re still learning the ropes or if you have some experience with creating and managing your own clusters and want to experiment with additional features, setting up a local solution is the quickest and most efficient way to go.

About Robert Boseanu

Robert is a software support engineer, who likes to have fun working with Agile methodologies, as well as .NET and Javascript. Robert is very keen on discovering all the new trends around DevOps, already having practical experience with CI/CD Pipelines, AWS and Azure DevOps, as well as sharing his knowledge with his colleagues and clients, in order to help the projects he works on.

 

Share this article