# Core Concepts (Part 1)

Kubernetes automates the deployment, scaling, and networking of containerized applications. While its internal architecture can seem intimidating at first, mapping its components to a maritime shipping fleet makes every piece intuitive.

## The High-Level Analogy: Control Ships vs. Cargo Ships

A Kubernetes cluster consists of machines—physical or virtual, on-premises or in the cloud—divided into two functional roles:

- **Control Plane (Master Nodes) — The Control Ships:** Manage the cluster, store state records, decide where containers go, and monitor cluster health.
- **Worker Nodes — The Cargo Ships:** Carry the actual workload by running your containerized applications.

<table style="min-width: 75px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1"><p><strong>Maritime Analogy</strong></p></td><td colspan="1" rowspan="1"><p><strong>Kubernetes Component</strong></p></td><td colspan="1" rowspan="1"><p><strong>Primary Role</strong></p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Control Ship</strong></p></td><td colspan="1" rowspan="1"><p>Control Plane (Master Node)</p></td><td colspan="1" rowspan="1"><p>Cluster management and orchestration</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Cargo Ship</strong></p></td><td colspan="1" rowspan="1"><p>Worker Node</p></td><td colspan="1" rowspan="1"><p>Running application workloads</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Shipping Container</strong></p></td><td colspan="1" rowspan="1"><p>Pod / Container</p></td><td colspan="1" rowspan="1"><p>Packaged application instance</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Ship's Logbook</strong></p></td><td colspan="1" rowspan="1"><p>etcd</p></td><td colspan="1" rowspan="1"><p>Distributed key-value state database</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Harbor Cranes</strong></p></td><td colspan="1" rowspan="1"><p>kube-scheduler</p></td><td colspan="1" rowspan="1"><p>Assigning workloads to the right nodes</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Port Operations Offices</strong></p></td><td colspan="1" rowspan="1"><p>kube-controller-manager</p></td><td colspan="1" rowspan="1"><p>Monitoring state and self-healing</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Port Radio Tower</strong></p></td><td colspan="1" rowspan="1"><p>kube-apiserver</p></td><td colspan="1" rowspan="1"><p>Central communication and API hub</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Ship Captain</strong></p></td><td colspan="1" rowspan="1"><p>kubelet</p></td><td colspan="1" rowspan="1"><p>Node-level agent managing local containers</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Inter-Ship Radio Network</strong></p></td><td colspan="1" rowspan="1"><p>kube-proxy</p></td><td colspan="1" rowspan="1"><p>Service networking and traffic routing</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Container Handling Gear</strong></p></td><td colspan="1" rowspan="1"><p>Container Runtime</p></td><td colspan="1" rowspan="1"><p>Low-level software executing containers</p></td></tr></tbody></table>

## Control Plane Components (The Control Ship)

The Control Plane acts as the brain of the cluster, making global decisions and responding to cluster events.

### 1\. kube-apiserver (The Port Radio Tower)

The `kube-apiserver` is the central management hub of Kubernetes. It exposes the Kubernetes API and orchestrates every operation in the cluster:

- External users and CLI tools (`kubectl`) send commands here.
- Internal controllers query it to monitor cluster state.
- Worker nodes report status back to it.

All communication flows through the API server; components rarely talk directly to `etcd` or one another without passing through it.

### 2\. etcd (The Ship's Logbook)

`etcd` is a consistent, highly available distributed key-value store that serves as Kubernetes' single source of truth. It records:

- Which nodes belong to the cluster.
- Which containers are scheduled on which nodes.
- Configuration data, secrets, and state timestamps.

### 3\. kube-scheduler (The Harbor Cranes)

When a new workload arrives, the `kube-scheduler` watches for unscheduled Pods and selects the optimal Worker Node to run them. It filters and scores nodes based on:

- CPU and memory resource requirements.
- Node capacity and current load.
- Scheduling constraints such as **taints and tolerations**, **node affinity**, and **anti-affinity** rules.

### 4\. kube-controller-manager (Port Operations Offices)

Controllers run continuous control loops that watch the actual state of the cluster via the API server and make changes to move it toward the desired state:

- **Node Controller:** Monitors node health, onboarded nodes, and responds when a node becomes unreachable or crashes.
- **Replication / ReplicaSet Controller:** Ensures the exact desired number of Pod replicas are running at all times, replacing any that fail.
- **Service Account & Token Controllers:** Manage authentication identities and API access credentials across namespaces.

## Worker Node Components (The Cargo Ships)

Worker nodes provide the compute, memory, and networking resources needed to run applications.

### 1\. kubelet (The Ship Captain)

The `kubelet` is the primary node agent running on every Worker Node. It registers the node with the Control Plane, watches the `kube-apiserver` for Pod assignments, instructs the container runtime to start or stop containers, and continuously reports node and Pod health back to the master.

### 2\. kube-proxy (The Inter-Ship Network)

Applications spread across multiple nodes need reliable communication (for example, a frontend web container on Node A talking to a backend database container on Node B). `kube-proxy` runs on every node and maintains network rules (via `iptables` or `IPVS`) that route traffic to the appropriate Pods behind Kubernetes Services.

### 3\. Container Runtime (Container Handling Gear)

The container runtime is the underlying software responsible for pulling container images and running containers on the host OS. Modern Kubernetes clusters use CRI-compliant runtimes such as **containerd** or **CRI-O** (having deprecated direct Docker Engine integration via `dockershim` in Kubernetes v1.24).
