
Local Sandbox Kubernetes for Development with Kind
Local Dev Kubernetes Cluster with Kind
When spinning up a kubernetes cluster on gcp or aws it may take time to provision. A quick way to spin up a cluster locally is by using this tool called Kind. You may want to set this up for testing purposes or for experimenting with a new tool. Setting up a full-blown Kubernetes cluster for just some testing can feel like overkill, right? It’s like a mini Kubernetes playground right on our local machines!
So, What’s Kind Anyway?
Kind is an open-source project that lets us run Kubernetes on our laptops. It uses Docker to create a bunch of containers, each pretending to be a node in a Kubernetes cluster. So, if you’re looking to see how your app runs in a Kubernetes environment but don’t want the hassle of a full-sized cluster, Kind is a great option.
Whats difference between kind and minikube?
Kind (Kubernetes in Docker) and Minikube are both tools that allow you to run Kubernetes locally, but they do so in slightly different ways and each has its own strengths.
Kind
Kind runs Kubernetes clusters using Docker containers as “nodes”. This makes it a lightweight option, especially useful for creating multiple-node clusters. It can also be used to mimic more complex Kubernetes deployments and networking scenarios. Kind is mainly designed for testing Kubernetes itself, but it can also be used to test local deployments of your applications. It’s often used in continuous integration (CI) systems.
Minikube
Minikube, on the other hand, creates a virtual machine (VM) on your local machine and installs a single-node Kubernetes cluster on it. It’s designed to be easy to use and is great for beginners learning Kubernetes or for local development and testing of applications. Minikube also comes with a number of add-ons for Kubernetes, such as the dashboard, which can be useful for beginners.
Differences
Here are the key differences between the two:
- Architecture: Kind uses Docker containers to create Kubernetes nodes, whereas Minikube creates a VM to host the Kubernetes cluster. This can make Kind faster to start and stop, but it means that it relies on your local Docker installation.
- Multi-node clusters: Kind can easily create multi-node clusters, whereas Minikube is primarily designed for
- single-node clusters. However, you can pass a flag to allow for creating multiple nodes:
minikube start --nodes 2 -p multinode-demo
- Add-ons: Minikube comes with a range of Kubernetes add-ons like the dashboard and a DNS that can be enabled or disabled as per your requirements. Kind does not have this feature.
- Resource Consumption: Typically, Minikube requires more system resources than Kind, as it operates in a VM.
- Learning Curve: Minikube is often seen as easier for beginners due to its simplicity and the availability of add-ons.
Both tools are excellent for different use cases, and the best one for you depends on your specific needs. If you are just getting started with Kubernetes, Minikube is a great choice. If you need to test more complex deployments or run a local cluster in CI, you might want to look at Kind.
Getting Started
Before we get started, make sure you’ve got Docker installed on your machine. Since Kind uses Docker to create the pretend nodes of our Kubernetes cluster, we’re gonna need it. You can get Docker from their official website or use your package manager if you’re on a Linux system.
Get Kind on Your Machine
Alright, ready to get Kind? It’s pretty straightforward. Head over to their GitHub page and grab the latest release. As of June 2023, we’re looking at version v0.20.0. Here’s the commands you’ll need to execute on a Unix-like system to get it installed:
# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
If you’re running a Windows machine, just download the relevant .exe file from the releases page and add it to your PATH.
Let’s Create a Cluster
Once you’ve got Kind, creating a new cluster is simple. Just pop open your terminal and run:
kind create cluster
This will create a cluster named “kind” by default. But hey, if you want to get creative with your cluster’s name,
go for it with the --name
flag:
kind create cluster
Boom! You’ve got a Kubernetes cluster running on your machine! You can talk to it using kubectl
, the Kubernetes command-line tool. If you don’t have kubectl
installed, you can follow the installation instructions in the official Kubernetes documentation.
You can also create you’re multinode cluster using yaml:
Create this file in local directory call it: kind-cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
Run the following command to create a multiple node cluster
[$USER:~/code/kind]$ kind create cluster --config kind-config.yaml
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.27.3) 🖼
✓ Preparing nodes 📦 📦 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Joining worker nodes 🚜
Set kubectl context to "kind-kind"
You can now use your cluster with:
To make sure everything’s setup, try running:
kubectl cluster-info --context kind-kind
Output:
[USER:~]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kind-control-plane Ready control-plane 3h35m v1.27.3
If everything’s up and running, this will return some info about your shiny new cluster.
Saying Goodbye to Your Cluster
When you’re done playing around, or if you want to start fresh with a new setup, you can wave goodbye to your existing cluster with:
[zmhassan:~]$ kind delete clusters kind
Deleted nodes: ["kind-control-plane"]
Deleted clusters: ["kind"]
This will remove all the Docker containers associated with the cluster disappear, and it’ll clean up any network resources that were created.
Conclusion
So there you have it! Kind is your helpful tool for all things Kubernetes - no need for heavyweight setups. It’s a easy to install and super simple to use. It’s the perfect playground for you to test your apps in a real Kubernetes environment. So go on, get hands on with Kind and Kubernetes.