The logic of state: Kubernetes orchestration explained
Kubernetes automates container management using a reconciliation loop that compares desired state in YAML manifests to actual cluster conditions. Created by Google engineers based on the Borg system, it manages billions of containers weekly through a control plane and worker nodes.
Kubernetes automates the deployment, scaling, and management of containerized applications. It groups containers into logical units for management and discovery. Google employees Joe Beda, Brendan Burns, and Craig McLuckie created the project based on 15 years of experience running production workloads at Google using a system called Borg. This design allows the platform to scale without increasing your operations team. The project was announced in June 2014 and the trademark is held by the Cloud Native Computing Foundation. The project was codenamed "Project 7" after the Star Trek character Seven of Nine, and the logo is a seven-spoked ship’s wheel. The system uses a reconciliation loop to continuously compare the desired state, which you declare in a YAML manifest, with the actual state currently running in the cluster to identify any divergences. This loop runs thousands of times per minute. If a developer declares three replicas of a pod, but only two exist, the controller creates an additional instance to match the declaration. You already know how Docker handles single containers, but scaling to thousands changes the math. The transition from a single monolithic application to microservices introduces high initial setup and operational complexity. Kubernetes scales without increasing your operations team because it handles billions of containers a week.
The Architecture of the Cluster
The architecture splits into a control plane and worker nodes. The control plane manages workloads and directs communication. The API server is the front end of the control plane, processing REST requests and updating the state in etcd. Etcd is a distributed, key-value data store that favors consistency over availability during network partitions. The API server uses the etcd watch API to monitor the cluster and restore divergences from the desired state. The scheduler is an extensible component that matches resource supply to workload demand. The scheduler selects the node that an unscheduled pod runs on, based on resource availability and other constraints. It tracks resource allocation on each node to ensure that workload is not scheduled in excess of available resources. The controller manager is a single process that manages several core Kubernetes controllers. One such controller is the ReplicaSet controller, which handles replication and scaling by running a specified number of copies of a pod. Worker nodes, also called minions, run the actual applications. Kubelet, an agent on each node, manages the running state of each node and ensures that containers in a pod run as expected. Kubelet takes care of starting, stopping, and maintaining application containers organized into pods as directed by the control plane. Kubelet relays status via heartbeat messages to the API server. Kube-proxy handles network communication by routing traffic to the appropriate container based on IP and port.
| Component | Function |
|---|---|
| Etcd | Stores cluster configuration and state |
| API Server | Processes REST requests and manages state |
| Scheduler | Assigns pods to nodes based on resources |
| Kubelet | Manages pod lifecycle on a node |
| Kube-proxy | Routes traffic and handles load balancing |
Workload Units and Runtime Changes
The pod is the smallest deployable unit and contains one or more containers. A Deployment manages a set of pods and handles rolling updates or rollbacks. A ReplicaSet maintains a stable number of identical pods using label selectors. While the ReplicaSet controller manages the scale, the Deployment controller manages what happens to the ReplicaSet, such as whether to roll out or roll back an update. The ReplicationController was the predecessor of the ReplicaSet and was deprecated to favor set-based label selectors. For applications requiring ordered deployment or unique identities, such as databases, StatefulSets enforce uniqueness and ordering. DaemonSets ensure a pod runs on every node in the cluster, which helps with log collection or storage services. Services provide a stable IP address or DNS name for a set of pods. A Service is a set of pods that work together, such as one tier of a multi-tier application. The Service API provides a stable IP address or host name for a service backed by one or more Pods, and Kubernetes tracks the backing Pods through EndpointSlice objects to ensure correct routing. Ingress manages external access to services by providing HTTP and HTTPS routing. ConfigMaps store configuration settings separately from the application, while Secrets store sensitive information like passwords or API keys. Persistent Volumes provide storage that does not get deleted when a pod is removed.
How does a team decide when the operational overhead of a control plane outweighs the benefits of automation?
Kubernetes scales workloads toward a set state, including scaling based on CPU, memory, or custom metrics. The system removed official support for Docker as a container runtime with the release of version 1.24 in May 2022. This followed the deprecation of the dockershim in 2020. Current widely used runtimes include containerd and CRI-O.