KinD Cluster Setup (Mac)
Overview
Section titled “Overview”KinD (Kubernetes in Docker) runs Kubernetes clusters using Docker containers as nodes. It’s perfect for local development, testing, and CI/CD pipelines.
Prerequisites
Section titled “Prerequisites”- macOS with Homebrew installed
- Docker Desktop running
Installation
Section titled “Installation”-
Install KinD using Homebrew
Terminal window brew install kind -
Verify installation
Terminal window kind version
Create Cluster
Section titled “Create Cluster”Basic Cluster
Section titled “Basic Cluster”Create a single-node cluster with default settings:
kind create clusterCustom Named Cluster
Section titled “Custom Named Cluster”Create a cluster with a specific name:
kind create cluster --name my-clusterMulti-Node Cluster
Section titled “Multi-Node Cluster”Create a cluster with multiple worker nodes using a config file:
kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4nodes:- role: control-plane- role: worker- role: workerkind create cluster --config kind-config.yaml --name multi-nodeCluster Management
Section titled “Cluster Management”List Clusters
Section titled “List Clusters”kind get clustersGet Cluster Info
Section titled “Get Cluster Info”kubectl cluster-info --context kind-my-clusterDelete Cluster
Section titled “Delete Cluster”# Delete default clusterkind delete cluster
# Delete named clusterkind delete cluster --name my-clusterAccessing the Cluster
Section titled “Accessing the Cluster”KinD automatically configures kubectl to use the new cluster:
# View current contextkubectl config current-context
# List all nodeskubectl get nodes
# Deploy a test applicationkubectl create deployment nginx --image=nginxkubectl expose deployment nginx --port=80 --type=NodePortTroubleshooting
Section titled “Troubleshooting”Docker Not Running
Section titled “Docker Not Running”If you see “Cannot connect to the Docker daemon”, ensure Docker Desktop is running:
docker psCluster Creation Fails
Section titled “Cluster Creation Fails”Delete any existing cluster and try again:
kind delete clusterkind create cluster