Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Kind: Kubernetes clusters in Docker containers

33 min read
Improve this page

Logo kind

Kind (Kubernetes IN Docker) creates complete Kubernetes clusters by using Docker containers as nodes. Where a real Kubernetes installation needs several machines or VMs, Kind runs everything in containers, with no VM to boot, so a cluster is quick to create and destroy.

The idea is simple: each "machine" of your Kubernetes cluster is actually a Docker container. The control-plane runs in one container, the workers in other containers. Docker handles the isolation and the network between them. This principle is enough for CI/CD tests, local development and learning.

This guide shows you how to install Kind, understand how it works internally, create clusters with different topologies, and fix common problems.

What you will learn

  • Create a disposable cluster for dev/CI with one command, no VM to boot
  • Build a multi-node cluster (workers) to simulate a real environment
  • Configure a multi control-plane cluster to test high availability
  • Expose your applications with extraPortMappings and NodePort
  • Load your local Docker images without going through a registry
  • Set up a local registry for a smooth development workflow
  • Troubleshoot common problems

When to choose Kind (and when to avoid it)

Kind, Minikube and K3s can all run Kubernetes on a single machine, with different approaches. The table below compares them.

CriterionKindMinikubeK3s
Use caseCI/CD, tests, disposable clustersLocal dev, learningEdge / IoT / homelab, light production
Datastoreetcd (kubeadm) in the control-planesetcd (kubeadm), stacked HASQLite (default); embedded etcd (HA)
Multi-nodeYes, via YAML configYes, --nodesYes, native (server/agent)
HA control planeYes, multiple control-planes (Envoy)Yes, --ha (min. 3 CP) + kube-vipYes, embedded etcd (min. 3 servers)
ResourcesNo published minimum for running a cluster2 CPU, 20 GB disk (default)Agent ~275 MiB, Server ~1.6 GiB
GPUTo configure yourselfYes, --gpus (Docker driver)To configure (toolkit + plugin)
PersistenceRather disposableYes, persistent profilesYes, system-wide cluster (systemd)
InstallationDocker "node" containersVM or container depending on the driverBinary + service (Linux)

Why choose Kind?

Kind was created by the Kubernetes team itself to test Kubernetes, and it is also used for local development and in CI. This origin explains its strengths:

  • Reproducibility: same behavior locally and in CI
  • Conformance: vanilla Kubernetes, no modifications
  • Multiple topologies: test realistic scenarios (HA, multiple workers)
  • Lightweight: no VM, no hypervisor, just Docker

When to avoid Kind?

  • GPU: Kind does not expose the host GPUs to the nodes, so you have to configure it yourself. Minikube can do it with the --gpus option.
  • Strong isolation: containers share the host kernel. For full VM isolation, prefer Minikube with VirtualBox/KVM.
  • Graphical interface: Kind is CLI-only. Minikube has a built-in dashboard.

Kind architecture

Understanding how Kind works will help you diagnose problems and configure your clusters correctly.

In a real Kubernetes cluster, each node is a machine (physical or VM) with its own operating system, its kubelet and its container runtime. Kind reproduces this architecture but replaces the machines with Docker containers.

Kind architecture: on the host machine, Docker or Podman runs a control-plane container (API Server, etcd, Scheduler, Controller Manager, kubelet, containerd, kindnetd) and a worker container (kubelet, containerd, kube-proxy, kindnetd, your Pods), connected by the kind bridge network.Host machine (Linux, macOS, Windows)Docker or Podman, kind bridge networkcontrol-plane containerworker containerAPI ServeretcdSchedulerController Mgrkubeletcontainerdkindnetd (CNI)kubeletcontainerdkube-proxykindnetdYour Pods
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

How does it work in practice?

When you create a Kind cluster, here is what happens:

  1. Docker creates a container based on the kindest/node image. This image contains a complete Linux system with systemd, kubelet, containerd, and all the Kubernetes components pre-installed.

  2. The container starts like a "machine": systemd starts kubelet, which in turn starts the system pods (kube-apiserver, etcd, etc.) through containerd.

  3. The pods run inside the node container: inside the Docker container, it is containerd, not Docker, that runs the containers of your applications. Your pods are therefore containers nested inside a Docker container.

