Kind, short for Kubernetes in Docker, is a tool for running local Kubernetes clusters using Docker containers as “nodes.”
Step 1: Prerequisites
Docker installed on your local machine. If Docker is not installed, you can download it from the Docker website.
Step 2: Install kind
You can install kind using a package manager like Homebrew on macOS or Chocolatey on Windows. For Linux, or to install without a package manager, you can download a release binary. Learn more in https://kind.sigs.k8s.io/docs/user/quick-start/
# macOS
brew install kind
# Windows
choco install kind
# Linux
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind
Step 3: Create a Configuration File
Kind allows us to define the structure of our cluster through a configuration file. In this file, we’ll specify that we want three worker nodes. Create a new file named kind-config.yaml and paste the following content into it:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: dxbook
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
system-reserved: memory=4Gi
- role: worker
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
kubeletExtraArgs:
system-reserved: memory=4Gi,cpu=2
- role: worker
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
kubeletExtraArgs:
system-reserved: memory=4Gi,cpu=2
- role: worker
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
kubeletExtraArgs:
system-reserved: memory=4Gi,cpu=2
This configuration creates a cluster with one control-plane (master) node and three worker nodes.
Step 4: Create a Kubernetes Cluster
Now, we’re ready to create our Kubernetes cluster. We can do so with a single command:
kind create cluster --config cluster/kind-config.yaml
By default, this command will create a cluster with a single node (the control plane node). It might take some minutes, hold on.
Step 5: Verify the Installation
You can verify that your cluster is running and accessible by using the kubectl command, which kind will automatically configure for us.
kubectl cluster-info --context kind-dxbook
This will show you some information about your cluster.
Step 6: Interacting with Your Cluster
You can interact with your cluster using the kubectl command. For example, to view the nodes in your cluster:
kubectl get nodes
You should see one node, with the status “Ready.” That’s it! You now have a Kubernetes cluster running on your local machine.