Day 30-Navigating the Kubernetes Cosmos: Unveiling the Architecture (Dec 26, 2023)
In the dynamic landscape of DevOps, Kubernetes has emerged as a cornerstone for deploying and managing containerized applications. Originally born out of Google's internal cluster management system, Borg, Kubernetes has become the go-to solution for orchestrating containers in production environments. As we embark on Day 30 of the #90DaysOfDevOps Challenge, let's dive into the Kubernetes architecture and explore its key components.
What is Kubernetes? Why do we call it k8s?
Kubernetes, often abbreviated as k8s, is an open-source container orchestration platform designed to automate the deployment, scaling, and management of containerized applications. The name "Kubernetes" originates from Greek, meaning "helmsman" or "pilot," emphasizing its role in steering and managing container workloads efficiently.
Benefits of Using Kubernetes:
Orchestration: Kubernetes automates the deployment and scaling of containerized applications, streamlining complex workflows.
Portability: Applications run consistently across various environments, promoting flexibility and avoiding vendor lock-in.
Scalability: Kubernetes scales applications horizontally, adapting to changing workloads by adding or removing containers.
Self-healing: Automatic detection and recovery from container failures, ensuring high availability.
Resource Efficiency: Efficient resource utilization with the ability to pack multiple containers on the same host.
Architecture of Kubernetes:
To comprehend the inner workings of Kubernetes, let's delve into its architecture:
The Control Plane is the brain of Kubernetes, responsible for making global decisions about the cluster. It consists of several components:
API Server: Acts as the front-end for the Kubernetes control plane. It validates and processes requests, enforcing policies, and then updates the corresponding objects.
Controller Manager: Watches the shared state of the cluster through the API server and makes changes as necessary to move the current state towards the desired state.
Scheduler: Assigns nodes to newly created pods based on resource requirements and other constraints.
etcd: A consistent and highly-available key-value store used to store the configuration data of the cluster, representing the single source of truth.
Nodes are the worker machines in a Kubernetes cluster. They host the containers and run the required services. Each node consists of:
Kubelet: Ensures that containers are running in a Pod.
Kube-proxy: Maintains network rules on nodes, allowing communication between Pods.
Container runtime: The software responsible for running containers.
Control Plane Components in Detail:
- API Server: The API server serves as the front-end to the control plane, receiving commands from the command-line tool
kubectland other Kubernetes components. It exposes the Kubernetes API, which is used by both internal components and external tools.
Difference between kubectl and kubelet:
kubectl: The command-line tool used to interact with the Kubernetes API. It allows users to deploy and manage applications, inspect and manage cluster resources, and view logs.
kubelet: An agent running on each node in the cluster, responsible for ensuring that containers are running in a Pod. It communicates with the control plane, manages the node's containers, and reports node and container status.
Role of the API Server:
The API server acts as the gateway to the Kubernetes cluster. It validates and processes requests, and the entire system communicates through the API server. This component is pivotal in maintaining the desired state of the cluster.