What is Kubernetes?
Kubernetes, also known as K8s is an open-source container management tool that automates container deployment, scaling & load balancing. It schedules, runs, and manages isolated containers that are running on virtual/physical/cloud machines. All top cloud providers support Kubernetes.
What are the benefits of using k8s?
Scalability: Kubernetes provides built-in scalability features that allow applications to scale horizontally by adding or removing instances based on demand. It automatically manages the distribution of containers across a cluster of nodes, ensuring optimal utilization of resources.
High Availability: Kubernetes supports self-healing capabilities, ensuring that applications are highly available. If a container or node fails, Kubernetes automatically restarts or reschedules containers on healthy nodes, minimizing downtime and maintaining service availability.
Load Balancing and Service Discovery: Kubernetes offers built-in load balancing mechanisms to distribute network traffic across multiple containers or pods. It also provides service discovery, allowing containers to easily find and communicate with other containers or services within the cluster.
Automatic Bin Packing: Kubernetes optimizes resource utilization through automatic bin packing. It intelligently schedules containers onto nodes, considering resource requirements and constraints, to ensure efficient utilization of computing resources.
Rolling Updates and Rollbacks: Kubernetes simplifies the process of rolling out application updates. It supports rolling updates, allowing new versions of containers to be deployed gradually, minimizing disruptions. Additionally, Kubernetes enables easy rollbacks to previous versions in case issues are detected after an update.
Configurable and Portable: Kubernetes uses declarative configuration files to define and manage applications. This allows for easy configuration management, version control, and the ability to reproduce environments across different clusters or environments. It also promotes infrastructure portability, enabling applications to be deployed consistently across various cloud providers or on-premises environments.
Extensibility: Kubernetes provides a rich ecosystem of extensions and plugins, allowing you to enhance and customize your deployment with additional features or integrations. These extensions include networking, storage, monitoring, logging, and security solutions, among others.
Community and Ecosystem: Kubernetes benefits from a vibrant and active open-source community, with extensive documentation, tutorials, and resources available. The ecosystem around Kubernetes continues to grow, providing a wide range of tools, frameworks, and services that integrate seamlessly with Kubernetes.
Cost Efficiency: By optimizing resource utilization, automating management tasks, and enabling horizontal scaling, Kubernetes can help reduce infrastructure costs and increase operational efficiency.
Architecture of Kubernetes.
The Kubernetes architecture is based on a master-slave model, where the master node manages the entire cluster while the worker nodes host the containers.
Kubernetes control plane:- manages Kubernetes clusters and the workloads running on them. Include components like the API Server, Scheduler, and Controller Manager.
Kubernetes data plane:- machines that can run containerized workloads. Each node is managed by the kubelet, an agent that receives commands from the control plane.
Pods:- pods are the smallest unit provided by Kubernetes to manage containerized workloads. A pod typically includes several containers, which together form a functional unit or microservice.
Control plane components API Server
API SERVER : Entry point for REST/kubectl. It is the front end for the Kubernetes control plane.
It tracks the state of all cluster components and manages the interaction between them. It is designed to scale horizontally. It consumes YAML/JSON manifest files. It validates and processes the requests made via API.
Scheduler:
To worker nodes, it schedules pods. It keeps an eye on the API server for newly formed Pods that don't yet have an assigned node and chooses a healthy node for them to run on. If there are no healthy nodes available, the pods are placed in a pending condition until one does. It monitors API Server for fresh work assignments
Controller Manager:
Through the API server, it monitors both the desired state and the actual state of the objects it controls.
To ensure that the existing condition and the desired state are the same, corrective measures must be taken.
The controller of controllers, it is.
It performs controller operations. Although technically each controller should operate as a separate process, they are all compiled into a single binary and run in a single process to decrease complexity.
ETCD:
It is a distributed, highly available, consistent key-value store. All of the Kubernetes cluster data (cluster status and configuration) is kept on stateful, persistent storage. For the cluster, it serves as the source of truth. It may be externally configured or a component of the control plane.
Worker node components:
A worker node runs the containerized applications and continuously reports to the control plane's API-server about its health.
Kubelet
It is an agent that is installed on every cluster node.
It serves as a link between the node and the API server.
It ensures that the containers are healthy and functioning in a Pod.
Pods are created and put into action.
It keeps an eye on work tasks on API Server.
The master gives it orders, and it reports back to the master.
Kube-proxy
It is a crucial part of networking as a networking component.
It controls IP routing and translation.
It is a network proxy that is active on each cluster node.
It keeps track of network policies on nodes. Network communication to Pods from both inside and outside the cluster is permitted under these network rules.
Each Pod will have a different IP address thanks to it.
It enables a pod's containers to share a single IP address.
It enables load-balancing across all pods in a service and Kubernetes networking services.
In addition to ensuring that the services are accessible to outside parties, it deals with specific host sub-netting.
Container runtime
The container runtime is the software that is responsible for running containers (in Pods).
To run the containers, each worker node has a container runtime engine.
It pulls images from a container image registry and starts and stops containers.
What is Control Plane? It is the platform where the Kubernetes architecture sits that controls the cluster. The control plane manages and maintains the worker nodes that hold the containerized applications.
The components are kube-apiserver, etcd, kube-scheduler, kube-controller-manager, cloud-controller-manager.
Write the difference between kubectl and kubelets:
kubectl is the command-line interface (CLI) tool for working with a Kubernetes cluster. It communicates with the API server to perform various operations on the cluster, such as deploying applications, scaling resources, and inspecting logs.
Kubelet is the technology that applies, creates, updates, and destroys containers on a Kubernetes node. Kubelets are the agents that run on each node in the cluster and communicate with the API server to ensure the desired state of the cluster is maintained. They manage the containers running on their node and communicate the status of those containers to the API server.
Explain the role of the API server: The Kubernetes API server is the front end of the Kubernetes control plane and is how users interact with their Kubernetes cluster.
It is the interface used to manage, create, and configure Kubernetes clusters. It's how the users, external components, and parts of your cluster all communicate with each other.
At the center of the Kubernetes control plane are the API server and the HTTP API that it exposes, allowing you to query and manipulate the state of Kubernetes objects.
Thankyou for reading....
Shubham Tiwari.
Great initiative by the #trainwithshubham community. Thank you Shubham Londhe