DEV Community

Cover image for kind - Creating a Kubernetes Cluster - Part 1
Unni P
Unni P

Posted on • Originally published at iamunnip.hashnode.dev

kind - Creating a Kubernetes Cluster - Part 1

In this article we will look how we can create a local Kubernetes cluster using kind

Introduction

  • Kubernetes has become the de facto standard for container orchestration in the modern cloud-computing world

  • kind (Kubernetes in Docker) is a tool to create Kubernetes clusters running inside Docker containers

  • Mainly used for testing and local development purposes

  • Uses the same tooling and configuration as a production Kubernetes cluster

Features

  • Cost-effective — No need to worry about cloud bills

  • Flexibility — No need to worry about breaking things

  • Fast iteration — Easily test new features

Installation

  • Spin up a Linux machine, here I’m using Ubuntu 20.04.6 LTS
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
Enter fullscreen mode Exit fullscreen mode
  • Install Docker using the convenience script
$ curl -fsSL https://get.docker.com -o get-docker.sh

$ sudo sh get-docker.sh
Enter fullscreen mode Exit fullscreen mode
  • Add your user to the Docker group, log out and log back in. Now you can execute Docker commands as a normal user
$ sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode
  • Download and install kind binary from the releases page
$ wget https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64

$ sudo install kind-linux-amd64 /usr/local/bin/kind
Enter fullscreen mode Exit fullscreen mode
$ kind version
kind v0.18.0 go1.20.2 linux/amd64
Enter fullscreen mode Exit fullscreen mode
  • Download and install kubectl binary
$ curl -LO https://dl.k8s.io/release/v1.26.3/bin/linux/amd64/kubectl

$ sudo install kubectl /usr/local/bin/kubectl
Enter fullscreen mode Exit fullscreen mode
$ kubectl version --client --output yaml
clientVersion:
  buildDate: "2023-03-15T13:40:17Z"
  compiler: gc
  gitCommit: 9e644106593f3f4aa98f8a84b23db5fa378900bd
  gitTreeState: clean
  gitVersion: v1.26.3
  goVersion: go1.19.7
  major: "1"
  minor: "26"
  platform: linux/amd64
kustomizeVersion: v4.5.7
Enter fullscreen mode Exit fullscreen mode

Usage

  • Creating a cluster
$ kind create cluster --name dev
Creating cluster "dev" ...
 ✓ Ensuring node image (kindest/node:v1.26.3) 🖼 
 ✓ Preparing nodes 📦  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹️ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
Set kubectl context to "kind-dev"
You can now use your cluster with:

kubectl cluster-info --context kind-dev
Enter fullscreen mode Exit fullscreen mode
  • Interacting to cluster
$ kubectl config use-context kind-dev 
Switched to context "kind-dev".
Enter fullscreen mode Exit fullscreen mode
$ kubectl get nodes
NAME                STATUS   ROLES           AGE   VERSION
dev-control-plane   Ready    control-plane   10m   v1.26.3
Enter fullscreen mode Exit fullscreen mode
  • Deploying workload to cluster
$ kubectl run nginx --image=nginx --port=80
pod/nginx created
Enter fullscreen mode Exit fullscreen mode
$ kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          22s
Enter fullscreen mode Exit fullscreen mode
  • Deleting cluster
$ kind delete cluster --name dev
Deleting cluster "dev" ...
Deleted nodes: ["dev-control-plane"]
Enter fullscreen mode Exit fullscreen mode

Reference

https://kind.sigs.k8s.io

Top comments (0)