Kind

πŸ› οΈ Kind Cheat-Sheet

Kind (Kubernetes IN Docker) is a tool to run Kubernetes clusters in Docker containers. It’s perfect for local development or CI/CD pipelines. Kind makes it easy to create multi-node Kubernetes clusters using Docker as the underlying container engine.


πŸ” Overview

  • Product Type: Tool for running Kubernetes clusters in Docker containers

  • Focus: Local development and CI/CD pipelines

    • Multi-node clusters: Create Kubernetes clusters with multiple nodes (control plane and workers)

    • Lightweight: Runs within Docker containers, making it ideal for resource-constrained environments

    • Integration: Easily integrates with CI/CD pipelines for Kubernetes testing and development

    • Portability: Supports running Kubernetes clusters on any machine with Docker installed


βš™οΈ Installation on Linux

Since Kind uses Docker containers, ensure that Docker is installed and running on your system.

πŸ“₯ Install Kind

To install Kind, download the latest release and move it to /usr/local/bin:

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.16.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

πŸ–±οΈ Cluster Management

πŸ› οΈ Cluster Creation

To create a cluster, you need to define a configuration file (kind-cluster-config.yaml) that specifies the cluster’s desired nodes and roles. Below is an example configuration:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: testcluster
# 1 control plane node and 2 workers
nodes:
  - role: control-plane
  - role: worker
  - role: worker

πŸš€ Create the Cluster

Use the following command to create the cluster:

kind create cluster --config kind-cluster-config.yaml

You will see output similar to the following:

Creating cluster "testcluster" ...
Ensuring node image (kindest/node:v1.25.2)
Preparing nodes
Writing configuration
Starting control-plane
Installing CNI
Installing StorageClass
Joining worker nodes

Set kubectl context to "kind-testcluster"
You can now use your cluster with:
kubectl cluster-info --context kind-testcluster

🐳 Check Docker Containers

To check the Docker containers running, use:

docker ps -a

The output will show containers for the control plane and worker nodes:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac14d8c7a3c9 kindest/node:v1.25.2 "/usr/local/bin/entr..." 2 minutes ago Up About a minute testcluster-worker2
096dd4bf1718 kindest/node:v1.25.2 "/usr/local/bin/entr..." 2 minutes ago Up About a minute 127.0.0.1:42319->6443/tcp testcluster-control-plane
e1ae2d701394 kindest/node:v1.25.2 "/usr/local/bin/entr..." 2 minutes ago Up About a minute testcluster-worker

πŸ”„ Interacting with Your Cluster

You can have multiple Kind clusters running simultaneously. To list all your Kind clusters, use:

kind get clusters

You will see an output like:

kind
kind-2

πŸ› οΈ Set Kubernetes Context

After cluster creation, the context is automatically set to your newly created cluster. You can change contexts using tools like kubectx or manually set it with the --context option in kubectl.

πŸ—‘οΈ Cluster Deletion

To delete a Kind cluster and its associated kubeconfig, use:

kind delete cluster -n testcluster

The output will show:

Deleting cluster "testcluster" ...

πŸ“ Further Information

For more tutorials, including how to manage Kind clusters with Ansible, check out:


πŸ“š Resources



🌍 Explore More


Tags πŸ“š

#kind #kubernetes #docker #cluster-management #local-development