Create a local Kubernetes test cluster
This tutorial introduces how to create a local Kubernetes test cluster using Minikube, K3d, and Kind. These tools make it easy to try out KubeBlocks on your local host, offering a great solution for development, testing, and experimentation without the complexity of creating a full production-grade cluster.
Before you start
Make sure you have the following tools installed on your local host:
- Docker: All three tools rely on Docker to create containerized Kubernetes clusters.
- kubectl: The Kubernetes command-line tool for interacting with clusters. Refer to the kubectl installation guide
- Kind
- Minikube
- k3d
Create a Kubernetes cluster using Kind
Kind stands for Kubernetes IN Docker. It runs Kubernetes clusters within Docker containers, making it an ideal tool for local Kubernetes testing.
-
Install Kind. For details, you can refer to Kind Quick Start.
- macOS
- Linux
- Windows
brew install kind
# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-arm64
chmod +x ./kind
sudo cp ./kind /usr/local/bin/kind
rm -rf kindYou can use chocolatey to install Kind.
choco install kind
-
Create a Kind cluster.
kind create cluster --name mykindcluster
This command creates a single-node Kubernetes cluster running in a Docker container.
-
Check whether the cluster is started and running.
kubectl get nodes
>
NAME STATUS ROLES AGE VERSION
mykindcluster-control-plane Ready control-plane 25s v1.31.0You can see a node named
mykindcluster-control-plane
from the output, which means the cluster is created successfully. -
(Optional) Configure a cluster with multiple nodes.
Kind also supports clusters with multiple nodes. You can create a multi-node cluster by a configuration file.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
role: control-plane
role: worker
role: workerUse the configuration file to create a multi-node cluster.
kind create cluster --name multinode-cluster --config kind-config.yaml
-
If you want to delete the Kind cluster, run the command below.
kind delete cluster --name mykindcluster
Create a Kubernetes cluster using Minikube
Minikube runs a single-node Kubernetes cluster on your local machine, either in a virtual machine or a container.
-
Install Minikube. For details, you can refer to Minikube Quck Start.
- macOS
- Linux
- Windows
brew install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
sudo rpm -Uvh minikube-latest.x86_64.rpmYou can use chocolatey to install Minikube.
choco install minikube
-
Start Minikube. This command will create a local Kubernetes cluster.
minikube start
You can also specify other drivers (such as Docker, Hyperkit, KVM) to start it.
minikube start --driver=docker
-
Verify whether Minikube and the K8s cluster is running normally.
Check whether Minikube is running.
minikube status
>
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: ConfiguredCheck whether the K8s cluster is running.
kubectl get nodes
>
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 1d v1.26.3From the output, we can see that the Minikube node is ready.
Create a Kubernetes cluster using k3d
k3d is a lightweight tool that runs k3s (a lightweight Kubernetes distribution) in Docker containers.
-
Install k3d. For details, refer to k3d Quick Start.
- macOS
- Linux
- Windows
brew install k3d
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
You can use chocolatey to install k3d.
choco install k3d
-
Create a k3s cluster.
k3d cluster create myk3s
This command will create a Kubernetes cluster named as
myk3s
with a single node. -
Verify whether this cluster is running normally.
kubectl get nodes
>
NAME STATUS ROLES AGE VERSION
k3d-myk3s-server-0 Ready control-plane,master 31s v1.30.4+k3s1 -
If you want to delete the k3s cluster, run the command below.
k3d cluster delete myk3s