What Kubernetes is, and the problem it solves







Kubernetes, From the Ground Up


A working reference, not a wall of theory

Kubernetes, from the ground up

How a cluster is put together, how a Pod actually gets scheduled and kept alive, and the commands you reach for once it’s running — with a diagram for every moving part.

11Core topics
25+Diagrams & flows
60+kubectl commands

01Foundations

What Kubernetes is, and the problem it solves

Kubernetes (K8s) is an open-source container orchestration platform. It automates deployment, scaling, networking, and self-healing for containerized applications — originally built at Google, now maintained by the CNCF.

💡

In one line: Kubernetes runs your containerized applications reliably, at scale, without you babysitting them by hand.

Why it exists

Docker alone is great at packaging a single container — but running dozens or hundreds of them in production exposes problems it was never designed to solve.

Docker alone Kubernetes
Manages a single container Manages fleets of containers across many machines
Manual scaling process Automatic scaling based on load
No self-healing Restarts / reschedules failed containers automatically
No built-in load balancing Distributes traffic across replicas natively
No rolling updates Zero-downtime rollouts and instant rollbacks

The stack, top to bottom

Application Pods smallest deployable unit Runs your app’s containers Kubernetes orchestration layer Schedules & heals Pods Cluster = nodes

Application → Pods → Kubernetes orchestration → physical Cluster of Nodes

Core features at a glance

Self-healing

Failed containers are restarted, unhealthy Pods are replaced automatically.

Auto scaling

Scale Pods up or down manually or via the Horizontal Pod Autoscaler.

Rolling updates

Ship new versions with zero downtime, and roll back instantly if something breaks.

Service discovery

Stable networking and load balancing even as Pods are destroyed and recreated.

Storage orchestration

Mount local, network, or cloud storage automatically.

Config & secret management

Separate configuration and credentials from your container images.

02Foundations

Cluster architecture: control plane vs. worker nodes

Kubernetes follows a master–worker (client–server) model. Every cluster splits into two halves: the Control Plane, which makes decisions, and Worker Nodes, which do the work.

User / Client kubectl Kubernetes Cluster

Control Plane (Master) API Server Front end of K8s. All requests pass through it.

etcd Key-value store for all cluster state.

Scheduler Picks a Node for each new Pod to run on.

Controller Mgr Runs controllers that hold the desired state.

Worker Node kubelet Talks to control plane, manages Pods on this node

kube-proxy Handles networking & service rules

Container Runtime Pod Pod Pod

Control Plane decides. Worker Nodes execute. A real cluster has one control plane and many worker nodes.

Control plane components

Component Role
API Server The front door of Kubernetes — exposes the REST API that kubectl and every other component talks to.
etcd A consistent, highly-available key-value store holding all cluster data.
Scheduler Watches for newly created Pods with no Node assigned, and picks the best Node for them.
Controller Manager Runs the background controllers (Node, ReplicaSet, etc.) that continuously push the cluster toward its desired state.

Worker node components

Component Role
kubelet Ensures the containers described for a Pod are actually running on this node.
kube-proxy Maintains network rules so traffic reaches the right Pods.
Container Runtime Pulls images and runs containers (e.g. containerd, Docker).
🧭

Mental model: the Control Plane is the “brain” — it never runs your application code. Worker Nodes are the “muscle” — they only run what they’re told.
03Workloads

Pods: the smallest deployable unit

A Pod wraps one or more containers that share the same network and storage. Containers inside a Pod are always scheduled together, on the same node — they’re never split up.

Pod Container 1 Container 2 Shared Network (one IP) Shared Storage (Volumes)

Every container in a Pod shares one network identity and one set of volumes.

Why a Pod instead of a bare container?

Container (Docker alone) Pod (Kubernetes)
Single container One or more containers
Managed manually Managed by Kubernetes
No self-healing Self-healing — restarts on failure
Scaling is manual Auto-scaling is possible
No shared resources Shares network & storage across its containers

Pod lifecycle

PendingAccepted by the cluster
RunningBound to a node, containers start
SucceededCompleted, won’t restart

Running can also branch to ↓
FailedFailed and won’t restart
UnknownState can’t be determined
Pending / RunningMay restart, back into the cycle

A Pod moves through Pending → Running → a terminal state, and can loop back if it restarts.

Pod types

Single-container Pod

The common case — one container per Pod, doing one job.

Multi-container Pod

Tightly-coupled helper containers (e.g. sidecars, log shippers) that must live and scale alongside the main container.

📌

In short: a Pod is the simplest unit Kubernetes creates or deploys. It wraps one or more containers that are meant to be tightly coupled.
04Workloads

ReplicaSets & Deployments

You almost never create Pods directly. Instead, a Deployment manages a ReplicaSet, which manages the Pods — giving you scaling, rolling updates, and rollbacks for free.

Deployment Manages ReplicaSet (desired state) ReplicaSet Manages Pods (keeps N replicas) Pod Pod Pod Running containers

