Over the weekend, I was curious about the options for deploying a Kubernetes cluster on my laptop, which is not exactly a powerhouse. I wanted to find something that would not hog all my resources while still letting me experiment with Kubernetes. This led me down the rabbit hole of different tools designed for local setups. In this blog post, I will share what I discovered, comparing these options and why I found them interesting.
Why You Might Need a Local Kubernetes Cluster?
Running a Kubernetes cluster locally offers several benefits:
- Learning and Experimentation: A local setup allows for hands-on learning and experimentation with Kubernetes concepts.
- Application Development: Test containerized applications in a controlled environment before deployment.
- Cost-Effective: Utilizing your own hardware eliminates the need for expensive cloud resources.
Available Options for Local Kubernetes Clusters
Here are some popular tools I came across to run Kubernetes on a laptop
Minikube
Minikube is a popular tool that creates a single-node or highly available Kubernetes cluster on your local machine. It supports various hypervisors(KVM, QEMU) and can also run using Docker or Baremetal making it flexible for different setups. While it provides a rich feature set, it can be resource-intensive, particularly when running multiple services.
KIND(Kubernetes IN Docker)
KIND allows you to run Kubernetes clusters in Docker containers, making it lightweight and suitable for testing Kubernetes itself.
MicroK8s
MicroK8s is a minimal Kubernetes distribution designed by Canonical. It can be easily installed with a single command and is optimized for low resource consumption. While itβs easy to use, setting up multi-node clusters requires additional configuration.
k3d(K3s in Docker)
k3d is a lightweight wrapper around k3s, allowing you to run Kubernetes in Docker containers seamlessly. It’s designed for resource efficiency, using SQLite for single-node clusters and supporting etcd
for high availability. k3d is known for its quick setup and low resource footprint, making it perfect for local experimentation.
Performance Testing: Cluster Creation Time
To evaluate how these tools perform, I conducted a test for cluster creation using Minikube, kind, and k3d on my laptop. Below are the command outputs showing how long it took to set up a cluster with each tool. k3d is clearly a winner.
Minikube – 1minute 43seconds
β minikube start
π minikube v1.34.0 on Ubuntu 22.04
β¨ Automatically selected the docker driver. Other choices: qemu2, virtualbox, ssh
π Using Docker driver with root privileges
π Starting "minikube" primary control-plane node in "minikube" cluster
π Pulling base image v0.0.45 ...
πΎ Downloading Kubernetes v1.31.0 preload ...
> preloaded-images-k8s-v18-v1...: 326.69 MiB / 326.69 MiB 100.00% 18.31 M
> gcr.io/k8s-minikube/kicbase...: 487.90 MiB / 487.90 MiB 100.00% 23.65 M
π₯ Creating docker container (CPUs=2, Memory=3900MB) ...
π³ Preparing Kubernetes v1.31.0 on Docker 27.2.0 ...
βͺ Generating certificates and keys ...
βͺ Booting up control plane ...
βͺ Configuring RBAC rules ...
π Configuring bridge CNI (Container Networking Interface) ...
π Verifying Kubernetes components...
βͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
π Enabled addons: storage-provisioner, default-storageclass
π Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
~ took 1m 43.3s β¦
β kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 30s v1.31.0
KIND – 1minute 8seconds
β kind create cluster
Creating cluster "kind" ...
β Ensuring node image (kindest/node:v1.31.0) πΌ
β Preparing nodes π¦
β Writing configuration π
β Starting control-plane πΉοΈ
β Installing CNI π
β Installing StorageClass πΎ
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Thanks for using kind! π
~ took 1m 8.3s β¦
β kubectl get nodes
NAME STATUS ROLES AGE VERSION
kind-control-plane Ready control-plane 3m6s v1.31.0
K3D – 28.8 seconds
β k3d cluster create k3s-cluster
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-k3s-cluster'
INFO[0000] Created image volume k3d-k3s-cluster-images
INFO[0000] Starting new tools node...
INFO[0001] Pulling image 'ghcr.io/k3d-io/k3d-tools:5.7.4'
INFO[0001] Creating node 'k3d-k3s-cluster-server-0'
INFO[0002] Starting node 'k3d-k3s-cluster-tools'
INFO[0003] Pulling image 'docker.io/rancher/k3s:v1.30.4-k3s1'
INFO[0007] Creating LoadBalancer 'k3d-k3s-cluster-serverlb'
INFO[0008] Pulling image 'ghcr.io/k3d-io/k3d-proxy:5.7.4'
INFO[0016] Using the k3d-tools node to gather environment information
INFO[0016] HostIP: using network gateway 172.18.0.1 address
INFO[0016] Starting cluster 'k3s-cluster'
INFO[0016] Starting servers...
INFO[0016] Starting node 'k3d-k3s-cluster-server-0'
INFO[0020] All agents already running.
INFO[0020] Starting helpers...
INFO[0020] Starting node 'k3d-k3s-cluster-serverlb'
INFO[0026] Injecting records for hostAliases (incl. host.k3d.internal) and for 2 network members into CoreDNS configmap...
INFO[0028] Cluster 'k3s-cluster' created successfully!
INFO[0028] You can now use it like this:
kubectl cluster-info
~ took 28.8s β¦
β kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3d-k3s-cluster-server-0 Ready control-plane,master 86s v1.30.4+k3s1
Based on my research so far, I am summarising my observations:
Features | Minikube | KIND | K3D |
Ease of Use | Easy | Easy | Very Easy |
Resource Efficiency | Moderate | Moderate | Lightweight |
Multi-Node Support | Yes | Yes | Yes |
Installation Time | Moderate | Moderate | Fast |
Platform Support | Most Platforms | Docker | Docker |
Ideal Use Case | General Dev/Test | General Dev/Test/CI | General Dev/Test/CI/Edge/IoT |
Why I Chose k3d?
After evaluating all the options, I selected k3d as the best tool for local Kubernetes development for several reasons:
- Lightweight: k3s uses SQLite for single-node clusters, which minimizes resource usage.
- Fast Setup: The setup time is impressively quick, especially compared to Minikube and kind. Multi-node clusters can be created almost instantly.
- Low Resource Footprint: Even with multiple nodes, k3d performs well on laptops with limited hardware resources.
- Seamless Docker Integration: Since k3d runs inside Docker, the setup is straightforward and efficient.
- Familiarity: I work with RKE2, which is also a product from Rancher, so I feel confident using it on my laptop.
Cluster creation using k3d
The default installation is very simple. I downloaded k3d binary following the instruction from the official documentation. Once the installation is complete, I used k3d to create k3s Kubernetes cluster.
k3d cluster create k3s-cluster
Since I didn’t specify any options, a single-node Kubernetes cluster was created by default. I have the option to customize the cluster either by using command line parameters or by creating a configuration file that I can store in version control (Git).
Here is the configuration file I utilized to set up a highly available Kubernetes cluster featuring two worker nodes.
β cat config.yaml
apiVersion: k3d.io/v1alpha5
kind: Simple
metadata:
name: trinity-cluster
servers: 3
agents: 2
image: docker.io/rancher/k3s:v1.30.4-k3s1
subnet: "172.28.0.0/16"
β k3d cluster list
NAME SERVERS AGENTS LOADBALANCER
trinity-cluster 3/3 2/2 true
~ β¦
β kubectl get nodes
NAME STATUS ROLE VERSION
k3d-trinity-cluster-agent-0 Ready <none> v1.30.4+k3s1
k3d-trinity-cluster-agent-1 Ready <none> v1.30.4+k3s1
k3d-trinity-cluster-server-0 Ready <none> v1.30.4+k3s1
k3d-trinity-cluster-server-1 Ready <none> v1.30.4+k3s1
k3d-trinity-cluster-server-2 Ready <none> v1.30.4+k3s1
~ β¦
β docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}"
CONTAINER ID NAMES IMAGE
178c71bb76bb k3d-trinity-cluster-serverlb ghcr.io/k3d-io/k3d-proxy:5.7.4
3f91747757dc k3d-trinity-cluster-agent-1 rancher/k3s:v1.30.4-k3s1
0256e9846ab8 k3d-trinity-cluster-agent-0 rancher/k3s:v1.30.4-k3s1
ee22041f8ea7 k3d-trinity-cluster-server-2 rancher/k3s:v1.30.4-k3s1
88e4f01d554c k3d-trinity-cluster-server-1 rancher/k3s:v1.30.4-k3s1
2135cbecac8e k3d-trinity-cluster-server-0 rancher/k3s:v1.30.4-k3s1
Conclusion
If you want to experiment with Kubernetes locally, k3d offers the best combination of speed, simplicity, and resource efficiency. While Minikube and kind have their advantages, k3d is particularly suited for those looking to run Kubernetes on laptops or other devices with limited resources.
Pingback: Automating SSL/TLS Certificates for Kubernetes using Cert-Manager: Hands-On Guide - SnapInCloud