Saturday, September 23, 2017

What is Kubernetes and how to use it

Hello everyone,

  Today I would like to talk more about one tool that I am working since 2016 and it's now on top of our projects. So, here it comes Kubernetes.



Benefits of Kubernetes

Kubernetes is designed in a way that provides availability, scalability, security, and portability. Reliability is another main benefit of Kubernetes and can be used to prevent failure from impacting the availability or performance of the application. Moreover, Kubernetes enables the users to respond efficiently to customers demand by scaling or rolling out new innovative features. It is systematized in such a way that it offers freedom of choice when choosing operating systems, container runtimes, processor architectures, cloud platforms and PaaS. It also improves the cost of infrastructure by efficiently dividing the workload across available resources. This shows that while other technologies are doing a commendable job at handling the cluster aspect, Kubernetes is providing a better management system.

Pre-requisites

For beginners, before you delve into the what, why and how of Kubernetes, you need to have prior knowledge of what containers are and how do they work? What are Dockers and managed VMs and how do they work? Since the basic aim of this article is to explain Kubernetes in detail, the main terminologies will be briefly explained before we jump onto the Kubernetes and its components. If you’re interested to learn more about Dockers, Virtual Machines, containers then you can check out terrific articles here, here, and here. Now for the shorter basic versions:

What are containers?

A container is a standardized unit of software. It is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows-based apps, the containerized software will always run the same, regardless of the environment.
Source of definition taken from docker.com

What is Dockers?

Docker container is an open source software development platform. Its main benefit is to package applications in “containers,” allowing them to be portable to any system running the Linux operating system (OS).
Now back to what is Kubernetes. Since you now know of some of the basic terminologies, let’s go back to the definition of the Kubernetes. It is basically a cluster management tool for Docker container. Kubernetes aids in scheduling and deploying a large number of containers replicas onto a node cluster. Since it’s an open source model, Kubernetes can run almost anywhere, and all the major players in public cloud providers offer easy ways to utilize this technology. Private clouds based on OpenStack or Mesos can also run on Kubernetes, and bare metal servers can be leveraged as worker nodes for it.

The Kubernetes Architecture
Screen Shot 2017-11-01 at 1.46.33 PM.png

and

Kubernetes architecture diagram

Image: Kubernetes architecture diagram (Image Source: Wikipedia)


As with most distributed computing platforms, a Kubernetes cluster consists of at least one master and multiple compute nodes.

Master component

The master node is the one that is responsible for the management of Kubernetes cluster. This is the main entry point of all administrative tasks. The master node, also known as the control plane, is the one that is managing the worker nodes, where the actual services are running.

A master node is made of following components:


  • etcd storage


The etcd is a simple, lightweight, distributed key-value store that can be distributed across multiple nodes. The etcd storage was developed by the CoreOS team to be mainly used for shared configuration and service discovery.  Kubernetes uses etcd to store configuration data that can be used by each of the nodes in the cluster


  • API Server


API Server is the main management point of the entire cluster, as it allows a user to configure many of Kubernetes’ workloads and organizational units. The API server is also the entry points for all the REST commands used to control the cluster. That means several different tools and libraries can easily communicate with it.




  • Controller-manager


The controller manager service is a general service that is responsible for controllers that regulate the state of the cluster and perform routine tasks. The example of such a controller is the replication controller. As it ensures that the number of replicas defined for a service matches the number currently deployed on the cluster. The details of these operations are written to etcd, where the controller manager watches for changes to the API server.


  • Scheduler


The scheduler component configures pods and services onto the nodes. Moreover, the scheduler is also responsible for tracking resource utilization on each host to make sure that workloads are not scheduled in excess of the available resources.

Nodes

Nodes are the servers that perform work in Kubernetes. It was previously known as minion. A node can be a virtual machine or a physical machine, depending on the cluster. Every single node has the services necessary to run pods and is managed by the master components. The services on a node include:


  • kubelet


kubelet gets the configuration of a pod from the API server and ensures that the described containers are up and running. This is the worker service that’s responsible for communicating with the master node. It is responsible for relaying information to and from the control plane services, as well as interacting with the etcd store to read configuration details or write new values.


  • Docker


Docker is responsible for downloading the images and starting the containers. It runs on the encapsulated application containers in a lightweight operating environment. Each unit of work is implemented as series containers that must be deployed.


  • kube-proxy


Kube-proxy runs on each node to deal with individual host sub-netting and ensure that the services are available to external parties. It serves as a network proxy and a load balancer for a service on a single worker node and manages the network routing for TCP and UDP packets.

Kubernetes terminologies

Must know terminologies of Kubernetes are:


  • Pods– Pods are a collection of one or more containers. It acts as a Kubernetes’ core unit of management. Pods set the logical boundary for containers sharing the same context and resources.

Screen Shot 2017-11-01 at 1.44.20 PM.png

  • Labels– Labels are arbitrary tags that can be placed on the above work units to mark them as a part of a group. These can then be selected for management purposes and action targeting.



  • Services– Services is a unit that acts as a basic load balancer and ambassador for other containers. Service groups together logical collections of pods that perform the same function to give an impression of the single entity.



  • Replication Controller– A more complex version of pod is known as a replicated pod. These are handled a type of work unit known as a replication controller. Replication controllers make sure that a specific number of pod replicas are running at any one time.


In November-2017, Please be ready for new chronicle K8S - Managing Snapshots through kubectl


I hope you liked this article and happy coding,
Thiago Leoncio


No comments:

Post a Comment