The key components

  • kindnetd: the CNI (Container Network Interface) provided by Kind. It handles the network between pods. It is a simple implementation based on ptp and host-local, good enough for tests but without the advanced features of Calico or Cilium.

  • Docker kind network: Kind creates a dedicated Docker bridge network. All the nodes of the cluster communicate through this network. This is why your Kind containers can see each other.

  • Envoy (HA clusters): when you create several control-planes, Kind automatically adds an Envoy container in front of them. It is the single entry point for the Kubernetes API, like the virtual IP (VIP) of a real HA cluster. Up to Kind 0.31 this role was played by HAProxy: if you read older documentation, it is the same function under another name.

Prerequisites

Before installing Kind, check these prerequisites:

  1. Container runtime: Docker, Podman or nerdctl installed and working

    Terminal window
    docker --version
    # Docker version 29.1.3, build f52814d
  2. kubectl (optional but recommended): to interact with the cluster

    Terminal window
    kubectl version --client
    # Client Version: v1.36.0
  3. System resources: count on about 2 GB of free memory for a single-node cluster (this is the figure used in the lesson Create your first local Kubernetes cluster with kind), and more for each node you add. The Kind documentation does not publish a minimum for running a cluster; its 6 GB (8 GB recommended) apply to building a node image under Docker Desktop.

Installing Kind

Kind is distributed as a single binary. Several installation methods are available.

Recommended method, especially for CI: you choose the exact version.

Terminal window
# Download the binary (AMD64)
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.33.0/kind-linux-amd64
# Download the binary (ARM64)
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.33.0/kind-linux-arm64
# Make it executable and move it into the PATH
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
# Check the installation
kind version
# kind version 0.33.0

Package managers (community)

Terminal window
brew install kind

Create your first cluster

Let's start with the simplest case: a single-node cluster. It is enough for most development and unit tests. If you are new to Kubernetes, the lesson Create your first local Kubernetes cluster with kind does the same thing step by step; this page goes further into Kind configuration.

Terminal window
kind create cluster --name demo --wait 60s

Let's break this command down:

  • --name demo: names the cluster. Without this flag, Kind uses "kind" by default. Always name your clusters, it avoids confusion when you have several of them.

  • --wait 60s: waits until the cluster is ready before giving control back. Essential in CI to avoid race conditions where you try to deploy before the API server answers.

Creating cluster "demo" ...
✓ Ensuring node image (kindest/node:v1.37.0) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Waiting ≤ 1m0s for control-plane = Ready ⏳
• Ready after 17s 💚
Set kubectl context to "kind-demo"

Each step matches a concrete action:

  1. Ensuring node image: downloads the kindest/node:v1.37.0 image if it is missing. This image contains a pre-installed Kubernetes.

  2. Preparing nodes: creates the Docker container that will be your node.

  3. Writing configuration: generates the certificates, the kubeconfig, etc.

  4. Starting control-plane: starts kubelet in the container, which then starts the system pods (API server, etcd, scheduler, controller-manager).

  5. Installing CNI: deploys kindnetd for the network between pods.

  6. Installing StorageClass: configures local storage for PersistentVolumes.

Check that the cluster is ready:

Terminal window
kubectl get nodes
NAME STATUS ROLES AGE VERSION
demo-control-plane Ready control-plane 22s v1.37.0

The node is Ready: the cluster is working.

Use a specific Kubernetes version

By default, Kind uses the latest supported version, v1.37.0 with Kind v0.33.0. To test compatibility with a specific version:

Terminal window
kind create cluster --name k8s-1-36 --image kindest/node:v1.36.4@sha256:099e049362a1526b2db71494e1947aae99bd16290d7c895f2b7ea312e3cbfaed

Kind v0.33.0 publishes four node images: v1.37.0, v1.36.4, v1.35.8 and v1.34.11. The first three match the versions currently maintained by the Kubernetes project, which supports only three at a time. Each Kind release provides its own list, published on the GitHub releases page.

Pin the image rather than the Kind version. An aging Kind binary keeps creating clusters, but with a Kubernetes version that falls out of support: you then learn on a cluster that nobody patches anymore.

The Kind YAML configuration

The command line is enough for a simple cluster, but real use cases need a YAML configuration. This configuration lets you define reproducible clusters, versioned in Git, and shared between developers.

Minimal structure

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: mon-cluster

This is equivalent to kind create cluster --name mon-cluster. The benefit comes when you add options that cannot be expressed on the command line.

