In the era of modern software development and deployment, Kubernetes stands as the standard tool for orchestrating containerized applications in DevOps methodology. Its robust architecture not only simplifies the management of containerized workloads but also empowers teams to scale, deploy, and manage applications seamlessly across diverse environments. According to the statista “In 2022, 61 percent of respondents state using Kubernetes. 50 percent of respondents to a global survey of DevOps, engineering, and security professionals stated that Red Hat OpenShift is the Kubernetes platforms they primarily use. “
Before using Kubernetes for deployment we have to understand the architecture and working of it. In this blog, we are going to understand the working of kubernetes, its components and a lot more.
Watch this video by Intellipaat to understand the Kubernetes Architecture
What Is Kubernetes?
Kubernetes, popularly known as Kube or K8s, is an open source container orchestration tool used for automating, scaling and management of containerized applications.
Kubernetes was originally developed by Google and was first released in 2014. It is officially written in Go Programming Language. Later, Cloud Native Computing Foundation (CNCF) , a joint venture of Google and Linux Foundation, worked together with the community to maintain kubernetes.
Example of Kubernetes Use Case
Engineers and finance can determine exactly where, when, and how Kubernetes expenditures are incurred. They can check Kubernetes costs, assure high availability in service delivery, and more by monitoring Kubernetes appropriately.
Kubernetes Architecture Diagram
Kubernetes works on the principle of client-server architecture, where there are master and slave nodes. The master node is often installed on a single Linux system while the slave node is installed on linux workstations. Below is a diagram representing the architecture of kubernetes:
Kubernetes Components
There are many Components in Kubernetes. All the components can be grouped under two major categories:
- Control Plane Components: The control plane components responsible for container orchestrations. It helps to maintain the state of a cluster.
- Node Components: The node components are a very critical component in kubernetes, responsible for running the containerized applications.
Control Plane Components
The control plane acts as a nerve center to Kubernetes for container orchestration and maintaining the state of the cluster. There are a total of 5 services that run on the control plane.
- Kube-apiserver
The Kube API server is one of the most important parts of Kubernetes control plane. It functions as the primary interface for communication with the cluster. It takes commands and updates from Kubectl, CLI and other tools and it is a security wall to all incoming traffic. All these requests are then authenticated prior to being transmitted to other parts of the system in order to ensure that both integrity and safety of the cluster are maintained. In a nutshell, every action within the cluster must go through API server, making this component central and vital in Kubernetes operations.
- etcd
The Kubernetes clusters’ vital information like pod status and namespace configuration is managed by etcd, a purpose-built distributed key-value data storage component. Security is important to restrict the accessibility of this component only to the API server. The watch capability of etcd is utilized by the Kubernetes API server in order to keep a close eye on any changes concerning object states.
- Kube-scheduler
When the API Server receives a request for scheduling pods, it forwards the task to the Scheduler that aims at making informed choices on best node placement aimed at improving cluster efficiency. Suitable worker nodes are identified by kube-scheduler based on factors like pod requirements such as CPU, memory and affinity in order to ensure effective resource allocation.
There are several ways Kubernetes uses to schedule a pod. First of all, it goes through every node available and picks out ones that are best suited for the pod. Scheduling plugins score each node so as to assist the scheduler in choosing an optimal one that can bind the pod according to its specifications. This helps with prioritizing high-priority pods and allows for easy incorporation of custom plugins which is a novel way of managing pods within Kubernetes.
- Kube-controller-manager
The kube-controller-manager looks into the execution of controllers responsible for managing different phases of the cluster’s control loop.
There are several types of controller present. Here are a few of them listed below:
- Deployment Controllers manage the deployment of multiple replicas of containerized applications.
- Replication Controllers maintain a designated number of pod replicas, replacing any failed pods automatically.
- StatefulSet Controllers offer functionalities such as persistent storage, unique network identities, and controlled deployment and scaling of applications.
- DaemonSet Controllers guarantee the presence of specific pods on every node in the cluster or on selected nodes based on specific labels.
- Cloud-controller-manager
On cloud based Kubernetes deployments, establishing connectivity between Kubernetes cluster and Cloud Computing Platform APIs is done by the cloud controller manager. This ensures that core components of Kubernetes can work independently while being able to interface with cloud providers through plugins.
For instance, the cloud controller manager acts as an intermediary between the AWS API and the Kubernetes control plane if you are collaborating with AWS. It provides a way for such services as EC2 instances, Elastic Load Balancers (ELBs), and Elastic Block Store (EBS) volumes to function and seamlessly integrate with it.
Node Components
The node components are the present in the actual nodes used for maintaining and running the pods hence providing kubernetes the runtime environment. In total there are three services that are present in each node used for managing the pods.
- Kubelet
A kubelet is an agent that runs on each node in the cluster. It is responsible for managing the containers in the Pod.
- Kube-proxy
Kube-proxy, present on every node within the cluster, serves as a network proxy, playing a crucial role in realizing Kubernetes Service concept.
- Container Runtime
Container element is a core element facilitating Kubernetes to efficiently run containers. It manages the execution and lifecycle of containers within the Kubernetes ecosystem.
Addons
To ensure optimal performance of the kubernetes cluster, it is essential to incorporate necessary add-ons alongside the core elements. The choice of these add-ons and supplementary components largely relies on the specific needs and objectives of the project.
Some of the popular add-on components needed in the cluster like DNS, Web UI, Container level monitoring, cluster level logging and network plugins enhance the functionality of the kubernetes cluster.
- DNS
Cluster DNS operates as an additional DNS server alongside existing ones in your environment, catering specifically to Kubernetes services by providing DNS records.
- Web UI (Dashboard)
Dashboard serves as a web-based interface for managing and diagnosing applications and the cluster itself within Kubernetes clusters.
- Container Resource Monitoring
Container Resource Monitoring captures essential time-series metrics about containers, storing them in a centralized database and offering a user-friendly interface for data exploration.
- Cluster-level Logging
Cluster-level logging functionality is responsible for saving container logs into a central repository equipped with search and browsing capabilities.
- Network Plugins
Network plugins are essential software components that implement the container network interface (CNI) specification. They facilitate IP address allocation for pods and enable seamless communication within the cluster.
Kubernetes Architecture Explained
Here’s how Kubernetes works:
- The Desired State is Defined: A Kubernetes manifest file is produced, which highlights the intended configuration of your application. The manifest file typically gives details about the container image, number of replicas, networking and storage requirements, and environment variables or command line arguments to set.
- Submit the Manifest File: After you have specified the intended state, the Kubernetes API server, which acts as a control plane for this system receives your manifest file. The desired state will be saved in an etc distributed key-value store by API server.
- Control Plane Components: Kubernetes includes several control plane elements that work together to ensure that the cluster works correctly. These include controller manager, etcd and API server.
- Scheduler: New pods are watched for by the scheduler in Kubernetes; these are small units that can be deployed individually. This scheduler then distributes them to nodes- computers for execution in a cluster based on available resources and other scheduling concerns.
- Kubelet: The kubelet is a component of kubernetes that manages the containers and pods running on each node in the cluster. This kubelet talks to the API server to make sure that the desired state of operating pods are met.
- Container Runtime: Kubernetes enables you to work with different kinds of container runtimes such as Docker Container for handling nodes’ running containers.
- Networking: Within Kubernetes, there exists a networking model that allows communication between containers on different nodes. Combining load balancing and network address translation also means services running in the cluster can be exposed to those outside it.
- Updates and Scaling: In order to update an application without downtime, recover deleted folders, create nested groups of teams and manage your users or scale up / down based on demand, you can use updates and scaling features provided by Kubernetes.
Conclusion
We hope this blog has been successful in explaining the Kubernetes Architecture, how it works, its components and add ons. For more such content, you can check out our YouTube channel as well.