Kind Cluster Setup

Lightweight local Kubernetes clusters using Docker containers as nodes. The fastest way to spin up a multi-node K8s environment for learning, CI/CD, and CKA practice.

Source: CKA Day 6 — Kind Tutorial

What is Kind?

Kind (Kubernetes IN Docker) runs local Kubernetes clusters where each “node” is a Docker container running systemd and all Kubernetes components.

AspectKindminikube
RuntimeDocker containersVM (or Docker driver)
StartupFasterSlower
Multi-nodeNative supportLimited
CI/CDExcellentModerate
Best forDev, testing, learningLocal dev with addons

Prerequisites

Single-Node Cluster

# Create default cluster (1 control-plane node)
kind create cluster
 
# Verify
kubectl get nodes
kubectl get pods -n kube-system   # See system components in their default namespace

Multi-Node Cluster

Define topology in kind-config.yaml:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker
kind create cluster --name cka-cluster --config kind-config.yaml
kubectl get nodes

Cluster Management

CommandPurpose
kind create clusterCreate default cluster
kind create cluster --name <name>Create named cluster
kind create cluster --config <file>Create from config
kind get clustersList all clusters
kind delete clusterDelete default cluster
kind delete cluster --name <name>Delete named cluster

Loading Local Images

Kind does not automatically see host Docker images. Load them explicitly:

docker build -t myapp:1.0 .
kind load docker-image myapp:1.0 --name cka-cluster
kubectl run myapp --image=myapp:1.0

Port Mapping

Expose cluster services to your host machine. This is essential for NodePort Services because Kind runs Kubernetes inside Docker containers — node ports are not automatically reachable from the host without explicit mapping.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
    extraPortMappings:
      - containerPort: 30001
        hostPort: 30001
        protocol: TCP

With this config, a NodePort Service exposed on port 30001 inside the Kind node becomes accessible at localhost:30001 on your host. On cloud VMs, bare metal, or the CKA exam, NodePort works without extra configuration. Source: CKA Day 9

CKA Relevance

Kind provides a safe sandbox for:

  • Practicing kubectl commands and YAML manifests
  • Observing pod scheduling across multiple nodes
  • Testing control plane and networking behaviors
  • Reproducing cluster issues locally

Practical Practice

Exam-style hands-on tasks for this topic. Complete each task before reviewing the solution. Time yourself — CKA tasks average 5–7 minutes.

Task 1: Create a Multi-Node Kind Cluster Create a multi-node Kind cluster with 1 control plane and 2 workers. Requirements: Use a config file. Verification: kubectl get nodes Solution:

cat <<EOF > kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker
EOF
kind create cluster --name cka-cluster --config kind-config.yaml
kubectl get nodes

Task 2: Verify and Run a Test Pod Verify cluster nodes and run a test Pod. Requirements: Deploy nginx and expose it. Verification: kubectl get pods,svc Solution:

kubectl run nginx --image=nginx
kubectl expose pod nginx --port=80 --type=NodePort
kubectl get pods,svc
kubectl exec nginx -- curl -s localhost

Task 3: Export Kubeconfig Export the Kind kubeconfig to a custom file and switch contexts. Requirements: Do not overwrite your default ~/.kube/config unless intended. Verification: kubectl config current-context Solution:

kind get kubeconfig --name cka-cluster > ~/cka-cluster.kubeconfig
export KUBECONFIG=~/cka-cluster.kubeconfig
kubectl config current-context
kubectl get nodes

Tags: kubernetes kind local-cluster cka devops docker