Multi-node cluster: why and how

A single-node cluster does not reflect reality. In production, you have a control-plane and several workers. Some behaviors only appear with several nodes:

  • The distribution of pods across workers (scheduling)
  • Pod affinities/anti-affinities
  • PodDisruptionBudgets (you cannot drain a node if there is only one)
  • The inter-node network behavior
kind-multi-node.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: multi-node
nodes:
- role: control-plane
- role: worker
- role: worker

Here, we declare 3 nodes: 1 control-plane and 2 workers. Kind will create 3 Docker containers.

Terminal window
kind create cluster --config kind-multi-node.yaml --wait 120s
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP
multi-node-control-plane Ready control-plane 43s v1.37.0 172.26.0.4
multi-node-worker Ready <none> 34s v1.37.0 172.26.0.5
multi-node-worker2 Ready <none> 34s v1.37.0 172.26.0.6

Note that the workers show no role (<none>). This is normal: only the control-planes have the node-role.kubernetes.io/control-plane label.

Multi control-plane cluster (HA): test high availability

In production, a single control-plane is a SPOF (Single Point of Failure). If the API server goes down, nobody can interact with the cluster anymore. For high availability, you deploy 3 control-planes (or 5 for very large clusters).

Kind lets you simulate this architecture:

kind-ha.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: ha-cluster
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker

Why 3 control-planes? It comes down to etcd, the Kubernetes database. Etcd uses a consensus (Raft) that needs a majority to work. With 3 nodes, you tolerate 1 failure. With 5 nodes, 2 failures.

Terminal window
kind create cluster --config kind-ha.yaml --wait 180s
Creating cluster "ha-cluster" ...
✓ Ensuring node image (kindest/node:v1.37.0) 🖼
✓ Preparing nodes 📦 📦 📦 📦
✓ Configuring the external load balancer ⚖️
✓ Writing configuration 📜
...

Note the "Configuring the external load balancer" step. Kind automatically adds an Envoy container in front of the 3 control-planes:

Terminal window
docker ps --format "table {{.Names}}\t{{.Status}}" | grep ha-cluster
ha-cluster-external-load-balancer Up About a minute
ha-cluster-control-plane3 Up About a minute
ha-cluster-control-plane2 Up About a minute
ha-cluster-control-plane Up About a minute
ha-cluster-worker Up About a minute

This container is not a Kubernetes node, so it does not appear in kubectl get nodes. Its image confirms it:

Terminal window
docker inspect ha-cluster-external-load-balancer --format '{{.Config.Image}}'
docker.io/envoyproxy/envoy:v1.36.2

This component changed in Kind v0.32: it was HAProxy until then, it is Envoy since. The function is identical, only the container name and its image differ. Tutorials from before June 2026 still mention HAProxy.

Your kubeconfig points to the load balancer, not to a particular control-plane. If a control-plane goes down, Envoy routes to the others:

Terminal window
kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'
docker port ha-cluster-external-load-balancer
https://127.0.0.1:35107
6443/tcp -> 127.0.0.1:35107

The host port is picked at random at creation time, yours will be different.

extraPortMappings: expose ports to the host

A classic problem: you deploy an application in Kind, but how do you reach it from your browser?

By default, Kind nodes sit in an isolated Docker network. Your browser (on the host) cannot directly reach the Kubernetes services.

Solution: map a port of the Kind container (the "node") to a port of your host machine. It works exactly like Docker's -p 8080:80, but applied to the Kind container.

kind-with-ports.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: with-ports
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080 # Port on the Kind node (NodePort)
hostPort: 8080 # Port on your machine
listenAddress: "127.0.0.1" # Listen on localhost only
protocol: TCP

How does it work?

  1. You create a Kubernetes service of type NodePort on port 30080
  2. The Kind node listens on port 30080
  3. Docker maps this port to port 8080 of your machine
  4. You open http://localhost:8080

Complete example: deploy nginx and reach it

