Kubernetes: A Complete Guide - Chapter 1

This is the first article in the Kubernetes series. Lets directly deep dive into it to learn about the basics.

What is Kubernetes ?

Before learning about Kubernetes, let's find out what are Containers since both are dependent on each other.

Containers:-

source: freecodecamp.org

A container is a standard unit of software that contains code and all its dependencies so the application runs quickly and reliably in all environments.

Container images become containers at runtime and in the case of Docker containers – images become containers when they run on Docker Engine.

Note: Any changes in the code requires the container image to be re-built to be used for Deployments.

Now let's find out what is Kubernetes.

Kubernetes:-

Kubernetes (pronounced “koo-ber-net-ees”), an open-source software by Google, is used for deploying and managing  containers at scale. It is also the Greek word for helmsmen of a ship or pilot. Build, deliver and scale containerised apps faster with Kubernetes, sometimes referred to as “k8 s” or “k-eights.”

Why should we use Containers instead of  virtual machines ?

  • Each VM needs operating system, RAM, CPU, storage to run the operating system in order to enable you to deploy your application
  • Docker does not require all these resources for the operating system
  • Each docker container contains a very light weight OS, very small
  • Containers saves a lot of money by saving computing and storage resources
  • Containers are very light weight, very fast in startup and shutdown

Architecture of Kubernetes:-

source: kubernetes.io

First, let us know what is a Kubernetes Cluster ?

A Kubernetes cluster consists of at least one main (Control) plane, and one or more worker machines, called nodes on which multiple Pods run.

The following components make up the Kubernetes Architecture:-

  1. Control Plane: Also known as the "head/master node", it is the one that manages the worker nodes and the Pods in the cluster.
  2. Node: Also known as the "worker/compute node", it is a virtual machine which can be hosted on service providers like AWS, GCP, Azure and other cloud service providers. It can be a physical machine as well. A Kubernetes cluster requires at least one node to provision a Pod.
  3. Pods: A pod is a group of containers or a single container, and is the smallest unit that is managed by Kubernetes. Pods have a single IP address that is applied to every container within the pod. Containers in a pod share the same resources such as memory and storage of the Nodes. This allows the individual Containers inside a pod to be treated collectively as a single application, as if all the containerized processes were running together on the same host in more traditional workloads. Multiple containers can be part of a single Pod. We can say that Pods are a wrapper around a container.
  4. kubelet: A kubelet is an agent that runs on each Node in a cluster. Basically, kubelet is the one that ensures the containers are running in a Pod and they are healthy.
  5. kube-proxy: It is a network component that plays vital role in networking which ensures each Pod gets its own unique IP address. It also ensures that all containers within a single Pod share the same IP.
  6. scheduler: Also known as "kube-scheduler", it is responsible for assigning pods to worker nodes. If there are no suitable Nodes with enough resources i.e. CPU, Ram etc. then he pods are put in a pending state until such a healthy node appears. It watches API Server for new work tasks.
  7. etcd: Also known as "key-value store", it is a stateful, persistent storage that stores all the data of the Kubernetes Cluster such as cluster state and config. We can say that it is the source of truth for the Kubernetes Cluster.
  8. Controller Manager: Also knowns as "kube-controller-manager", it watches the state of the cluster through the watch feature of the API Server component. When it receives a notification, it makes the necessary changes and attempts to move the current state towards the desired state. Some examples of controllers are:- Replication Controller, Endpoints Controller, and Namespace Controller. The "kube-controller-manager" also performs lifecycle functions such as namespace creation and garbage collection, etc.
  9. API Server: To interact with a Kubernetes Cluster, we use the kubectl command line interface, which in fact communicates with the master API Server component. The API Server connects to etcd and all the other components must go through the API Server to work to manage the cluster state. The API Server is also responsible for the authentication and authorization mechanism. The API Server also implements a watch mechanism (similar to etcd) for clients to watch for changes. This helps components such as the "kube-scheduler" and "kube-controller-manager" to interact with the API Server in a loosely coupled manner.

Hopefully, the above article helps you to understand the basics of Kubernetes and it's architecture and how each and every component are tightly bound to each other.

In the next chapter, we'll understand how to Create Images and How do we deploy a service to the worker node. We'll cover topics such as Deployments, Service etc.

Abhishek Roy

Abhishek Roy

DevOps Engineer who aims to automate and simplify stuff related to infra and CI/CD.
Kolkata, India