Kubernetes for Beginners

Kubernetes for Beginners

What is Kubernetes?

Kubernetes is basically a "container orchestrator". It was created by Google, called K8s but now this open source project is maintained by Cloud Native Computing Foundation(CNCF). Kubernetes make sure :-

  • That container is where it is supposed to be.
  • That the containers work together.
  • That the services are running like the developer wants.

Why Kubernetes?

  • It is used for automating software deployment, scaling, and management.
  • It was built to be to make sure developers application can be used anywhere i.e. developer can run his application across on-site deployments and public cloud.
  • It makes sure that your website or application is never down or in an unstable state, also called zero downtime. It has self healing property which ensures that if a application goes down, it is redeployed.
  • It has secure objects that store sensitive data, such as passwords, OAuth tokens etc. with encryption

Kubernetes Architecture

image.png

Cluster

A Kubernetes cluster is a collection of nodes that run containerized applications. These nodes are controlled/managed by a master node called Control Plane.

Control Plane

image.png The Control Plane makes global decisions about the clusters, it manages the overall health of the cluster. It has the following components-

  • API server
  • etcd
  • Controller Manager
  • Scheduler

API server

All communications in the Control Plane happen via the API server, basically it handles the CRUD operations for the server. To interact with the API we need kubectl (Kubecontrol). kubectl is a Command Line Tool(CLI) which helps user to talk with the API server.

etcd

It is a database that stores information about the cluster. It is a distributed key-value store i.e. it is built to run on multiple computers running together. Any component of Kubernetes can query etcd to understand the state of the cluster.

Controller Manager

Controller Manager manages the Controllers in Kubernetes. Controllers make sure that you get the desired state you want. It makes changes attempting to move the current state to the desired state.

Scheduler

As the name suggests Scheduler manages and schedules tasks to the worker nodes. It looks for the appropriate node that meet the criteria for the task and will schedule the task accordingly.

Worker Node

k8s-arch.png It is basically either a virtual or a physical machine where containers are deployed, it manages the Pods and the containers running on a machine. It has the following components:

  • Kubelet
  • Kube-proxy
  • Pods and Containers

Kubelet

Kubelet also known as primary node agent. It listens to API server and allocates the requests on the basis of that. It communicates with control plane whether or not pods can schedule tasks or not. It works in terms PodSpec, PodSpec is a YAML or JSON object that describes the pod.

Kube-proxy

Kube-proxy is a network proxy, it takes care of the communication between a cluster and outside network. It also makes sure that every worker node gets its unique IP address. It is the core networking component in Kubernetes.

Pods

A pod is a scheduling unit. These are the smallest deployable units of computing. Each pod consists of containers or you can say pod acts as a cover for the containers. To manage and interact with the container we need pods.

Containers

A container is a standard unit of software that packages up code and all its dependencies. For eg. you have made a website containing various libraries and code and you want to send it you your friend, but that code would not run on your friends device because he doesn't have some libraries installed, these are where containers come into picture. You can send all the files of the code in container to your friend so the code will run on his machine as well. In Virtual Machine you run code on different operating systems while using containers you can run code in one machine only using container engine.

References

Image Sources