Skip to main content

Kubernetes Ep 1: Introduction to Kubernetes & Containers

Rachmat Hidayat
Author
Rachmat Hidayat
Learn & sharing insights on TypeScript, Go, Kubernetes, DevOps, DevSecOps, SRE, Platform Engineering, AI/ML Engineering, and MLOps.
kubernetes - This article is part of a series.
Part 1: This Article
The evolution of modern infrastructure has transitioned from physical bare-metal servers to Virtual Machines (VMs), lightweight OCI Containers, and ultimately automated Container Orchestration platforms like Kubernetes.

TL;DR (Quick Summary)
#

  • Bare Metal to Containers: Virtualization abstracted hardware into guest OSs, while containerization abstracts the Operating System kernel to run isolated user-space processes.
  • Why Containers Alone Aren’t Enough: Docker runs individual containers on a single host. In production, you need self-healing, multi-node scheduling, automatic scaling, load balancing, and zero-downtime deployments.
  • What is Kubernetes?: K8s is an open-source, declarative container orchestration platform originally designed at Google (Borg) and hosted by CNCF.
  • Key K8s Capabilities: Automatic bin packing, self-healing, service discovery & load balancing, automated rollouts & rollbacks, storage orchestration, and secret/configuration management.

1. The Infrastructure Evolution
#

To appreciate why Kubernetes exists, we must trace how application deployment architectures evolved over the last two decades.


graph LR
    A["Traditional Deployment
(Bare Metal)"] --> B["Virtualized Deployment
(Hypervisors / VMs)"] B --> C["Containerized Deployment
(Docker / Containerd)"] C --> D["Orchestrated Deployment
(Kubernetes Cluster)"]

Bare-Metal Physical Servers
#

In traditional deployments, applications ran directly on physical hardware.

  • Drawbacks: Resource allocation issues (one app hogging CPU/RAM), slow provisioning times (weeks to order hardware), expensive maintenance, and configuration drift.

Virtual Machines (VMs)
#

Hardware virtualization allowed multiple Guest Operating Systems to run on a single physical host managed by a Hypervisor (e.g., VMware, KVM).

  • Drawbacks: Heavy overhead. Each VM requires its own complete guest OS kernel, virtual disk image, and dedicated RAM allocation.

Containerization
#

Containers leverage Linux Kernel features—specifically namespaces (for isolation) and cgroups (control groups for resource limiting)—to run isolated user-space processes sharing the host kernel.

  • Benefits: Near-zero startup latency (milliseconds), minimal RAM footprint, portable image layers (OCI format), and consistent environments across dev, staging, and production.

2. VM vs Container Architecture Comparison
#

MetricVirtual Machine (VM)Container (OCI / Docker)
Abstraction LayerHardware level (Hypervisor)OS Kernel level (Namespaces/cgroups)
Guest OSFull OS per VM (Ubuntu, RHEL, Windows)Shared host OS kernel
Startup TimeMinutesMilliseconds to seconds
Disk SizeGigabytes (GBs)Megabytes (MBs)
Performance OverheadHypervisor translation penaltyNear-native bare-metal speed
IsolationHard hardware-level security boundaryProcess-level namespace isolation

3. Why Do We Need Container Orchestration?
#

Running docker run on a developer laptop is simple. But running hundreds of microservices across a cluster of servers in production introduces complex operational challenges:

Problem: "What happens when Host Node 3 crashes at 3:00 AM?"
Docker Alone: Containers running on Host Node 3 die and remain offline.
Kubernetes: Automatically detects node failure, reschedules containers onto healthy nodes, updates load balancers, and restores desired state within seconds.

Challenges Solved by Kubernetes
#

  1. Multi-Node Scheduling: Intelligently deciding which server node has enough CPU and memory to host a new container instance.
  2. Self-Healing: Automatically restarting crashed containers, replacing unresponsive nodes, and re-routing traffic away from failing pods.
  3. Automated Scaling: Scaling container replicas up or down based on CPU utilization, memory thresholds, or custom metrics.
  4. Service Discovery & Load Balancing: Exposing containers with single DNS endpoints and distributing incoming HTTP/TCP requests across healthy replicas.
  5. Declarative State Management: You define what state you want (e.g., “Keep 5 instances of NGINX running”), and Kubernetes continuously works to align actual state with desired state through control loops.

4. The Declarative Model & Reconcile Loop
#

Unlike imperative scripts that execute step-by-step commands (do A, then do B), Kubernetes operates on a declarative paradigm.


graph TD
    A["User submits YAML Manifest
(Desired State: replicas=3)"] --> B["API Server stores spec in etcd"] B --> C["Controller Reconcile Loop"] C -->|Compare| D{"Actual State == Desired State?"} D -- Yes --> E["Sleep & Monitor"] D -- No --> F["Take Action:
Spin up / terminate Pods"] F --> C

You submit a YAML manifest specifying your desired state. The Kubernetes Controller Manager continuously runs reconciliation loops comparing actual cluster state to desired state, taking corrective actions automatically.


5. Summary & Next Steps
#

In this episode, we learned how containerization solved OS overhead and how Kubernetes solves multi-node container management at scale.

In Episode 02: Architecture - Control Plane & Worker Nodes, we will dive deep under the hood to inspect the core components that make Kubernetes work: kube-apiserver, etcd, kube-scheduler, kube-controller-manager, kubelet, and kube-proxy.

kubernetes - This article is part of a series.
Part 1: This Article