Kubernetes is a declarative control plane that manages the lifecycle of containerized workloads. It abstracts physical infrastructure into a set of logical primitives: Pods, Services, and Deployments.

The Atomic Unit: The Pod

A Pod is the smallest deployable unit. It groups one or more containers that share a network namespace (localhost) and storage volumes.

The Sidecar Pattern

The Pod's shared network namespace enables the Sidecar Pattern, where auxiliary tasks (logging, service mesh proxying, secret rotation) are decoupled from the primary application container.

Technical Constraint: All containers in a Pod share a single IP. Port conflicts must be managed at the container level within the Pod.

Management: Deployments and ReplicaSets

A Deployment manages the desired state of a set of Pods. It is a high-level abstraction over ReplicaSets.

Rolling Update Mechanics

When a Deployment is updated (e.g., new image version), the Deployment Controller:

  1. Creates a new ReplicaSet (RS_{new}).
  2. Scales up RS_{new} while scaling down the old ReplicaSet (RS_{old}).
  3. Monitors Readiness Probes to ensure RS_{new} Pods are healthy before terminating RS_{old} Pods.

Rollback Strategy: If RS_{new} fails health checks, the controller can be instructed to revert to RS_{old} immediately, leveraging the immutable history of ReplicaSet revisions.

Networking: The Service Abstraction

Pods are ephemeral; their IPs change on every restart. A Service provides a stable virtual IP (ClusterIP) and DNS name for a set of Pods.

Service Discovery (kube-proxy)

kube-proxy runs on every node and manages the mapping from the Service IP to the healthy Pod IPs using:

Exposure Modes

Reliability: Probes as Contracts

Kubernetes relies on three probe types to manage the "Self-Healing" loop:

  1. Liveness Probe: "Is the process stuck?" If it fails, the container is restarted.
  2. Readiness Probe: "Can I send production traffic?" If it fails, the Pod is removed from the Service endpoint list.
  3. Startup Probe: "Is the slow-starting process done yet?" Disables liveness/readiness until the first success.

Resource Management (QoS Classes)

Resource requests and limits define the Pod's Quality of Service (QoS):

Summary of Primitives

ComponentResponsibilityFailure Mode
PodExecution & Co-locationEphemeral; dies with the Node.
ServiceStable NetworkingPoints to old IPs if selector is wrong.
DeploymentVersioning & ScalingRollout stall if probes never pass.
ConfigMap/SecretState & ConfigurationStale data if application doesn't watch for updates.