Deployment → ReplicaSet → Pods. Each layer manages the one below it.

ReplicaSet vs. Deployment

Feature ReplicaSet Deployment
Purpose Ensures N Pod replicas are running Manages ReplicaSets, adds declarative updates
Rolling updates Not supported Supported
Rollbacks Not supported Supported, to any previous revision
Scaling Supported Supported
Self-healing Yes Yes
Typical use Rare, simple cases Production standard

Rolling update, step by step

1 · Current stateReplicaSet v1, all Pods old
2 · New RS createdReplicaSet v2 stands up
3 · Gradual swapOld Pods retire one by one, new Pods take over
4 · CompleteAll Pods on v2, zero downtime

Rollback flow

Update failsNew version misbehaves
kubectl rollout undoDeployment reverts
Stable againPods back on previous version

# roll back to the previous working version
kubectl rollout undo deployment my-app
# see revision history first if you need to pick a specific one
kubectl rollout history deployment my-app

Deployment strategies

Recreate

All old Pods are killed first, then new ones are created. Simple, but causes downtime.

RollingUpdate (default)

Pods are updated one by one — zero downtime, the workhorse strategy.

Blue/Green

Run two full environments (blue = current, green = new) and switch traffic over instantly once green is verified. More infrastructure, but instant, safe cutover and rollback.

Commands you’ll actually use

Command Description
kubectl create deployment name --image=img Create a new Deployment
kubectl get deployments List all Deployments
kubectl scale deployment name --replicas=5 Scale to N replicas
kubectl rollout status deployment/name Check rollout progress
kubectl rollout undo deployment/name Roll back to the previous version
kubectl set image deployment/name c=img:tag Update a container’s image
05Networking

Services: stable networking for ephemeral Pods

Pods are ephemeral — they get created, destroyed, and rescheduled, and their IPs change every time. A Service gives them a stable IP and DNS name, and load-balances traffic across whichever Pods currently exist.

Client Service Stable IP / DNS Distributes traffic Pod Pod Pod

Pods come and go behind the scenes; the Service address never changes.

The four Service types

Type Use Accessible from Description
ClusterIP Internal communication Inside the cluster Default type. Cluster-internal IP only.
NodePort Expose on each Node’s IP Outside, via Node IP : Port Opens a static port on every Node.
LoadBalancer Expose to external traffic Outside, via cloud LB Provisions a cloud provider load balancer.
ExternalName Map to an external domain Inside the cluster Maps the Service to a DNS name outside the cluster.
ClusterIP Client (in) Service Pod Pod Pod cluster-only NodePort Client (out) Node IP:Port Service Pod Pod Pod via node IP + port LoadBalancer Client (out) Cloud LB Service Pod Pod Pod via cloud provider LB ExternalName Client (in) Service external-domain.com DNS alias, no proxying

Same idea, four different reach — from cluster-internal only to a mapped external DNS name.

📎

Worked example — ClusterIP: Service name my-service, ClusterIP 10.96.0.15, port 80, target port 8080. A client inside the cluster hits my-service:80, and the Service load-balances that to port 8080 on one of the matching Pods.
06Networking

Ingress: smart routing at Layer 7

A LoadBalancer or NodePort Service exposes one application. Ingress sits in front of many Services behind a single entry point, routing by hostname or path — at the HTTP layer, not just TCP/UDP.

Internet Ingress Ingress Controller e.g. Nginx, Traefik implements the rules

app.example.com/api app.example.com/web admin.example.com/

Service: api Service: web Service: admin

Pods Pods Pods

One Ingress, one IP, three routing rules — host- and path-based traffic splitting to different backend Services.

Service vs. Ingress

Feature Service Ingress
Layer Layer 4 (TCP/UDP) Layer 7 (HTTP/HTTPS)
Routing Basic, port-based Advanced — host and path-based
SSL/TLS Not handled Can terminate SSL
Usage Exposes one Service Exposes many Services via rules
Requires Nothing extra An Ingress Controller
# list every Ingress across all namespaces
kubectl get ingress -A
# create an Ingress from a YAML manifest
kubectl apply -f ingress.yaml
# inspect the rules on a specific Ingress
kubectl describe ingress my-ingress

In short: Namespaces isolate resources; Ingress routes traffic intelligently to those resources. Different jobs, easy to mix up.
07Configuration

ConfigMaps & Secrets

Both decouple configuration from your container image, so the same image can run in dev, test, and prod without rebuilding it. The difference is sensitivity.

ConfigMap

Stores non-sensitive key–value config — app settings, URLs, feature flags — as plain text.

Secret

Stores sensitive data — passwords, tokens, keys, certificates — Base64-encoded (not encrypted by default).

Feature ConfigMap Secret
Data type Non-sensitive Sensitive
Encoding Plain text Base64-encoded
Purpose Configuration Passwords, keys
Security Less secure More secure (but not encrypted at rest by default)
Consumed as Env vars or mounted files Env vars or mounted files
ConfigMap app.properties = value log.level = value Secret username = dXNlcg== password = cGFzcw== Pod env vars or volume mount