Terminal window
# Create the cluster with the port mapping
kind create cluster --config kind-with-ports.yaml --wait 60s
# Deploy nginx
kubectl create deployment nginx --image=nginx:1.30.7-alpine@sha256:caf4e1e032a20f9c3c5e28fc7f25ffd768ad8677b4975c54193075997b3a97e3 --port=80
# Expose it on a NodePort
kubectl expose deployment nginx --type=NodePort --port=80 --target-port=80
# Force the NodePort to 30080 (otherwise Kubernetes picks a random one)
kubectl patch svc nginx -p '{"spec":{"ports":[{"port":80,"nodePort":30080}]}}'
# Wait for the pod to be ready
kubectl wait --for=condition=ready pod -l app=nginx --timeout=60s
# Test access from your machine
curl http://127.0.0.1:8080

extraMounts: share files with the nodes

Use case: you are developing an application and want to test without rebuilding the image after each change. Or you have configuration files to inject into the cluster.

extraMounts mounts a folder of your machine into the Kind container (the "node"). This folder is then available to the pods through hostPath volumes.

kind-with-mounts.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: with-mounts
nodes:
- role: control-plane
extraMounts:
- hostPath: /home/dev/mon-projet/dist
containerPath: /app
- hostPath: /home/dev/configs
containerPath: /configs
readOnly: true # Protection against accidental writes

Warning: this is a 2-step mount:

  1. Host → Kind container: extraMounts does this
  2. Kind container → Pod: you must configure a hostPath volume in your Kubernetes manifest
pod-with-hostpath.yaml
apiVersion: v1
kind: Pod
metadata:
name: mon-app
spec:
containers:
- name: app
image: nginx:1.30.7@sha256:7fad6c0dff97965adbddf28027d934b111fc0221a554315dc274712f3fba24d3
volumeMounts:
- name: app-files
mountPath: /usr/share/nginx/html
volumes:
- name: app-files
hostPath:
path: /app # The path INSIDE the Kind container
type: Directory

Load local images

The problem: you built a Docker image locally (docker build -t mon-app:v1 .), but when you deploy it in Kind, Kubernetes cannot find it.

Why? Remember the architecture: Kind nodes use containerd, not Docker. Your image exists in the Docker daemon of your machine, but the Kind nodes have their own image store (containerd). These are two separate worlds.

There are two solutions: kind load (simple) or a local registry (recommended for intensive development).

Method 1: kind load (for simple cases)

kind load docker-image copies an image from Docker to the Kind nodes.

Terminal window
# Build your image (in Docker)
docker build -t mon-app:v1 .
# Copy it to the Kind cluster
kind load docker-image mon-app:v1 --name demo

The command announces what it does, node by node:

Image: "mon-app:v1" with ID "sha256:1c4f325378dc..." not yet present on node "demo-control-plane", loading...

Check that the image is in the node:

Terminal window
docker exec demo-control-plane crictl images | grep mon-app
docker.io/library/mon-app v1 221e519220e87 2.21MB

When to use kind load?

  • You test an image occasionally
  • You are in CI and the image is built only once per job
  • You have few images to load

When to avoid kind load?

  • You iterate quickly (rebuild every 5 minutes)
  • You have many images or heavy images
  • You want several developers to share the images

The problem with kind load: every code change needs a rebuild, then a kind load. It is slow and tedious.

The solution: a local registry. You push your images to localhost:5001, and the Kind nodes pull them from this registry. It is the standard workflow of a cloud registry (Docker Hub, GCR...) but local.

  1. Create the setup script:

    This script does 5 things: it creates the registry, creates the cluster, configures containerd to recognize the registry, connects the networks, and documents the registry through a ConfigMap.

    kind-with-registry.sh
    #!/bin/sh
    set -o errexit
    # 1. Create the registry container (if it does not exist yet)
    reg_name='kind-registry'
    reg_port='5001'
    if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
    docker run -d --restart=always -p "127.0.0.1:${reg_port}:5000" \
    --network bridge --name "${reg_name}" registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
    fi
    # 2. Create the Kind cluster
    kind create cluster --name with-registry --wait 60s
    # 3. Configure containerd to resolve localhost:5001 to the registry
    # Without this step, the nodes do not know where the registry is
    REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}"
    for node in $(kind get nodes --name with-registry); do
    docker exec "${node}" mkdir -p "${REGISTRY_DIR}"
    cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml"
    [host."http://${reg_name}:5000"]
    EOF
    done
    # 4. Connect the registry to the Kind network
    # Otherwise the nodes cannot reach the registry container
    docker network connect "kind" "${reg_name}" 2>/dev/null || true
    # 5. Document the registry (KEP-1755 convention)
    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: local-registry-hosting
    namespace: kube-public
    data:
    localRegistryHosting.v1: |
    host: "localhost:${reg_port}"
    EOF
  2. Run the script:

    Terminal window
    chmod +x kind-with-registry.sh
    ./kind-with-registry.sh
  3. Use the registry:

    Terminal window
    # Tag an image for the local registry
    docker pull nginx:1.30.7-alpine@sha256:caf4e1e032a20f9c3c5e28fc7f25ffd768ad8677b4975c54193075997b3a97e3
    docker tag nginx:1.30.7-alpine@sha256:caf4e1e032a20f9c3c5e28fc7f25ffd768ad8677b4975c54193075997b3a97e3 localhost:5001/nginx:1.30.7-alpine
    # Push to the registry
    docker push localhost:5001/nginx:1.30.7-alpine
    # Deploy in Kind: the image will be pulled from the local registry
    kubectl create deployment nginx --image=localhost:5001/nginx:1.30.7-alpine

