Kubernetes Architecture
Kubernetes is a container orchestration platform designed to manage containerized applications across a cluster of machines.
Master Node: Manages the entire cluster and orchestrates the operations of worker nodes.
1.API Server
Role: The API Server acts as the front-end for the Kubernetes control plane. It exposes the Kubernetes API, which is the primary entry point for all administrative tasks.
Operations:
Receives RESTful requests from users, operators, and internal components.
Validates and processes these requests, updating the cluster's state in etcd.
Serves as a communication hub for all other control plane components.
2.etcd
#Role: etcd is a distributed key-value store that holds the entire state of the Kubernetes cluster.
#Operations:
Stores configuration data, metadata, and the current state of all cluster resources.
Provides a consistent and reliable way to store and retrieve data, ensuring high availability and fault tolerance.
3.Scheduler
#Role: The Scheduler is responsible for assigning Pods to nodes based on resource requirements and constraints.
#Operations:
Monitors the API Server for newly created Pods that do not have an assigned node.
Evaluates the current state of the cluster, considering factors like resource availability, affinity/anti-affinity rules, and taints/tolerations.
Selects the most suitable node for each Pod and updates the Pod's specification in etcd.
4.Controller Manager
#Role: The Controller Manager runs various controllers that regulate the state of the cluster.
#Operations:
Each controller watches the state of the cluster through the API Server and makes or requests changes to achieve the desired state.
Examples of controllers include:
Node Controller: Manages node status and lifecycle.
Replication Controller: Ensures the desired number of Pod replicas are running.
Endpoint Controller: Manages endpoint objects for services.
Service Account & Token Controllers: Create default accounts and API access tokens.
5.Cloud Controller Manager
#Role: Integrates with cloud provider APIs to manage cloud-specific resources.
#Operations:
Manages cloud resources like load balancers, storage volumes, and networking routes.
Ensures that cloud resources are provisioned and maintained according to the cluster's needs.
Worker Nodes:Run the containerized applications.
1.Kubelet
#Role: The Kubelet is an agent that runs on each worker node, ensuring that containers are running in a Pod.
#Operations:
Registers the node with the cluster and reports its status to the API Server.
Watches for PodSpecs assigned to its node and ensures that the containers described in those Pods are running and healthy.
Watches for PodSpecs assigned to its node and ensures that the containers described in those Pods are running and healthy.
2.Kube-proxy
#Role: Kube-proxy is a network proxy that runs on each node, managing network rules and facilitating communication between Pods and services.
#Operations:
Implements service abstraction by maintaining network rules on nodes.
Forwards traffic to the appropriate Pods based on service definitions.
Supports various modes of operation, such as userspace, iptables, and IPVS, to handle network traffic efficiently.
3.Container Runtime
#Role: The container runtime is responsible for running containers on a node.
#Operations:
Pulls container images from registries.
Starts and stops containers as instructed by the Kubelet.
Manages container networking and storage.
k8s vs Docker Architecture:
Purpose: Docker is focused on containerization, while Kubernetes is focused on orchestrating and managing containers at scale.
Scope: Docker operates on a single node, whereas Kubernetes manages a cluster of nodes.
Components: Docker's architecture is simpler, with a focus on the Docker Engine and CLI. Kubernetes has a more complex architecture with multiple components for cluster management.
Functionality: Kubernetes provides advanced features like autoscaling, self-healing, and load balancing, which are not part of Docker's core functionality.