Both feed the same Pod, as environment variables or mounted files — the app doesn’t care which.

⚠️

Watch out: Secrets are Base64-encoded, not encrypted. Anyone who can read the Secret object can decode it instantly — enable encryption at rest in etcd for real protection.
08Storage

Volumes, Persistent Storage & StorageClasses

Containers are ephemeral — delete one, and everything inside it is gone. Volumes give Pods storage that survives container restarts and deletions.

Pod Container /app/data Volume Data persists even if the container is deleted.

Volume types

Type What it does
emptyDir Temporary storage; deleted when the Pod is removed
hostPath Mounts a file or directory from the host node (use with caution)
nfs Mounts an NFS share
configMap Mounts a ConfigMap as files
secret Mounts a Secret as files
persistentVolumeClaim Uses persistent storage (PV) — the production choice

How PV, PVC, and StorageClass fit together

AdminCreates a StorageClass
UserCreates a PVC (request for storage)
Dynamic ProvisionerCreates a PV automatically
PVC binds to PVRequest matched to actual storage
PodUses the storage

Flow: Pod requests storage → PVC → binds to a PV → Pod uses it.

🗄️

StorageClass describes the “class” of storage you want — e.g. fast-ssd for high performance, standard for general purpose, slow-hdd for backups — and enables dynamic provisioning so a PV doesn’t have to be created manually.
# storage inspection
kubectl get pv
kubectl get pvc
kubectl describe pvc my-pvc
kubectl get storageclass
kubectl describe storageclass fast-ssd
09Organization

Namespaces

A Namespace divides cluster resources between multiple users, teams, or environments. Resources in one namespace are invisible to another by default.

Kubernetes Cluster Namespace 1 Namespace 2 Namespace N Pod Pod Pod Service Other Resources

Pod Pod Pod Service Other Resources

Pod Pod Pod Service Other Resources

A Pod in Namespace 1 cannot directly reach a Pod in Namespace 2 — isolation is the point.

  • The default namespace is literally called default.
  • Namespaces help with isolation and resource management (e.g. quotas per team).
  • Resources in different namespaces are isolated from each other.
# list namespaces, and everything scoped to one
kubectl get ns
kubectl get pods -n my-namespace
10Reliability

Resource management & health checks

Two mechanisms keep a cluster stable under real load: resource requests/limits control how much a container can use, and probes control whether it’s considered healthy.

Requests vs. Limits

What it means
Requests Minimum resources guaranteed; used by the scheduler to place the Pod. If unset, scheduling can be poor.
Limits Maximum resources a container may use. Prevents one noisy container from starving the node. Exceeding it can throttle or kill the container.

The three probes

Liveness Probe

“Is the container running?” — fails it, and Kubernetes restarts the container.

Readiness Probe

“Is it ready to serve traffic?” — fails it, and the Pod is pulled out of Service rotation without being killed.

Startup Probe

“Has the application finished starting up?” — protects slow-starting apps from being killed too early by the liveness probe.

Common labels

Label Meaning
app Name of the application
env Environment — dev, test, prod
tier Tier — frontend, backend
version Version of the application
team Owning team
11Reference

kubectl command reference

Grouped by what you’re actually trying to do, so you can scan straight to the section you need.

Inspecting the cluster

kubectl get pods                    # list all Pods
kubectl get svc                     # list all Services
kubectl get nodes                   # list all Nodes
kubectl get ns                      # list all Namespaces
kubectl describe pod <pod-name>     # full details of a Pod
kubectl logs <pod-name>             # logs of a Pod
kubectl exec -it <pod-name> -- /bin/bash   # shell into a Pod

Deployments & ReplicaSets

kubectl create deployment <name> --image=<image>
kubectl get deployments
kubectl get rs
kubectl describe deployment <name>
kubectl scale deployment <name> --replicas=<n>
kubectl rollout status deployment <name>
kubectl rollout undo deployment <name>
kubectl rollout history deployment <name>

Services & Ingress

kubectl get svc
kubectl get ingress -A
kubectl describe ingress <name>
kubectl apply -f ingress.yaml
kubectl delete ingress <name>

Storage

kubectl get pv
kubectl get pvc
kubectl describe pvc <name>
kubectl delete pvc <name>
kubectl get storageclass
kubectl describe storageclass <name>
🔖

Bookmark this page. Every diagram above maps directly to a command group here — if you forget what a Service does, scroll back to §5; if you forget the syntax, you’re already in the right place.

The one-paragraph version

A Deployment manages a ReplicaSet, which keeps a set of Pods running on Worker Nodes, scheduled and supervised by the Control Plane. A Service gives those Pods a stable address; Ingress routes external traffic to the right Service. ConfigMaps and Secrets inject configuration; Volumes, PVs, and PVCs give it storage that outlives any single container. Namespaces keep it all separated by team or environment.


Leave a Reply

Your email address will not be published. Required fields are marked *