Before you go, check out these stories!

0
Hackernoon logoHow To Manage Local Kubernetes Testing with KIND Tool by@sudip-sengupta

How To Manage Local Kubernetes Testing with KIND Tool

Author profile picture

@sudip-senguptaSudip Sengupta

Solution Architect | Technical Content Writer

If you've spent days (or even weeks?) trying to spin up a Kubernetes cluster for learning purposes or to test your application, then your worries are over. Spawned from a Kubernetes Special Interest Group, KIND is a tool that provisions a Kubernetes cluster running IN Docker.

From the docs:

kindĀ is a tool for running local Kubernetes clusters using Docker container "nodes". kindĀ is primarily designed for testing Kubernetes 1.11+, initially targeting theĀ conformance tests.

Installing KIND

As it is built usingĀ go, you will need to make sure you have the latest version ofĀ 

golang
Ā installed on your machine.

According to the k8sĀ docs,Ā 

golang -v 1.11.5
Ā is preferred. To install kind, run these commands (it takes a while):

go get -u sigs.k8s.io/kind
kind create cluster

Then confirmĀ kindĀ cluster is available:

kind get clusters

Setting up kubectl

Also, install the latestĀ 

kubernetes-cli
Ā usingĀ HomebrewĀ orĀ Chocolatey.
The latest Docker has Kubernetes feature but it may come with olderĀ 
kubectl
Ā . Check its version by running this command:

kubectl version

Make sure it showsĀ 

GitVersion: "v1.14.1"
Ā or above.
If you find you are runningĀ 
kubectl
from Docker, tryĀ 
brew link
Ā or reorder path environment variable.

OnceĀ 

kubectl
Ā and kind are ready, open bash console and run these commands:

export KUBECONFIG=ā€$(kind get kubeconfig-path)ā€
kubectl cluster-info

IfĀ 

kind
Ā is properly set up, some information will be shown.
Now you are ready to proceed. Yay!

Deploying first application

What should we deploy on the cluster? We are going to attempt deploying Cassandra since the docs have a pretty decent walk-through on it.

First of all, downloadĀ 

cassandra-service.yaml
Ā andĀ 
cassandra-statefulset.yaml
Ā for later. Then createĀ kustomization.yamlĀ by running twoĀ catĀ commands.

Once thoseĀ 

yaml
Ā files are prepared, layout them as following:

k8s-wp/
  kustomization.yaml
  mysql-deployment.yaml
  wordpress-deployment.yaml

Then apply them to your cluster:

cd k8s-wp
kubectl apply -k ./

Validating (optional)

Get the Cassandra Service.

kubectl get svc cassandra

The response is:

NAME        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
cassandra   ClusterIP   None         <none>        9042/TCP   45s

Note that Service creation might have failed if anything else is returned. ReadĀ Debug ServicesĀ for common issues.

Finishing up

That's really all you need to know to get started with KIND, I hope this makes your life a little easier and lets you play with Kubernetes a little bit more :)

About the author - Sudip is a Solution Architect with more than 15 years of working experience, and is the founder ofĀ Javelynn. He likes sharing his knowledge by regularly writing forĀ Hackernoon,Ā DZone,Ā AppfleetĀ and many more. And while he is not doing that, he must be fishing or playing chess.

Previously posted atĀ https://appfleet.com/.

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.