Kubernetes Guides

Run your local Kubernetes clusters with Kind

If you’re looking for Kubernetes Cluster for your local development then kind is the best choice. Basically, kind was primarily designed for testing Kubernetes itself but may be used for local development or CI. In this post, we take look steps on how to configure, deploy sample application onto to kind cluster.

Image – kind tool logo

kind is more like Minikube which is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems.

Step #1: Install kind

Stable binaries for kind are available on the releases page. To install, download the respective binary for your platform and place into your $PATH. Here I’m using Linux so I have downloaded *amd64 binary release.

curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind

 

Image – Download kind binary

Once the binary is downloaded place kind binary into your $PATH.

Image – Place downloaded kind binary into your path
Image – kind version

kind does not require kubectl, but you will not be able to continue on the below sample deployment.

Step #2: kubectl installation

kubectl is the Kubernetes command-line tool that allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

Download the latest release of kubectl with the following command:

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

Make the kubectl binary executable chmod +x ./kubectl and Move the binary into your PATH sudo mv ./kubectl /usr/local/bin/kubectl

To check if the kubectl configuration is successful, run kubectl from the terminal.

Step #3: Create a new cluster

Now that we have the basic setup ready, we can set up a new cluster. kind create cluster command would create a new cluster. This command will bootstrap a Kubernetes cluster using a pre-built node image.

Image – Create new cluster

By default, the cluster will be named as kind. If you wish to name it differently, use the --name flag to assign a different context name.Use kubectl command to inspect the cluster that we have created.

Image – View cluster info

In order for kubectl to find and access a Kubernetes cluster, it needs a kubeconfig file, which is created automatically when you create a cluster but here if you have noticed,I have supplied --context to the command to look for the cluster.

You can also check the nodes in the cluster using kubectl get nodes command.

Image – View nodes of the cluster

Step #4 : Deploy Nginx app to one of the nodes of the cluster

Let’s run our first app on Kubernetes cluster with the kubectl applycommand. The applycommand creates a new deployment. We need to provide the deployment YAML configuration, I have provided one of the sample Nginx application.

Image – Deploy Nginx app

Congrats! We have just deployed the first application by creating a deployment. Following is what the command has done for us:

  1. Searched for a suitable node where an instance of the application could be run (currently we have only 1 available node)
  2. Scheduled the Nginx application to run on that node.
  3. Configured the cluster to reschedule the instance on a new Node when needed.

Here is the deployment configuration that we have deployed:

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

 

Image – View pods that are currently active

Once the application instances are created, a Kubernetes Deployment Controller continuously monitors those instances. If the Node hosting an instance goes down or is deleted, the Deployment controller replaces it.

To list your deployments, use the get deployments command:

Image – View list of deployments

Some of the useful kubectl commands are below.

  • kubectl getlist resources
  • kubectl describeshow detailed information about a resource
  • kubectl logsprint the logs from a container in a pod
  • kubectl execexecute a command on a container in a pod

Step #5 : Expose Nginx app outside of the cluster

To expose the app on to the outside world, use expose deployment command. Pods that are running inside Kubernetes are running on a private, isolated network. By default, they are visible from other pods and services within the same Kubernetes cluster, but not outside that network.

To see the Nginx landing page, you can do so by navigating to the http://localhost:80

Step #6 : Delete app and cluster

To delete the app, run delete deployment command:

kubectl delete deployment nginx-deployment

For deleting the cluster,use the following command:

kind delete cluster

 

Like this post? Don’t forget to share it!

Additional Resources :

Summary
Article Name
Run your local Kubernetes clusters with Kind
Description
In this post, we take look steps on how to configure, deploy sample application onto to kind cluster.
Author
Publisher Name
Upnxtblog
Publisher Logo
Karthik

Allo! My name is Karthik,experienced IT professional.Upnxtblog covers key technology trends that impacts technology industry.This includes Cloud computing,Blockchain,Machine learning & AI,Best mobile apps, Best tools/open source libs etc.,I hope you would love it and you can be sure that each post is fantastic and will be worth your time.

Share
Published by
Karthik

Recent Posts

Developing a Strong Disaster Recovery Plan for Your Business

Operating a business often entails balancing tight schedules, evolving market dynamics, and shifting consumer requirements.…

10 hours ago

How to Secure Your WordPress Hosting by Upgrading Your Login URL

Of course, every site has different needs. In the end, however, there is one aspect…

2 days ago

Social Media Marketing: A Key to Business Success with Easy Digital Life

In today's digital-first world, businesses must adopt effective strategies to stay competitive. Social media marketing…

4 days ago

Best 7 AI Tools Every UI/UX Designer Should Know About

62% of UX designers now use AI to enhance their workflows. Artificial intelligence (AI) rapidly…

6 days ago

How AI Enhances Photoshop Workflow: A Beginner’s Guide

The integration of artificial intelligence into graphic design through tools like Adobe Photoshop can save…

3 weeks ago

The Rise Of Crypto Trading Bots: A New Era In Digital Trading

The cryptocurrency trading world has grown significantly in recent years, with automation playing a key…

4 weeks ago

This website uses cookies.