Core Kubernetes: Jazz Improv over Orchestration | by Joe Beda | Heptio
Visit Website
Joe Beda
May 30, 2017
Summary
This article details the inner workings of Kubernetes, explaining its core components (etcd, API Server, Controller Manager, Scheduler, and Kubelet) and how they interact to schedule and run a Pod. Kubernetes is presented as a 'jazz improv' system where components react and coordinate loosely via the API Server, rather than a centrally orchestrated system.
Content Sections
Datastore: etcd
etcd is the core state store for Kubernetes, prioritizing consistency. Clients use watches to subscribe to changes in the key namespace, enabling real-time coordination between components. This is an inversion of common pub/sub mechanisms where the keys (topics) store the real data and notifications contain change information.
Policy Layer: API Server
The API Server is the central policy component providing filtered access to etcd, and manages resources via a REST API. Its responsibilities include authentication, authorization, running admission controllers for policy enforcement, and handling API versioning by converting resources based on the API version requested. Clients can watch for resource changes, facilitating coordination.
Business Logic: Controller Manager and Scheduler
The Controller Manager and Scheduler coordinate through the API Server to implement system behavior. The scheduler assigns unbound Pods to nodes based on available resources and constraints. Controllers, like the ReplicaSet controller, watch resources and take actions to maintain a stable state.
Node Agent: Kubelet
The Kubelet runs on each node, authenticates to the API Server, and ensures that Pods bound to its node are running. It monitors Pod status via the container runtime and reports changes back to the API Server.
A Typical Flow
A user creates a Pod via the API Server, which writes it to etcd. The scheduler picks a node and updates the binding. The Kubelet notices the change, runs the container, and monitors its status, reporting back to the API Server.