Kubernetes Architecture and Components

Photo by Growtika on Unsplash

Kubernetes Architecture and Components

Why Kubernetes is so important?

Going back in time will give you an answer, so here it is.

For microservice architecture and container deployment era, Kubernetes is the best platform.

Kubernetes provides you with a framework to run distributed systems resiliently. It takes care of auto-scaling, healing, and failover for your application to ensure there is no downtime.

Kubernetes provides you with:

  • Service discovery and load balancing

  • Auto-scaling(Vertical and Horizontal)

  • Storage Orchestration

  • Automated rollouts and rollbacks

  • Self-healing and Fault Tolerance

  • Secrets and Configuration Management

  • Batch executions(one time, sequential, parallel)


Kubernetes Architecture:

Kubernetes Architecture diagram to show all the components of a k8s cluster and how external systems connect to the cluster.

It consists of 2 nodes:

  • Master Node (Control Plane): It is responsible for container orchestration and maintaining the desired state of the cluster.

    It consists of the following components:

    • Scheduler

    • API Server

    • etcd

    • Controller Manager

    • Cloud Controller Manager

  • Worker Node (Data Plane): It is responsible for running containerized applications.

    • kubelet

    • kubeproxy

    • Container Runtime


Kubernetes Control Plane Components:

  1. kube-apiserver:

    • It's a front end for the Kubernetes control plane that exposes the Kubernetes API.

    • It's designed to scale horizontally automatically so that you can run several instances of it and balance traffic between those nodes.

    • When you use kubectl to manage the cluster, you basically communicate with kube api-server via HTTP Rest API and internal components like scheduler, controller manager, etc, etc are communicating with gRPC(proto buffers).

    • It is responsible for API Management (Processing API requests), Authentication.

    • It's the only component that communicates with etcd.

    • It coordinates all the processes between the control plane and worker node components.

  2. etcd:

    • it is an open source strongly consistent, highly available, distributed key-value store.

    • it stores all the configurations, states, and metadata of Kubernetes objects(pods, secrets, daemonsets, deployments, configmaps etc). Stores all objects under /registry directory in key-value format.

    • It is highly secure and fast.

  3. kube-scheduler:

    • It is responsible for scheduling pods on worker nodes.

    • When user makes request for the creation and management of a pod then kube scheduler takes action.

    • The scheduler schedules the pods according to the node resource availability.

  4. kube-controller-manager:

    • controllers are control loops that watch the state of your cluster and always try to reach closer to the desired state from the current state of the cluster.

    • It also has various components like node controller, route controller, service controller, volume controller, and many more.

  5. Cloud-Controller-Manager (CCM):

    When Kubernetes is deployed in cloud environments, the cloud controller manager acts as a bridge between Cloud Platform APIs and the Kubernetes cluster.

    With this it allows Kubernetes to provision cloud resources like storage(for persistent volumes), load balancer(for services), and instances(for pods).


Kubernetes Node Components:

  1. kubelet:

    • An agent is a daemon that runs on each node in the cluster.

    • It makes sure that containers are running in a Pod.

    • Listen to Kubernetes master

    • Use port 10255

    • Send success/fail report to master

  2. kube-proxy:

    • It is a network proxy (daemon)that runs on each node of the cluster as a daemonset and maintains network rules on nodes- allowing network communication of pods inside/outside of your cluster.

    • It assigns an IP to each pod.

  3. Container-runtime:

    • It is the software that is required to run containers.

    • Kubernetes supports container runtimes such as containerd, CRI-O, and any other implementation of the Kubernetes CRI (Container Runtime Interface) eg Docker, Rocket, etc.

    • It works with kubelet.

    • It pulls the images, starts and stops containers, exposing containers on pods as specified in the manifest.


Pod

  • smallest deployable unit in Kubernetes.

  • A pod is a group of containers that are deployed together.

  • The best practice is to use a single pod for a single container.

  • Kubernetes does not know about containers, it knows about Pod.

  • It creates all containers in a pod - in an all-or-nothing manner.

  • A pod is created in a node.

Limitation:

  • by default auto-healing and auto-scaling are not there but can be added this feature by adding plugins such as High-Level Kubernetes Objects:

    • Replication set: scaling and healing

    • Deployment: versioning and rollback

    • Service: networking and static IP

    • Volumes: non-ephemeral storage

Basic flow diagram of how these components interact with each other for a pod creation request:

This is all about the Kubernetes architecture and its components.

Keep Learning :)