Back to Top

An Introduction to Kubernetes

introduction-to-kubernetes

After writing about Docker, I am going to share about the Kubernetes(k8s). Kubernetes is built on Docker technology. This article mainly explains the Kubernetes architecture, key concepts and how to use Kubernetes.

What is Kubernetes?

Kubernete is open source container management system where you can deploy application containers across clusters of hosts.It provides container centric infrastructure.An important feature of kubernete is can actively manage the container and ensure the continued status of the cluster. It also allows maximizing the use of hardware resources.

Kubernete is mainly for the system admin to deploy the code.Kubernetes has fifteen years of experience in running large-scale container cluster and the important part is also supported Docker containers.

Let’s understand the features of Kubernetes:

  1. You can quickly deploy the application.
  2. You can scale the application.
  3. Rolling updates

Kubernetes is a physical and virtual machine. Many Big companies like Google, Red hat, Intel, Puppet, CoreOS etc are using the Kubernete.

Basic Components of Kubernetes

Let’s begin with the basic components of the Kubernete.

Kubectl is a command to controls the Kubernetes cluster manager. Kubectl provides many options which you learn from here (http://kubernetes.io/docs/user-guide/kubectl/kubectl/ )

Key Concepts of Kubernetes:

  1. Pods
  2. Labels
  3. Services
  4. Replication
  5. Controllers
  6. Deployments
  7. Volumes
  8. Persistent Volumes
  9. Etc

Pods

Kubernetes is the most basic deployment scheduling unit where you can create Pods.The pod is a set the container with a shared disk.The pod can be created individually.

Docker file is supposed to create docker image but here You will use the existing docker images to deploy the things.Pod is a group of containers.The pod is used to solve the problem of expansion and volume reduction.

Some more important things about Pods

  • Smallest deployable units that can be created and managed in k8s
  • Share resources like volumes, IP address
  • Group of containers scheduled on the same host
  • Can also communicate using standard IPC
  • Containers within a pod can find each other via localhost
  • Containers in different pods have distinct IP addresses and can not communicate by IPC.

The following example will create a Pod

vim nginx-pod.yaml

In this,Name is the name of the container and image Is the name of the image that will be used Docker mirror.containerPort is the port of the container to communicate with the IP address Pod Nginx server.Metadata is the data.

Once the pod is created, you can list them to see what is up and running using the following command:

Labels

Kubernetes has the features of rolling updates that make the deployment process for administrator very simple. Labels are the very important part for that. There are commands for specifically do deployments and rolling updates where you can distinguish using appropriate labels.

Labels is an inbuilt feature in kubernetes. They have key value pairs where you can attach to the objects.It is not limited to Pods, you can attach replication controllers,servers etc almost anything.

Labels are used to make sure the management of an object is simple.If you are using VMware, you might have come across the concept of tags so this is just the different name for those tags.

  • Key/Value pairs that are attached to objects, such as pods
  • This is used to organize and select subsets of objects
  • Example of labels are very simple:
    • “release” : “stable”, “release” : “canary”
    • “environment” : “dev”, “environment” : “qa”, “environment” : “production”

Here is the example of labels in kubernete

Replication Controllers (rc)

Support your all pods are working on the single system so imagine that system is going down so run environment screwed. In that case, you need to have replication and that is what replication controller come into the picture.

Replication Controllers is made sure that specific replicas exist.If you need more replicas and only one pod are running currently,so it will spin up some new pods for you.The reverse is also true if you have modified YAML file and if you change it again to one, it will kill all other or unused pods.

When you create Replication Controllers using YAML, you will get the selector field. Selector will decide which pods going to replicate.

Let’s have an example, There are 5 replicas exists, and you get more traffic and you want to increase the replicas, you can just increase on the fly without any downtime.

replication-controller

Here is the main points of Replication Controllers

  • Ensures a specified number of pod “replicas” are running
  • Manages all the pods with labels which match the “selector”
  • If there are more pods, it will kill some
  • If there are less pods, it will start more
  • Increase/Decrease number of replicas on the fly

Now, let’s create the Replication Controller

Services

Services have an own purpose,Pod IP addresses cannot be relied upon because pods can come up and go down anytime.

What if pods (backend) provide some service to other pods (frontend) and backend pods suddenly die? So Kubernete will make sure new pods created immediately but what about IP address so application might be stopped and that is the scenario where services come into the picture.

Services look up at the IP address so when you call the specific IP address, it will send the request to any available backend pods. For example, You have 5 replicas so it will send the request to any of replica from five replicas

Again you are going to use the selector freed YAML file so that kind of the same concept we saw in the Replication Controller.Services define logical set of Pods and Set of Pods targeted by a Service is determined by “selector”

Service has one logical IP address means it has the single point of an area so that’s why skyDNS comes into the picture.skyDNS gives the DNS functionality so instead of IP address you have DNS name.If one your services are skying and it have different pods or nods,there might be the case that it’s IP address changed but DNS name is same.You can just rely on it.

Here to try to establish a service Kubernete.

Nginxsvc.yaml create a file and write to:

Deployments

Deployments are useful to create Pods and Replica Sets in one node.Replica Sets is the next gen Replication Controller. Deployments provide declarative updates for Pods and Replica Sets (next gen RC).It is used to bring up Pods and Replica Sets and also for Canary deployments

Volumes

Volumes are just another directory accessible to the Pod.The moment when Pods getting killed, the have volume is killed too.Volumes get mounted at specific path within image or container.

Some other useful points of volumes.

  • Ceases to exist when Pod ceases to exist
  • Support for many volume types; Pod can use any number of them simultaneously
  • Mounted at the specified paths within the image

Volume Types

Volume Types supported are listed below:

  1. emptyDir
  2. hostPath
  3. gcePersistentDisk
  4. awsElasticBackStore
  5. nfs
  6. iscsi
  7. glusterfs
  8. rbd (Ceph) – Object Storage.

Persistent Volume

Persistent Volume has life cycle going to extend on the Pods. If in case, Your Pod is dead, the Persistent Volume still exists. Persistent Volume created by the administrator.Persistent Volume is a piece of networked storage in the cluster provisioned by an administrator.It is lifecycle independent of any individual pod that uses the PV.

Here is the types Persistent Volume:

  1. GCEPersistentDisk
  2. RBD (Ceph)
  3. Glusterfs
  4. NFS
  5. iSCSI

What are the advantages of Kubernetes?

  1. First advantage is Kubernete is lightweight and very simple to understand so can anybody use it.
  2. Kubernete provides public,private and hybrid cloud deployment so it is portable.
  3. Using kubernete, you can have automatically deployment,restart and copy which reduces maintenance work.
  4. Kubernete is pluggable and modular technology so you can attach it anywhere.

I hope you will have a better understanding of the Kubernetes.Enjoyed reading this article? Do share this article with your friends on Facebook & Twitter.Feel free to share your thoughts and comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to Fetch Twitter data using cURL

Posted on 5 years ago

Bhumi

How To Sort by custom fields in WordPress

Posted on 6 years ago

Zinal

Tips to Choose Your Next WordPress Theme

Posted on 5 years ago

Bhumi

How to manage Session in WordPress

Posted on 6 years ago

Bhumi