Create a Multi-Node Kubernetes Cluster Inside Docker Using kind in 1 Minute

Setting up a Kubernetes cluster can be quick and easy with Kind (Kubernetes IN Docker). In just 1 minute, you can have a multi-node Kubernetes cluster running inside Docker, perfect for development and testing.
Install Docker:
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Install Kind:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
Create Cluster Inside Docker:
Define the cluster configuration:
# kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
Create the cluster:
kind create cluster --config kind-config.yaml
Install kubectl using Snap:
sudo snap install kubectl --classic
Verify & Manage:
kubectl get nodes
Create a Simple Pod - Deploy a basic Nginx pod:
kubectl run nginx --image=nginx --port=80
Verify the pod is running:
kubectl get pods
Clean Up:
kind delete cluster
This quick setup allows you to create and manage Kubernetes clusters inside Docker effortlessly. It's perfect for rapidly deploying and testing applications, with the simplicity of managing both the cluster and pods in minutes.