Managing clusters

List existing clusters

Terminal window
kind get clusters
demo
ha-cluster
with-registry

Each name matches a set of Docker containers prefixed with that name.

Switch the kubectl context

Kind automatically configures your kubeconfig when a cluster is created. But if you have several clusters, you have to switch between them:

Terminal window
# See all the available contexts
kubectl config get-contexts
# Switch to a specific cluster
kubectl config use-context kind-demo

The Kind context follows the kind-{cluster-name} convention.

Delete a cluster

Terminal window
kind delete cluster --name demo
Deleting cluster "demo" ...
Deleted nodes: ["demo-control-plane"]

This command deletes the Docker containers and cleans up the kubeconfig. Deletion is idempotent: deleting a nonexistent cluster does not produce an error. This is handy in CI for a systematic cleanup at the end of a job.

Export logs for debugging

When something does not work, the cause is usually in the logs. Kind exports all of the cluster's logs with one command:

Terminal window
kind export logs ./kind-logs --name demo
Exporting logs for cluster "demo" to:
./kind-logs

You get a complete structure:

kind-logs/
├── docker-info.txt # Docker info (version, config)
├── kind-version.txt # Kind version
└── demo-control-plane/ # Logs per node
├── containerd.log # Container runtime logs
├── containers/ # Logs of each container (system pods)
├── inspect.json # State of the Docker container
├── journal.log # Full systemd journal
├── kubelet.log # Kubelet logs (very useful!)
├── kubernetes-version.txt
└── pods/ # Pod logs per namespace

The most useful files:

  • kubelet.log: pod startup errors, scheduling problems
  • containerd.log: image pull errors
  • pods/kube-system/: system pod logs (API server, etcd...)

Expose services (LoadBalancer/Ingress)

The problem: in production, you use LoadBalancer services and Kubernetes assigns you an external IP. But Kind runs on your machine, and there is no cloud provider to provision IPs.

As a result, your LoadBalancer services stay in EXTERNAL-IP: <pending> forever.

The solution: cloud-provider-kind

cloud-provider-kind is a component that simulates a cloud provider for Kind. It assigns external IPs to LoadBalancer services and handles routing through Envoy containers.

Terminal window
# Installation through Go, pinned version
go install sigs.k8s.io/cloud-provider-kind@v0.12.0

Or download the binary of the same version from the GitHub releases.

Use a LoadBalancer

  1. Start cloud-provider-kind (in a separate terminal):

    Terminal window
    cloud-provider-kind

    This process must stay running. It watches the LoadBalancer services and provisions the IPs.

  2. Create a LoadBalancer service:

    Terminal window
    # Deploy a test app
    kubectl create deployment echo --image=hashicorp/http-echo:0.2.3@sha256:ba27d460cd1f22a1a4331bdf74f4fccbc025552357e8a3249c40ae216275de96 \
    -- -text="Hello from Kind"
    # Expose it as a LoadBalancer
    kubectl expose deployment echo --type=LoadBalancer --port=80 --target-port=5678
  3. Get the external IP:

    Terminal window
    kubectl get svc echo
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    echo LoadBalancer 10.96.7.228 172.19.0.4 80:30964/TCP 18s

    The EXTERNAL-IP is now assigned, cloud-provider-kind did its job.

  4. Test access:

    Terminal window
    curl http://172.19.0.4
    # Hello from Kind

