Thursday, September 19, 2024

Minikube vs k3s: Pros and Cons for Developers and DevOps

Kubernetes is one of the skills that developers and DevOps need to have experience within 2024 and beyond. Kubernetes has established itself as the de facto standard for running containers with high-availability. One of the places that most developers and DevOps start with is a local Kubernetes cluster for local development. There are a couple of Kubernetes distributions that many begin with for their local development environments. Those are minikube and k3s. Let’s take a look at minikube vs k3s and see the pros and cons of each.

Local Kubernetes cluster development environments

Many use local Kubernetes cluster environments to develop and test their code before committing changes to staging or production infrastructure. Local Kubernetes development is a great way to test out code before going any further into production or production-test environments. It allows developers and DevOps to run containerized applications in the same infrastructure used for production and not just in a single docker container on their host system.

kubernetes

Developers can also test and verify their containerized apps in a local environment before these are deployed in production. These provide a good way to manage Kubernetes clusters.

What exactly is a local Kubernetes development environment?

Local environments mean the Kubernetes cluster is self-contained and runs on a single machine, usually the developer’s or DevOps engineer’s workstation or virtual machines they may run locally in something like a VM based Kubernetes environment running on something like Hyper-V, VirtualBox, or VMware Workstation. Those with Windows workstations may even use Windows Subsystem for Linux (WSL) for installing local Kubernetes clusters.

With the local test Kubernetes environment, you have full control over the Kubernetes nodes and can do things without fear of breaking production environments. These allow development, testing, and CI/CD pipeline configuration.

What is minikube?

Minikube is a very popular local Kubernetes single-node cluster environment. It provides a great way to get your hands on Kubernetes. It is lightweight and provides everything you need to run a single-node K8s cluster.

minikube
minikube

Developers usually don’t need a full-scale Kubernetes cluster with multiple nodes for development. They just need a single node. Minikube simplifies getting up and running with a Kubernetes cluster running inside a virtual machine, container, or even a bare-metal install.

Minikube supports multiple operating systems. These include Windows, macOS, and Linux. It also works with different container runtimes like Docker and CRI-O. Minikube allows you to experiment with Kubernetes without the complexity involved with a “from scratch” setup. you can easily learn K8s components and start developing applications in a local environment.

What is k3s?

Now, what about k3s? It is a lightweight Kubernetes distribution that is a great distribution for minimal resource hosts. These are typically the kinds of hosts you would find in edge compute environments, IoT devices, or even in the home lab.

K3s is developed and produced by Rancher Labs and is the underpinning Kubernetes distro that runs underneath the hood of Rancher Desktop when you enable Kubernetes. One of the interesting things about k3s is that it is a single binary weighing in at less than 100MB that helps in resource constrained environments.

k3s kubernetes
k3s kubernetes

However, don’t let the size of the distro fool you for running Kubernetes locally. K3s has all the core functionalities of full-blown Kubernetes. These features include networking, storage, and security. It makes building a Kubernetes cluster easier as well and works great with projects like K3sup and KubeVIP.

Also, keep in mind that k3s is a distribution that you can use to run a production cluster or multi-node clusters on edge devices or other nodes, not just a local Kubernetes development environment.

Installing Minikube

Let’s look and see how simple it is to install minikube on a development workstation. Below, I am installing minikube in Windows Subsystem for Linux (WSL) with the following commands:

sudo apt install -y curl wget apt-transport-https && \
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \
sudo install minikube-linux-amd64 /usr/local/bin/minikube
installing minikube in windows subsystem for linux
installing minikube in windows subsystem for linux

Once you have minikube installed, you can then start the minikube cluster. It requires that you have some type of virtualization engine available to run your Kubernetes node. Below, we are using the Docker driver with the command:

minikube start --driver=docker
using the docker driver for a new minikube cluster
using the docker driver for a new minikube cluster

Installing k3s

Let’s now look at the process to install k3s. The installation of k3s can be carried out with a single command:

curl -sfL https://get.k3s.io | sh -

Next, you will copy the kubeconfig file for k3s to your home directory:

sudo cp /etc/rancher/k3s/k3s.yaml ~

Then change ownership on the k3s.yaml file:

sudo chown -R linuxadmin k3s.yaml

Then you can now set your KUBECONFIG environment variable to point to this file:

 export KUBECONFIG=~/k3s.yaml

Now, you can view your kubectl config:

kubectl config view
getting the kubernetes config view for k3s
getting the kubernetes config view for k3s

Below, after setting up the kubeconfig file, we are getting our nodes where we can see the Kubernetes version.

getting the k3s nodes using kubectl
getting the k3s nodes using kubectl

Minikube vs k3s: Pros and Cons

Now, let’s look at a few areas of comparison between k3s vs minikube.

1. Kubernetes Features and Support

Let’s first look at the kubernetes features and support that most would want for development and DevOps. Minikube is a distribution that supports just about all Kubernetes features. These capabilities include rolling updates and self-healing. It also makes things like spinning up a Kubernetes dashboard easy. You can use the simple command:

minikube dashboard

You can also add an ingress controller very easily to minikube with the command:

minikube addons enable ingress

Minikube is not intended for production but rather for single node kubernetes development environments. Also, it doesn’t support multiple kubernetes nodes.

K3s also supports a full Kubernetes cluster experience with support for the majority of features across networking, storage, and other areas. It is meant for both development and production. It can run in a multi node clusters configuration and in edge clusters with resource constraints.

With projects like KubeVIP you can have load balancing (service load balancer) and other features to your K3s clusters. As you would expect as well, you can have enterprise support with K3s. For storage, you can use local storage or HCI storage such as Longhorn.

2. Performance

Minikube is arguably more resource intensive than k3s and is a larger footprint. K3s is a single sub-100 MB binary that you can easily download and install. It can run on limited resource-constrained hardware, such as IoT devices in edge clusters.

3 Developer Experience

Minikube is a very good Kubernetes distribution for development and provides various tools and plugins for developers and DevOps engineers to use. K3s is also very simple and intuitive to use, although it may not be as straightforward as minikube.

4 Security & Networking

What about security and networking features? K3s being a production-grade Kubernetes distribution, provides more security features that include things like network policies and secrets management. Both solutions provide several different networking options, including CNI and Calico.

5 Community Support

Both minikube and k3s have large communities of users and support resources. Both are equally well-supported by the community and have good documentation.

Choosing the Right Kubernetes with Minikube vs K3s

For the most part if you need to run Kubernetes locally and you need a testing Kubernetes environment, you are not going to go wrong with either Minikube or K3s. Both are very good Kubernetes distros that can do just about anything you need to do for learning, development, testing, and other use cases on your local cluster housed on a local machine.

If you need to develop on the same Kubernetes that can also be used in a production environment, k3s is definitely the choice between the two as it is a lightweight Kubernetes that can be used for production environments, edge and IoT devices, and other use cases.

Wrapping up the comparison between minikube vs k3s

Building a local Kubernetes development cluster is a great way for developers and DevOps engineers to have a Kubernetes environment to test changes and configurations locally without affecting production.

There are many different pros and cons when comparing minikube vs k3s and looking at the options you have between them. To make a decision on which is best for your use, think about factors like resource requirements, feature support, and community support.

Brandon Lee
Brandon Leehttps://tek2cloud.com
Brandon Lee is the Senior Writer, Engineer and owner at tek2Cloud.com and has over two decades of experience in Information Technology. Brandon holds multiple industry certifications and loves IT automation, modern applications, and cloud technologies along with traditional servers and infrastructure.

2 COMMENTS

Leave a Reply

Read more

Other Posts