writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
kubernetes-internalsThe Kubernetes Control Plane under the hood, etcd consensus (Raft), kube-apiserver event loops, kubelet operation, and CNI fundamentals.
Independent GitHub snapshot · Automated classification · Original documentation governs
Kubernetes is a declarative, state-reconciling system. Its architecture is fundamentally driven by a distributed control loop paradigm, backed by a strongly consistent distributed key-value store.
All cluster state (configuration, specifications, statuses) resides in etcd. It guarantees linearizability through the Raft consensus algorithm.
AppendEntries RPCs to followers. A write is committed only when a quorum (majority) acknowledges the append.WATCH for changes effectively without polling.resourceVersion. This is mapped directly to the etcd revision, preventing lost updates via optimistic concurrency control (Compare-and-Swap).The kube-apiserver is the singular gateway to the cluster state. It is a stateless, horizontally scalable REST interface, but its core power lies in its event loop and watch mechanisms.
ADDED, MODIFIED, DELETED). This is facilitated by the SharedInformer cache, which reduces apiserver load.The kube-controller-manager runs continuous control loops. A reconciler strictly adheres to this pseudo-logic:
func (c *Controller) Reconcile(request Request) (Result, error) {
// 1. Observe the current state from the informer cache
currentState := c.lister.Get(request.Name)
// 2. Determine the desired state (e.g., from the object's Spec)
desiredState := getDesiredState(currentState)
// 3. Actuate: compute the delta and apply mutations
if currentState != desiredState {
c.client.Update(desiredState)
}
}
The kubelet is the primary node agent. It watches the apiserver for Pod bindings assigned to its node.
CNI dictates how network namespaces are wired.
ADD command.%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
flowchart TD
API[kube-apiserver] --> ETCD[(etcd - Raft)]
KCM[kube-controller-manager] -.->|Watch/List/Update| API
Sched[kube-scheduler] -.->|Watch/Bind| API
Kubelet[Kubelet Node Agent] -.->|Watch Pods / Update Status| API
Kubelet --> CRI[Container Runtime Interface]
Kubelet --> CNI[Container Network Interface]
Kubelet --> CSI[Container Storage Interface]
CRI --> PodC[Pod Containers]
CNI --> Veth[Network Namespaces & veth]