What is Kubernetes ArchitectureÂ
Kubernetes, also known as K8s, is an open-source platform that was designed to automate containerized applications’ deployment, scaling, and management. It was also built to handle the complexities of managing microservices-based applications in dynamic environments.
Originally designed by Google, the Kubernetes project is maintained today by a global community of contributors. Kubernetes architecture facilitates the deployment and management of applications across clusters of hosts, with features for high availability, scalability, and resilience.
The Components of Kubernetes Architecture
- Master Node: The master node acts as the control plane for a Kubernetes cluster. It manages the cluster’s state, schedules application workloads, and maintains overall cluster operations. The main components of the master node include:
- An API server that acts as the front-end for the Kubernetes control plane. It exposes the Kubernetes API, which enables users and external components to interact with the cluster.
- The scheduler assigns workloads to nodes based on resource availability, workload requirements, and other constraints.
- A controller manager monitors the cluster state and ensures that the desired state matches the actual state. It includes various controllers responsible for tasks such as node management, replication control, and endpoint management.
- The etcd is a distributed key-value store that stores the cluster’s configuration data and state. It serves as the single source of truth for the cluster.
- Node (Worker): Nodes are the individual machines (physical or virtual) that run containerized applications. Each node hosts a set of pods, which are the smallest deployable units in Kubernetes. Critical components of a node include:
- The Kubelet is the primary agent running on each node and manages the node and its containers. It communicates with the master node and ensures that containers are running as expected.
- Container runtime software that is charged with running containers. Kubernetes supports a range of container runtimes, including Docker, containerd, and CRI-O.
- The Kube proxy maintains network rules, performs request forwarding for Kubernetes services, and enables communication across pods and external clients.
- Pod: A pod is the smallest deployable unit in Kubernetes, representing one or more containers that share networking and storage resources. Pods encapsulate an application’s containers, storage resources, and configuration settings. They are scheduled and managed as a single entity by Kubernetes.
- Controller: Controllers are Kubernetes components responsible for managing the lifecycle of various objects within the cluster. Examples include:
- The ReplicaSet ensures that a specified number of pod replicas are running at any given time.
- The deployment manages the rollout and scaling of application deployments, allowing for declarative updates to the desired state.
- The StatefulSet maintains the identity of stateful applications by providing stable network identities and persistent storage.
Interactions in Kubernetes Architecture
Kubernetes architecture adheres to a decentralized, event-driven model in which components interact with other components through the Kubernetes API server. Key interactions include:
- User Interaction: Users interact with the Kubernetes cluster using command-line tools, such as kubectl, or through the Kubernetes API. They can create, update, and delete resources such as pods, deployments, and services.
- API Server: Acts as the central hub for communication within the Kubernetes cluster. It receives requests from users, controllers, and other parts and processes them to maintain the cluster’s desired state.
- Scheduler: Interacts with the API server to determine where to place newly created pods based on factors such as resource availability, workload constraints, and node affinity rules.
- Controller Manager: Monitors the cluster state by continuously comparing the actual state with the desired state defined by users or controllers. It can take corrective actions to ensure that the cluster remains in the desired state.
- Etcd: Stores the cluster’s configuration data and state in a distributed key-value store. It is accessed by the API server and other components to read and update cluster information.