๐ ๏ธ 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.
- Official Documentation: Kind Quick Start
๐ 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.yamlYou 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 -aThe 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 clustersYou 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 testclusterThe output will show:
Deleting cluster "testcluster" ...๐ Further Information
For more tutorials, including how to manage Kind clusters with Ansible, check out:
๐ Resources
-
Official Website: Kind Official Site
-
Documentation: Kind Quick Start
๐ Related
-
Getting Started with Kubernetes โ A guide to setting up and managing Kubernetes clusters.
-
Using Kubernetes with Helm โ Dive deeper into Helmโs features for managing Kubernetes applications.
๐ Explore More
-
Explore Kubernetes Networking to learn about networking in a containerized environment.
-
Dive into CI/CD Pipelines with Kind for integrating Kind in your development and deployment workflows.