Oh My AlgorithmKO
←
Kubernetes
← All catalogs

Kubernetes

Pod scheduling, rollout, recovery, and resource management

Pod

Separate containers · Separate networks and filesystems

Running the collector and web server separately gives each its own IP and filesystem.

File PullerWeb Server172.17.0.2172.17.0.3Its own filesystemIts own filesystem

Same Pod · Shared network and volumes

A Pod is the basic Kubernetes execution unit, grouping one or more containers for placement and management.

PodFile PullerWeb Server
Principles and uses

Compare placement, networking, and file sharing when containers run in one Pod.

Containers in one Pod share networking and are assigned to the same node.

Shared volume mounts allow file access across containers. Containers also share a port space and cannot bind the same address and port simultaneously.

Use it to decide container grouping and understand Pod networking and storage.

Nodes & Pods

A node is a physical or virtual machine that provides resources for running Pods.

Node 1Node 2CPUMemoryCPUMemory
Principles and uses

Explore node components, resources, and recovery after node failure.

A Pod runs on one node; running elsewhere requires a replacement Pod.

Kubelet and the container runtime manage execution. Scheduling uses allocatable resources, and recovery can create new Pods rather than move existing ones.

Use it to distinguish node capacity from Pod placement and understand replacement identities.

Jobs & CronJobs

Batch work such as reconciliation or migration should finish, unlike continuously running workloads managed by Deployments.

report-1Deployment · reportreplicas 1
Principles and uses

Run work that ends after a required number of successful completions.

A Job tracks successful work rather than continuously running replicas.

Completions sets the success target; parallelism controls concurrency. Retries follow configured limits, and CronJobs add schedules.

Use it for batch processing, migrations, one-off tasks, and scheduled work.

Desired State

Declare three web replicas. The API server accepts the configuration and stores it in etcd.

etcd · replicas 3Controller3 − 0 = 3Node 1 · kubeletNode 2

Try it yourself

Delete a Pod or simulate a node failure, then watch the controller restore the Pod count.

Control plane
Node 1
Node 2
API serverStores the declaration
etcdwhere the declaration is actually written
ControllerCompares declared with actual
SchedulerWhich node it goes on
web-1
web-2
web-3
Desired Pod count3Current Pod count 3

The desired and current Pod counts are both 3. No Pods need to be created or deleted.

Desired Pod count 3 · Current Pod count 3 · Selected Pod: web-1 · Node 1: Ready · Node 2: Ready

Principles and uses

Follow reconciliation when the actual Pod count differs from the declared count.

Controllers repeatedly compare desired and actual state and take corrective action.

The API server stores configuration, the scheduler chooses nodes, and kubelet manages execution. Missing replicas can be replaced after failure.

Use it to understand declarative configuration and the responsibilities involved in recovery.

Rolling Update

Three web Pods run the v1 image. A Deployment and ReplicaSet maintain that replica count.

Deployment · replicas 3ReplicaSet · v1Ready · 3 / 3v1-1v1-2v1-3

Try it yourself

Deploy v2 or roll back to v1. This example allows one extra Pod and keeps at least 3 ready Pods.

Available Pods3 / 3
web-1 · v1Ready
web-2 · v1Ready
web-3 · v1Ready

Target version v1 · Ready Pods 3 / 3 · Three v1 Pods are running. Start a v2 rollout.

Principles and uses

Follow a rolling update that progressively creates new Pods and removes old ones.

Scale the new ReplicaSet up and the previous one down.

Availability and surge depend on update settings. Readiness gates replacement, and retained ReplicaSets support rollback.

Use it to understand availability during rollout and version rollback.

Autoscaling (HPA)

HPA adjusts the number of Pods using metrics such as CPU utilization.

ReplicasHumanreplicas: 3Autoscalertarget: 50%3
Principles and uses

Follow HPA as it adjusts replicas using CPU utilization.

Calculate required replicas from the metric-to-target ratio and apply configured bounds.

