CLOUD & INFRASTRUCTURE / SYSTEM CONCEPT BRIEF

Kubernetes

Kubernetes (K8s) is an open-source container orchestrator.

IntermediatePhase 07 / Topic 8 of 17RequirementsTrade-offsFailure modes
01

Overview

Kubernetes (K8s) is an open-source container orchestrator. You declare the desired state (run 5 replicas of this image, expose them on port 80, give each 512 MB of memory) in YAML manifests, and Kubernetes continuously works to make reality match: scheduling pods onto nodes, restarting failures, rolling out new versions, scaling, and routing traffic.

The control plane (API server, etcd, scheduler, controller manager) stores and reconciles state; worker nodes run pods through the kubelet and container runtime. Core objects include Pods, Deployments, Services, Ingress, ConfigMaps, Secrets, and Horizontal Pod Autoscalers. Managed offerings (EKS, GKE, AKS) run the control plane for you.

An air traffic control tower

You file a flight plan (desired state). The tower (control plane) assigns runways and gates (nodes), reroutes planes when something breaks, and keeps everything moving according to plan, without pilots coordinating with each other directly.

02

When to use it

  • Running many containerized services with shared infrastructure.
  • Self-healing, rolling deployments, and autoscaling.
  • Portable deployments across clouds and on-prem.
  • Platform teams offering a standard runtime to developers.
03

Where it shows up in interviews

Microservices platform

Recognize it when: dozens of services, many teams.

  • Design a microservices e-commerce platform
  • Design an internal developer platform
Self-healing and scaling

Recognize it when: services must recover and scale automatically.

  • Design a highly available API
  • Handle traffic spikes on a web app
04

Where it is used in real software

Borg heritage

Kubernetes was open-sourced by Google in 2014, based on its internal Borg system.

Spotify, Airbnb, Pinterest

Run large Kubernetes fleets for most of their services.

CNCF ecosystem

Helm, Argo CD, Prometheus, Istio, and hundreds of projects build on Kubernetes.

05

Key terms

Pod
Smallest deployable unit: one or more containers sharing network and storage.
Deployment
Manages ReplicaSets for stateless apps with rolling updates.
Service
Stable virtual IP and DNS name load balancing to pods.
Ingress / Gateway
HTTP routing from outside into Services.
Controller / reconciliation loop
Watches desired vs actual state and acts to converge.
06

How it works, step by step

  1. 1
    kubectl apply a Deployment

    The API server stores the desired state in etcd.

  2. 2
    Controllers create pods

    The Deployment controller creates a ReplicaSet, which creates pods.

  3. 3
    Scheduler places pods

    On nodes with enough CPU and memory, respecting constraints.

  4. 4
    Kubelet runs containers

    Pulls images, starts containers, runs probes.

  5. 5
    Services route traffic

    To ready pods; controllers keep replacing failures.

Kubernetes reconciliation
Step 1 / 4
kubectl
API server
etcd
Scheduler
Node A
Node B

STEP 1You apply a Deployment with replicas: 3. The API server validates and stores it in etcd.

07

Core Kubernetes objects

What each object is for

Step 1 / 6
ObjectPurposeExample
DeploymentStateless replicas + rolling updatesapi with 5 replicas
StatefulSetStable identity and storageKafka, databases
ServiceStable endpoint to podsapi.default.svc.cluster.local
Ingress / GatewayExternal HTTP routingapi.example.com to api Service
ConfigMap / SecretConfiguration / sensitive valuesFeature flags / DB password
HPAAutoscale replicasScale 3-30 on CPU

NOWObject: Deployment | Purpose: Stateless replicas + rolling updates | Example: api with 5 replicas

Most applications need a Deployment, a Service, an Ingress, config, and an autoscaler.

08

Implementation

apiVersion: apps/v1kind: Deploymentmetadata: { name: api }spec:  replicas: 3  selector: { matchLabels: { app: api } }  strategy: { rollingUpdate: { maxUnavailable: 0, maxSurge: 1 } }  template:    metadata: { labels: { app: api } }    spec:      containers:        - name: api          image: containers.artifactory.tools.bestbuy.com/team/api:abc1234          ports: [{ containerPort: 3000 }]          resources:            requests: { cpu: 250m, memory: 256Mi }            limits: { memory: 512Mi }          readinessProbe: { httpGet: { path: /ready, port: 3000 }, periodSeconds: 5 }          livenessProbe: { httpGet: { path: /health, port: 3000 }, initialDelaySeconds: 10 }          envFrom: [{ secretRef: { name: api-secrets } }]---apiVersion: v1kind: Servicemetadata: { name: api }spec:  selector: { app: api }  ports: [{ port: 80, targetPort: 3000 }]
09

Complexity and performance

Cluster scaleUp to ~5,000 nodes, 150k pods

Upstream tested limits.

Pod rescheduleSeconds to minutes

After node failure detection.

10

Trade-offs

Power vs complexity

Kubernetes solves scheduling, healing, and scaling but has a steep learning curve and operational overhead.

Managed K8s vs simpler platforms

EKS/GKE reduce control plane work; ECS, Cloud Run, or App Runner may be simpler for small teams.

11

Variants and related techniques

Helm and Kustomize

Package and customize manifests.

GitOps (Argo CD, Flux)

Git is the source of truth; controllers sync clusters.

Operators

Custom controllers that manage complex apps like databases.

12

Common mistakes

  • No resource requests and limits.

    Fix: Scheduling becomes unpredictable and noisy neighbors cause OOM kills.

  • Liveness probes that check dependencies.

    Fix: A DB outage restarts every pod; keep liveness simple, use readiness for dependencies.

  • Secrets in plain ConfigMaps.

    Fix: Use Secrets with encryption, or external secret managers.

13

Interview questions

What happens when you run kubectl apply for a Deployment?

The API server validates and stores it in etcd; the Deployment controller creates a ReplicaSet; the ReplicaSet creates pods; the scheduler assigns them to nodes; kubelets start containers; and Services route traffic to ready pods.

Readiness vs liveness probes?

Readiness decides whether a pod should receive traffic; failing removes it from Service endpoints. Liveness decides whether the container should be restarted; failing kills and restarts it.

14

Practice problems

ProblemDifficultyWhat it trains
Deploy an API with a Service and IngressEasyCore objects.
Design a multi-team Kubernetes platformHardNamespaces, RBAC, quotas, GitOps.