Intro to Kind Kubernetes (Local Kubernetes Development) - Part 1

A locally running Kubernetes cluster is a valuable tool to both easily learn & experiment with Kuberntes, but also develop new Kuberntes configurations without needing to deploy a Kubernetes cluster to a Cloud provider / hosting stack.

Additionally, for developer teams, it allows each developer to experiment on their own local Kubernetes cluster rather than using a shared cluster with the inherent disruption of multiple developers experimenting on the same cluster.

Finally, In your CI runs, having a local Kubernetes cluster provides the oportunity to test kubernetes deployments within your CI environment whithout deploying a full Kubernetes cluster. This allows for more testing earlier in the development cycle while also reducing the time & cost to test as spining a full kubernetes cluster in a cloud provider takes much more time & costs significantly more.

There are a few other easily installable Kubernetes projects such as MicroK8s, K3s (Rancher) or MiniKube. If you are setting up a home lab, MicroK8s or K3s would make the most sence. MiniKube & Kind (this guide) are focused around local development & testing.

Kind sets itself apart from MiniKube with it’s focus on running Kubernetes in docker (MiniKube now supports this as well), along with its support for multi node HA clusters (all running locally).

This guide walks through the basics getting Kind Kubernetes installed & configured. For your specific environment jump to to the Linux (Ubuntu), Mac, or Windows Sections.

Linux (Ubuntu)

Ubuntu Version: Ubuntu 18.04.4 LTS

Prerequisites:

Download Kind Binary & move to location in your PATH

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

The first time you create a kind Kubernetes cluster, it will take a couple minutes to download the docker images.

Run:

kind create cluster
 Creating cluster "kind" ...
 βœ“ Ensuring node image (kindest/node:v1.19.1) πŸ–Ό 
 βœ“ Preparing nodes πŸ“¦  
 βœ“ Writing configuration πŸ“œ 
 βœ“ Starting control-plane πŸ•ΉοΈ 
 βœ“ Installing CNI πŸ”Œ 
 βœ“ Installing StorageClass πŸ’Ύ

To interact with the kubernetes cluster, install the kubernetes CLI. On Ubuntu 18, this can be done with a snap. For more install options, see Kubernetes Docs

Run:

sudo snap install kubectl --classic
kubectl 1.20.1 from Canonicalβœ“ installed

If you have multiple Kubernetes configurations on your machine, run the below command to set your Kubernetes context to use the Kind config.

kubectl config set-context kind-kind
Context "kind-kind" modified.

Verify the cluster is running by listing the cluster nodes

kubectl get nodes
NAME                 STATUS   ROLES    AGE   VERSION
kind-control-plane   Ready    master   15m   v1.19.1

You how have a running local Kubernetes cluster!

To cleanup the cluster, run:

kind delete cluster
Deleting cluster "kind" ...

Mac

Prerequisites:

Mac installation is simplified greatly by brew (the Mac package manager). If you haven’t already, see brew installation.

Once brew is installed, installing kind is as simple as:

brew install kind

The first time you create a kind Kubernetes cluster, it will take a couple minutes to download the docker images.

Run:

kind create cluster
 Creating cluster "kind" ...
 βœ“ Ensuring node image (kindest/node:v1.19.1) πŸ–Ό 
 βœ“ Preparing nodes πŸ“¦  
 βœ“ Writing configuration πŸ“œ 
 βœ“ Starting control-plane πŸ•ΉοΈ 
 βœ“ Installing CNI πŸ”Œ 
 βœ“ Installing StorageClass πŸ’Ύ

Install the kubernetes CLI by running:

brew install kubectl

If you have multiple Kubernetes configurations on your machine, run the below command to set your Kubernetes context to use the Kind config.

kubectl config set-context kind-kind
Context "kind-kind" modified.

Verify the cluster is running by listing the cluster nodes

kubectl get nodes
NAME                 STATUS   ROLES    AGE    VERSION
kind-control-plane   Ready    master   100s   v1.19.1

You how have a running local Kubernetes cluster!

To cleanup the cluster, run:

kind delete cluster
Deleting cluster "kind" ...

Windows

Prerequisites:

Windows installation is simplified greatly by Chocolatey (the Windows package manager). If you haven’t already, see Chocolatey installation.

Once Chocolatey is installed, run the below to isntall Kind.

choco install kind

The first time you create a kind Kubernetes cluster, it will take a couple minutes to download the docker images.

Run:

kind create cluster
 Creating cluster "kind" ...
 βœ“ Ensuring node image (kindest/node:v1.19.1) πŸ–Ό 
 βœ“ Preparing nodes πŸ“¦  
 βœ“ Writing configuration πŸ“œ 
 βœ“ Starting control-plane πŸ•ΉοΈ 
 βœ“ Installing CNI πŸ”Œ 
 βœ“ Installing StorageClass πŸ’Ύ

Install the Kubernetes CLI by running the following:

choco install kubernetes-cli

If you have multiple Kubernetes configurations on your machine, run the below command to set your Kubernetes context to use the Kind config.

kubectl config set-context kind-kind
Context "kind-kind" modified.

Verify the cluster is running by listing the cluster nodes

kubectl get nodes
NAME                 STATUS   ROLES    AGE    VERSION
kind-control-plane   Ready    master   3m20s   v1.19.1

You how have a running local Kubernetes cluster!

To cleanup the cluster, run:

kind delete cluster
Deleting cluster "kind" ...