Tolerance handles small deviations, and stabilization can delay downscaling. Pod scaling and node-capacity scaling are separate responsibilities.

Use it to plan metric targets, replica bounds, and protection against frequent scaling changes.

Probes (Liveness & Readiness)

Readiness failure · Stop routing new requests

This example checks readiness every ten seconds. The Service sends new requests only to ready Pods.

Servicekubeletweb-1Running✓web-2Running✓web-3Running✓

Liveness failure · Restart the container

A liveness probe checks whether a container needs restarting, unlike readiness, which controls traffic eligibility.

Servicekubeletweb-1Running✓web-2Running✓web-3Running✓

Try it yourself

Choose a probe type and stop web-2 responses. Compare request removal with container restarts.

Pods in the endpoint list3 / 3
web-1Ready
web-2Ready
web-3Ready

Enabled probes readiness · All 3 Pods are responding. Stop responses from web-2.

Principles and uses

Compare how readiness, liveness, and startup probes affect traffic and restarts.

Readiness checks traffic eligibility; liveness checks whether a restart is needed.

Readiness failure alone does not terminate a container. Liveness can trigger restart, while startup probes allow initialization time.

Use it to distinguish traffic exclusion from container restart and choose health-check settings.

Service

A replacement Pod can have a new IP. Direct clients would need to find its new address.

web-110.0.0.2web-210.0.0.3api-1app=api
Principles and uses

Use a Service to retain a connection name as Pods change or scale.

A Service provides a stable endpoint and selects matching Pods.

Label selectors can discover replacement Pods with new IPs. Readiness controls which endpoints receive traffic.

Use it to connect workloads without hard-coded Pod IPs and understand traffic during deployments.

Ingress

ClusterIP Services provide internal addresses. Exposing them separately requires managing separate external endpoints and certificates.

api-svc:8080web-svc:80admin-svc:80178.91.123.132178.91.123.133178.91.123.134
Principles and uses

Follow Ingress rules routing external HTTP requests to multiple Services.

Match the request host and path to select a backend Service.

An Ingress controller must apply the rules. This example shares one external endpoint and terminates TLS at the Ingress.

Use it to plan host/path routing and locate external access and certificate handling.

ConfigMap & Secret

Embedding environment settings in an image requires separate builds for development and production.

Image · v1-devImage · v1-prodApp codeApp codeAPP_MODE=devDB_PASSWORD=dev-pwAPP_MODE=prodDB_PASSWORD=prod-pw
Principles and uses

Pass environment-specific configuration separately from container images.

ConfigMap and Secret values can be injected as environment variables or mounted files.

Existing environment variables do not update automatically. Ordinary ConfigMap volume files can update, but applications must reread them. Secret encoding is not encryption.

Use it to separate environment settings and plan update behavior and sensitive-value access.

Volumes & PV/PVC

Writable layer and emptyDir · Compare data lifetimes

Files in a container writable layer are lost when the container is recreated.

Node 1Node 2Pod Afile

Persistent volume · Keep data after replacing a Pod

A PVC requests the storage capacity and access mode needed by the application.

Node 1Node 2Pod APVC10Gi · RWO
Principles and uses

Compare data retention in writable layers, emptyDir, and persistent volumes.

EmptyDir follows the Pod lifetime; persistent storage can outlive Pod replacement.

Recreating a container resets its writable layer but preserves the same Pod emptyDir. Persistent volumes use PVC requests, access modes, and reclaim policies.

Use it to distinguish temporary data from data that must survive restarts and replacements.

Scheduling & requests/limits

A new Pod remains Pending until a node is assigned and startup can proceed.

PendingFilterScoreReserveBindnode-1node-2node-33.5 / 42 / 41 / 4web-4requests 1
Principles and uses

Follow node selection using resource requests and placement constraints.

Scheduling evaluates declared requests rather than current measured usage.

Filter eligible nodes, then evaluate them with scoring policies. Limits bound runtime usage, and CPU and memory exceedance behave differently.

Use it to understand requests, Pending Pods, node selection, and resource shortages.

Learning topics