Day 30 Task: Kubernetes Architecture
Kubernetes Overview
With the widespread adoption of containers among organizations, Kubernetes, the container-centric management software, has become a standard to deploy and operate containerized applications and is one of the most important parts of DevOps.
Originally developed at Google and released as open-source in 2014. Kubernetes builds on 15 years of running Google's containerized workloads and the valuable contributions from the open-source community. Inspired by Google’s internal cluster management system, Borg,
Tasks
- What is Kubernetes? Write in your own words and why do we call it k8s?
Kubernetes is an open-source container orchestration platform that is frequently referred to as K8s. It automates the deployment, scaling, and management of containerized application. Applications and their dependencies can be stored and run in containers, which makes it simpler to maintain consistency across many settings.
The eight letters between "K" and "s" in "Kubernetes" are used in the abbreviation "K8s."
What are the benefits of using K8s?
- For the management of containerized applications, Kubernetes has various benefits:
1.Container Orchestration: Kubernetes reduces personal involvement and human error by automating container deployment, scaling, and administration.
2.Scalability: It makes it simple for applications to scale by adding or deleting containers in accordance with workload demands.
3.Declarative Configuration: In configuration files, you specify the desired state of your apps, and Kubernetes makes sure the system complies.
4.Resource Efficiency: By effectively arranging containers onto nodes, it maximizes resource utilization.
5.Portability and Multi-Cloud Support: Kubernetes offers portability across different cloud providers and on-premises environments. It provides consistency in deployment and management practices, allowing applications to be easily moved between different cloud platforms or data centers.
Explain the architecture of Kubernetes
Kubernetes has a master node-worker node architecture:
Master Node: The control plane components are hosted on the master node. These components include:
API Server: Acts as the front-end for the Kubernetes control plane and is responsible for processing API requests.
Scheduler: Assigns work to worker nodes, deciding where to run containers based on resource requirements and policies.
Controller Manager: Ensures the desired state of the cluster and handles tasks like replication, scaling, and node management.
etcd: A distributed key-value store that stores the cluster's configuration data.
Worker Node: The worker nodes are responsible for running containers. They have the following key components:
Kubelet: Communicates with the API server and ensures containers are running in a Pod.
Container Runtime: The software responsible for running containers (e.g., Docker, containerd).
Kube Proxy: Maintains network rules on nodes and enables communication between Pods.
What is Control Plane?
- The Control Plane in Kubernetes refers to a crucial component responsible for managing the cluster and its state. It's the brains behind the entire Kubernetes system, overseeing and coordinating all activities within the cluster.
Components of the Control Plane:
API Server: Acts as the front end for the Kubernetes Control Plane. It validates and processes REST requests, serving as the gateway for cluster management.
Scheduler: Assigns workloads (pods) to nodes based on resource availability, policies, and constraints. It ensures efficient utilization of cluster resources by determining the best node for a pod to run.
Controller Manager: Manages various controllers that regulate the cluster's state, continuously monitoring and responding to changes. For example, it manages node status, replication controllers, endpoints, and more.
etcd: This distributed key-value store is a critical component that stores all cluster data, including configuration details, state information, and metadata. It serves as the cluster's source of truth.
Write the difference between kubectl and kubelets.
kubectl: The command-line tool Kubectl is used by developers and administrators to communicate with the Kubernetes cluster. From the command line, users can create, change, delete, and analyze different Kubernetes resources (such as pods, services, and deployments). To carry out these actions, Kubectl talks with the Kubernetes API server.
kubelet: Every worker node in the cluster has a component called Kubelet running on it. Its main duty is to make sure that each container in a Pod is running and safe. To manage the containers, it uses the Pod specifications provided by the API server and communicates with the container runtime (such as Docker). Additionally, Kubelet updates the control plane on the state of nodes and containers.
Explain the role of the API server.
The API server serves as Kubernetes' primary interface, handling all RESTful requests, and validating and processing cluster-related operations. It acts as the control hub, enabling users, controllers, and external systems to interact, manage, and maintain the cluster's state, configurations, and resources efficiently.
What is container
A container, is where applications run. Many applications will be running, and communicating with each other. For example, you have one container running the front end, another running the back end, and another running the database. Kubernetes manages these containers. You can do container management through Docker Swarm or Docker Compose, but what's different in Kubernetes is its focus on keeping things production-ready with minimal failures and downtime, having good backup and restore, and most importantly, supporting microservices.
What is monolithic and microservices?
Monolithic means a large application where everything runs together.
Microservices mean small applications integrated into a system.
This is where Kubernetes comes in to manage these small applications for container orchestration
The most common question asked in interviews is to explain Kubernetes' architecture
Kubernetes architecture
The Kubernetes emblem looks like the steering wheel of a ship. What does the word "ship" mean now? "Ship" is similar to the container that holds our Docker containers, which house different applications. In essence, Kubernetes acts as an application manager by giving you the resources you need to properly track and manage your apps.
In Kubernetes, two crucial components are the master and worker nodes, which form the master-worker architecture. Picture this: the master node operates as a server solely handling configuration files, secret files, management tasks, etcd, and scheduling. On the other hand, the worker node, which is another server, exclusively runs the actual applications.
Here, it's important to grasp two key components: the API server and kubelet. The master server houses the API server, responsible for handling worker nodes and management tasks. The API server is pivotal; it's an application programming interface that oversees worker nodes' operations. To interact with the API server, we use a tool named kubectl.
On the worker nodes, we require another essential tool called kubelet. This agent is stored within the worker node and focuses on monitoring the health of applications, detecting errors, and managing various functionalities essential for efficient operations.
What is different between Node and pod
Node is a Server or virtual Machine.
Pod is the smallest unit in Kubernetes used to manage group of one or more containers.