Kubernetes Architecture

Kubernetes Architecture

Kubernetes Architecture Type:

One MasterOne Node
One MasterMultiple Nodes
Multiple MasterMultiple Nodes

Kubernetes has rapidly become the de facto standard for container orchestration, and for good reason. Its robust architecture ensures scalability, fault tolerance, and efficient container orchestration. But what makes Kubernetes so powerful? Let's dive into its core architecture.

Main Components:

Kubernetes' architecture can be split into two main parts: the Control Plane (Master Node) and the Worker Nodes.

Working with Kubernetes:

  1. We create a manifest saved in .yml extension.

  2. Apply this to the cluster (set of nodes) through the master to bring it into the desired state.

  3. Pod runs on node, which is managed by the master.

Roles of Master Node

Kubernetes Cluster Contains: Container running or Bare metal or VM instances or Cloud Instances or all mix

Kubernetes is designed to have one or multiple master <--> node

Master rune set of processes, these processes ensure smooth functioning of cluster. These processes are called as Control Plane.

The control plane is run by master.

Components of Control Plane (Master Node)

API- Server - For all communication

Api server interacts directy with user- kubectl i.e. we apply .yml manifest to API server. API server handles request load as per traffic. API- Server is Frontend of Control plane.

etcd - Database

Stores metadata and status of cluster (set of nodes). Format: Key-Value. It is consistent and highly available.

Features: Fully Replicated: Entire state is available on every node of the cluster. Secure: Implement automatic TLS with optional Client Certificate automation. Fast: 10,000writes/second.

Scheduler - Action : Pod Creator

When user make requests for the creation and management of pods, the kube-scheduler takes action on these requests. When pod is been created, it finds the best suitable node and puts it there.

Controller manager - Actual State=Desired State

Two possible choices for the controller manger.

  1. If K8s is on the cloud, then it is referred to as Cloud-Controller Manager

  2. If K8s is on On-prem, then it is referred to as Kube-Controller Manager

Components on the master that runs the controller:

Node Controller: If the node has stopped responding - Detect it.

Route Controller: Setting up network and routes

Service Controller: Load Balancing

Volume Controller: Creating, attaching and monitoring volume and interacting with cloud provider to orchestrate volume.

Components of Node/Worker/Minion

kubelet

It is an agent running on the node. It listens to K8s Master, say for pod creation port 10255. It sends success-failure reports to the master.

Service-Proxy

Assign IP Address to pod dynamically; after start-stop nodes IP gets changes.

Container Engine - Docker

Works with Kubelet for pooling images and start-stop containers. Exposing containers on pods is specified manifest.

Some Information about POD

Kubernetes Networking Guide for Beginners - Kubernetes Book

Pod is the smallest unit in Kubernetes.

Pod is a group of one or more containers (tightly coupled), that are deployed together in the same host.

A cluster is a group of nodes, with at least one or more nodes and a master. You can interact with the container through the pod only.

Kubernetes only knows about the Pods NOT containers.

You can not start a container without Pod.

One Pod usually contains at least one container.

Multi Container Pod

Share access to memory and volume. It will share allocated memory and volume between containers.

Connect to each other locally with port as localhost:<ContainerPort>

Containers within pos are deployed in all-or-nothing manner.

Pos CAN NOT get shared between nodes.

/Kubernetes is designed to accommodate configurations that meet all of the following criteria: No more than 110 pods/node. No more than 5,000 nodes. No more than 150,000 total pods.

Autoscaling is one of the key features in the Kubernetes cluster. It is a feature in which the cluster is capable of increasing the number of nodes as the demand for service response increases and decreasing the number of nodes as the requirement decreases. Note that, Autoscaling and Autoheal are only done with Nodes not with Pods (containers). If pod crashes

Service

This is like a phone directory for Pods. Since Pods can come and go, a Service provides a stable "address" so that other parts of your application can find them.

Volume

This is like an external hard-drive that can be attached to a Pod to store data.

Namespace

A way to divide cluster resources among multiple users or teams. Think of it as having different folders on a shared computer, where each team can only see their own folder.

Ingress

Think of this as the "front door" for external access to your applications, controlling how HTTP and HTTPS traffic should be routed to your services.

The Difference Betweenkubectl and kubelet

When diving into the world of Kubernetes, two terms you will frequently encounter are kubectl and kubelet. At first glance, they might seem similar, given their shared prefix, but they serve very distinct roles within the Kubernetes ecosystem.

kubectl

  1. Command-Line Interface (CLI): kubectl is the CLI tool for interacting with the Kubernetes cluster.

  2. User Interaction: It is the primary method by which administrators and users communicate with the cluster, allowing them to deploy applications, inspect and manage cluster resources, and view logs.

  3. Scope: kubectl commands affect the entire cluster or specific cluster resources depending on the command and arguments provided.

kubelet

  1. Agent on Nodes: The kubelet is an agent that runs on each node in the Kubernetes cluster. Its primary role is to ensure that containers are running in a Pod.

  2. Node-Level Responsibility: It is responsible for watching for tasks sent from the API server and ensuring that the described containers are healthy and running as intended.

  3. Node Health: kubelet also reports the status of the node back to the central control plane, enabling the master node to maintain an understanding of the cluster's overall heal

    In simple terms, think of kubectl as the tool you use to give commands to the Kubernetes cluster, while kubelet is the agent that ensures those commands are executed on individual nodes.th.

ย