DEV Community

Rajit Paul
Rajit Paul

Posted on • Updated on

Setup KinD (Kubernetes In Docker) on Amazon EC2

Install Docker on Linux -

As I'm using an Amazon Linux I can install docker with a
yum install docker -y
Image description
Start docker service - systemctl start docker

For Docker Installations - https://docs.docker.com/engine/install/

Install Go -

Go to https://go.dev/dl/
Copy the link of go tarfile for linux platform
Install using wget
Image description
Extract it using tar zxf go1.17.7.linux-amd64.tar.gz -C /usr/local

  • Add /usr/local/go/bin to the PATH variable.

Install KinD

go install sigs.k8s.io/kind@v0.11.1
You can replace v0.11.1 with the latest stable kind version

Move the KinD Binary to /usr/local/bin -

  • You can find the kind binary inside the directory go/bin
  • Move it to /usr/local/bin - mv go/bin/kind /usr/local/bin
  • Make sure you have a path setup for /usr/local/bin

Install Latest Version of Kubectl:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin

Create a cluster with kind

kind create cluster --name labcluster
Image description
kubectl get nodes -o wide
Image description
docker ps
Image description

You are now running KinD successfully in Linux
Once done you can delete the cluster using
kind delete cluster

Multi-Node Cluster -

Create a config file kind-example-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:

  • role: control-plane
  • role: worker
  • role: worker

kind create cluster --config kind-cluster-config.yaml
Image description

You now have a running KinD Cluster with one master and two worker nodes.
kubectl get nodes -o wide
Image description

Top comments (2)

Collapse
 
garvitjoshi profile image
Garvit Joshi

Nice Explanation!

Collapse
 
rajitpaul profile image
Rajit Paul

Thanks bhai