kind Cheatsheet
Last Updated: 2023-09-18
# Create clusters.
$ kind create cluster --name test-cluster
# Get clusters.
$ kind get clusters
test-cluster
# Get nodes of a cluster.
$ kind get nodes --name test-cluster
test-cluster-control-plane
# Get kubeconfig and use it to talk to the cluster.
$ kind get kubeconfig --name test-cluster > ~/test-cluster-kubeconfig
$ kubectl --kubeconfig ~/test-cluster-kubeconfig ...
$ k9s --kubeconfig ~/test-cluster-kubeconfig
$ kind export kubeconfig --name test-cluster
Set kubectl context to "kind-test-cluster"
# `current-context` of `~/.kube/config` is updated to `kind-test-cluster`
# Export logs
$ kind export logs --name test-cluster
Exporting logs for cluster "test-cluster" to: /path/to/log
# load images; calls `ctr images import` under the hood.
$ kind load image-archive
# Get IP address
$ docker container inspect test-cluster-control-plane \
--format '{{ .NetworkSettings.Networks.kind.IPAddress }}'
# Delete clusters.
$ kind delete cluster --name test-cluster
# Check kind version
$ kind version
Check inside the control plane node.
# Get the container name of the control plane.
$ docker ps
CONTAINER ID IMAGE ... NAMES
2ff461dc6529 kindest/node:v1.xx.x ... test-cluster-control-plane
# Get inside the container.
$ docker exec -it test-cluster-control-plane bash
# List images on the control plane node.
root@test-cluster-control-plane:/# crictl images
# List running containers.
root@test-cluster-control-plane:/# crictl ps
# List running processes
root@test-cluster-control-plane:/# ps aux
Notes about control plane processes:
- built-in components as expected:
kube-apiserver
,kube-scheduler
,kube-controller-manager
,kube-proxy
,etcd
,coredns
, etc containerd
as a CRI implementation to deal with Pods and containers. No docker inside the control plane docker container.
Networking
By default Kind clusters use a bridge network named kind
(check by docker network ls
). This can be overriden by setting KIND_EXPERIMENTAL_DOCKER_NETWORK
.
$ KIND_EXPERIMENTAL_DOCKER_NETWORK=test-network kind create cluster --name test-cluster-with-test-network
# List networks
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
02ef0832c25e test-network bridge local
# Check details of the network
$ docker network inspect test-network
# Clean up unused networks
$ docker network prune
The number of networks you can create is limited by /etc/docker/daemon.json
. You may see this error:
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
Create clusters with multiple nodes
$ cat <<EOF | kind create cluster --name test-cluster-with-multiple-nodes --config -
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
$ kind get nodes --name test-cluster-with-multiple-nodes
test-cluster-with-multiple-nodes-worker
test-cluster-with-multiple-nodes-worker2
test-cluster-with-multiple-nodes-control-plane
Shell Completion
# bash
$ source <(kind completion bash)
$ echo "source <(kind completion bash)" >> ~/.bashrc
# zsh
$ source <(kind completion zsh)
# or
$ echo "source <(kind completion zsh)" >> ~/.zshrc
Create a kind cluster with rootless docker
$ export DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/docker.sock
$ kind create cluster
Dependencies
- Providers: Rootless Docker and Rootless Podman.
- kind uses
kubeadm
to configure cluster nodes.
Provider
Provider is used to perform cluster operations.
A Provider has an internal provider + a logger
Node Image
Base image: https://github.com/kubernetes-sigs/kind/blob/main/images/base/Dockerfile
Node image (pkg/build/nodeimage/
) is built upon base image
node image = base image (basic utilities like systemd, certificates, mount, etc.) + k8s packages and binaries (e.g. kubeadm, kubectl, kubelet)