nordvpn
Generic Category (English)728x90
Coursera Plus

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 Logo

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

Subscribe to Emails

More than 100,000 subscribers across the world trust & read Upnxtblog articles. Subscribe to emails updates!
* indicates required

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

Image – Place downloaded kind binary into your path

Image – kind version

Generic Category (English)728x90

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.

Recover over 700 unique file formats. Fully recover documents, emails, photos, videos, audio files and more. Supports 8 different data lost scenarios: deleted files recovery, recycle bin recovery, formatted drive recovery, lost partition recovery, externa

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

Best VPN Service (English Banners)

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.

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.

Packt US

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

New SSD Cloud Server Packages Now Available from $2.50/Month on Alibaba Cloud

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!

TextNow Download

Additional Resources :

Summary
Run your local Kubernetes clusters with Kind
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
%d bloggers like this: