Kubernetes has quickly become the de-facto standard for container orchestration. As more organizations adopt microservices and scale their infrastructure, understanding Kubernetes architecture is key for developers and IT ops professionals. In this comprehensive guide, I‘ll provide an in-depth look at the components that make up a Kubernetes cluster.
Overview
At a high-level, a Kubernetes cluster consists of a master node and worker nodes. The master node acts as the control plane and brain of the cluster by exposing APIs, scheduling workloads, and monitoring cluster health. The worker nodes run containerized applications packaged as pods.
Here is a diagram showing how the main Kubernetes components interact:
Next, let‘s explore each component in more detail.
Master Node Components
The master node runs various processes to manage and schedule workloads on the worker nodes.
kube-apiserver
As the frontend of Kubernetes control plane, kube-apiserver exposes the Kubernetes API that allows users, client processes, and external components to communicate with one another. It handles REST requests, validates them, and updates state of the cluster to match the desired state.
Kube-apiserver is like the receptionist for your cluster. It authenticates requests using service accounts and routes authorized requests to the appropriate components.
etcd
etcd is a distributed key-value store that persistently stores the cluster configuration data. It is accessible only from within the cluster for security reasons. kube-apiserver and the other master components Query etcd for current state data so they can schedule workloads and monitor cluster health.
Think of etcd as the brain that remembers everything important about your cluster!
kube-scheduler
This component monitors resource usage on worker nodes and places pods onto nodes intelligently. The scheduler looks at resource requirements of new pods and finds the best node match based on metrics like individual node CPU, RAM, storage, and more.
You can think of the kube-scheduler as the hard-working traffic cop that directs traffic pods to the optimal node.
kube-controller-manager
The controller manager contains functions like replication controllers that monitor the shared state of cluster and make necessary adjustments. For example, if the number of pod replicas defined in a replication controller doesn‘t match the actual number running, the controller manager will take actions to get the current state to the desired state.
The controller manager is like your overly controlling friend that constantly nagging the cluster to keep things in order.
Worker Node Components
The worker nodes do the actual work of running containerized applications.
kubelet
The kubelet agent runs on each worker node and communicates with master components to receive pod definitions. It then ensures the defined containers are all running and healthy as expected.
You can think of kubelets as the diligent employees on each node that perform their job tirelessly.
kube-proxy
This network proxy runs on each node and maintains rules to forward requests to the right pod based on IP address and port number. It helps provide basic load balancing and direct external traffic to the appropriate pod.
Imagine kube-proxy as the receptionists on each floor of an office building, directing customers and traffic to the correct department.
Container Runtime
The container runtime is the underlying software that runs containers. Most Kubernetes deployments use Docker as the runtime, but support for other runtimes like rkt and CRI-O exists. The kubelet communicates with the runtime via the Container Runtime Interface (CRI) to run pods and containers.
You can think of the container runtime as the actual machines in the factory floor that do the real work.
Conclusion
Kubernetes architecture provides a flexible and modular foundation to deploy, scale, and manage containerized applications. The master components provide scheduling, APIs, and health monitoring while the worker nodes actually run the applications.
Concepts like pods, services, replication controllers and more add rich functionality on top of this architecture. As you develop and run applications on Kubernetes, having a solid grasp of these core architecture components will give you great insight! Let me know in the comments if you have any other questions.