Interview Prep/DevOps Fundamentals/Containers & Kubernetes basics

What is Kubernetes, and why do we need it?

BeginnerConceptContainers & Kubernetes basics
Answer

In one line: Kubernetes (K8s) is an open-source platform that runs and manages containers across a cluster of machines — it handles deployment, scaling, self-healing, networking and rolling updates automatically.

Why we need it: running one container with docker run is easy. Running 200 containers across 20 servers is not: which server has space? What if a container crashes at 3 a.m.? How do containers find each other? How do you update without downtime? Kubernetes answers all of these.

What Kubernetes does:

  1. Scheduling — decides which node each container (pod) runs on, based on available resources.
  2. Self-healing — restarts crashed containers, replaces pods on failed nodes, and only sends traffic to healthy pods.
  3. Scaling — scale manually (kubectl scale) or automatically (Horizontal Pod Autoscaler).
  4. Service discovery and load balancing — gives pods stable names (Services + DNS) and spreads traffic.
  5. Rolling updates and rollbacks — update with zero downtime; undo with one command.
  6. Configuration and secrets — ConfigMaps and Secrets injected into pods.
  7. Storage — attaches persistent volumes (EBS, Azure Disk) to pods.
  8. Declarative desired state — you write YAML describing what you want; Kubernetes keeps reality matching it.

Simple example:

apiVersion: apps/v1
kind: Deployment
metadata: { name: orders }
spec:
  replicas: 3
  selector: { matchLabels: { app: orders } }
  template:
    metadata: { labels: { app: orders } }
    spec:
      containers:
        - name: orders
          image: myrepo/orders:1.4.2
          ports: [{ containerPort: 8080 }]

Kubernetes keeps 3 copies running at all times. Delete one pod and a new one appears.

Managed options: EKS (AWS), AKS (Azure), GKE (Google), OpenShift (Red Hat).

Tip for interviews: mention the "desired state" idea and self-healing — they're the core of how Kubernetes works.

All DevOps Fundamentals questions

More on Containers & Kubernetes basics