Alternative: extraPortMappings + NodePort

If you do not want to depend on cloud-provider-kind, the extraPortMappings approach described above works too. It is simpler but less "realistic" (no real external IP).

Troubleshooting

Common problems and solutions

SymptomLikely causeSolution
Nodes NotReady for a long timeCNI not deployed yetUse --wait 120s, check kubectl describe node
connection refused on the APIAPI server not startedkind export logs, analyze kubelet.log
ErrImagePull for a local imageimagePullPolicy: Always + :latest tagUse an explicit tag (v1) or IfNotPresent
Port already in useConflict with another servicenetstat -tlnp | grep <port>, change the hostPort
Ingress does not work (rootless)Ports < 1024 forbidden in rootlesssysctl net.ipv4.ip_unprivileged_port_start=0
kind load failsNonexistent cluster or wrong nameCheck kind get clusters, use --name
kind load: content digest ... not foundMulti-architecture image + Docker's containerd image storeLet the cluster pull the image from the registry, kind load is only for images you build
cgroup v1 detected warningThe host still runs cgroup v1Move the host to cgroup v2: Kubernetes deprecated cgroup v1, Kind warns since v0.32

Diagnostic commands

When something does not work, here is the debug sequence:

Terminal window
# 1. Is the state of the nodes good?
kubectl get nodes -o wide
kubectl describe node <node-name> # Look for "Conditions" and "Events"
# 2. Are all the system pods Running?
kubectl get pods -n kube-system
# If a pod is not Running, describe it:
kubectl describe pod -n kube-system <pod-name>
# 3. Are there any abnormal recent events?
kubectl get events --all-namespaces --sort-by='.lastTimestamp' | tail -20
# 4. Are the Kind Docker containers healthy?
docker ps --filter "name=mon-cluster"
docker logs mon-cluster-control-plane 2>&1 | tail -50
# 5. As a last resort: full export of the logs
kind export logs ./debug-logs --name mon-cluster
# Then analyze kubelet.log and containerd.log

Problem: "Unable to connect to the server"

This is often a kubectl context problem or a deleted cluster:

Terminal window
# Check the current context
kubectl config current-context
# List the existing Kind clusters
kind get clusters
# If the cluster was deleted but the context still exists:
kubectl config delete-context kind-mon-ancien-cluster

Best practices

For CI/CD

CI is a typical use case for Kind. A few recommendations:

  • Release binary: download a specific version, not go install latest. You want reproducible builds.

  • --wait is mandatory: without this flag, your script carries on before the cluster is ready, and the first commands fail at random.

  • Systematic cleanup: kind delete cluster at the end of the job, even if the tests fail. Use after_script or finally.

  • Export logs on failure: without logs, a CI failure is very hard to diagnose. Archive them as artifacts.

# GitLab CI example
test-kubernetes:
script:
- kind create cluster --name ci-test --wait 120s
- kubectl apply -f manifests/
- ./integration-tests.sh
after_script:
- kind export logs ./logs || true
- kind delete cluster --name ci-test || true
artifacts:
when: on_failure
paths: [logs/]

For local development

  • Local registry: if you iterate often, the registry saves you the repeated kind load. Setting it up takes a few minutes and pays off quickly.

  • extraMounts: for hot-reload, mount your source code in the Kind node and use a pod that watches the files.

  • Name your clusters: one name per project (kind-monprojet). You can run several clusters in parallel without conflicts.

  • Version your config: commit your kind-config.yaml file in the repo. Everybody uses the same configuration.

Security (even in dev!)

  • apiServerAddress: 127.0.0.1: by default, the API server listens only on localhost. Do not change this unless you know what you are doing.

  • Kind is not for production: no in-place security updates, no support, no SLA. It is a testing tool.

  • Isolate clusters: one cluster per test environment. Do not mix tests that could interfere with each other.

Key takeaways

  • Kind = Kubernetes IN Docker: Kubernetes nodes in Docker containers
  • Quick installation: a single binary, no VM to boot
  • Multi-node and HA: native through the YAML config
  • extraPortMappings: to expose NodePorts to the host
  • kind load: loads a local image into the cluster
  • Local registry: recommended workflow for intensive development
  • kind export logs: gathers all the cluster logs for debugging
  • cloud-provider-kind: enables LoadBalancer and Ingress

Next steps

Resources