Kubernetes
Kubernetes is a declarative scheduler with a reconciliation loop. You describe the desired state, controllers compare it to reality and act. Everything else — pods, deployments, services — follows from that one idea, and that is the idea an interviewer wants to hear first.
The 60-second answer
Section titled “The 60-second answer”Kubernetes runs containers on a cluster of nodes. You submit declarative manifests and controllers continuously reconcile actual state towards them. The unit of scheduling is the pod, one or more containers sharing a network namespace. A deployment manages replica sets to keep N pods running and performs rolling updates; a service gives those pods a stable virtual IP and load-balances across them; an ingress routes external HTTP by host and path. You set requests so the scheduler can place pods and limits to cap them, and add readiness and liveness probes so traffic only reaches healthy pods. HPA adds replicas on metrics. It is right when you have many services and a platform team; it is overkill for one app and three servers.
Objects you must know
Section titled “Objects you must know”| Object | Job |
|---|---|
| Pod | Smallest schedulable unit; containers sharing IP and volumes |
| Deployment | Stateless workloads; manages ReplicaSets and rolling updates |
| StatefulSet | Stable identity and per-pod storage for databases and queues |
| Service | Stable virtual IP and load balancing over pods |
| Ingress | HTTP routing by host and path |
| ConfigMap / Secret | Configuration as env vars or mounted files |
A deployment, annotated
Section titled “A deployment, annotated”apiVersion: apps/v1kind: Deploymentmetadata: { name: api }spec: replicas: 3 selector: matchLabels: { app: api } strategy: type: RollingUpdate rollingUpdate: { maxSurge: 1, maxUnavailable: 0 } template: metadata: labels: { app: api } spec: containers: - name: api image: registry.example.com/api:1.42.0 # never :latest resources: requests: { cpu: "250m", memory: "256Mi" } limits: { cpu: "1", memory: "512Mi" } readinessProbe: httpGet: { path: /healthz, port: 8080 } livenessProbe: httpGet: { path: /livez, port: 8080 }Services and ingress
Section titled “Services and ingress”- ClusterIP (default): reachable only inside the cluster. The normal internal choice.
- NodePort: opens a port on every node. Mostly a building block.
- LoadBalancer: provisions a cloud load balancer per service. Convenient, expensive at scale.
- Headless (
clusterIP: None): DNS returns pod IPs. Used with StatefulSets.
An ingress is routing handled by an ingress controller (NGINX, Traefik, a cloud ALB controller). One load balancer fronts many services.
ConfigMaps and Secrets
Section titled “ConfigMaps and Secrets”ConfigMaps hold non-sensitive configuration. Secrets hold sensitive data — but they are only base64-encoded by default, not encrypted at rest unless you enable encryption in etcd. Anyone with read access to the namespace can decode them.
- Enable encryption at rest and restrict
get secretwith RBAC. - Prefer mounted files over env vars: env vars leak into crash dumps and cannot be rotated without a restart.
- For real secret management use External Secrets Operator, Sealed Secrets or a cloud vault.
Requests, limits and QoS
Section titled “Requests, limits and QoS”- Requests are what the scheduler reserves; they decide placement and schedulability.
- Limits are the ceiling. Exceeding memory gets OOM-killed; exceeding CPU gets throttled.
| QoS class | Condition | Evicted |
|---|---|---|
| Guaranteed | requests == limits for every container | Last |
| Burstable | requests < limits | Middle |
| BestEffort | none set | First |
Probes
Section titled “Probes”- Readiness: should this pod receive traffic? Failing removes it from endpoints without restart.
- Liveness: is the process wedged? Failing restarts it — keep it shallow, because a probe that checks the database turns a blip into a restart storm.
Autoscaling and rollouts
Section titled “Autoscaling and rollouts”HPA adjusts replica count from metrics: CPU and memory need the metrics server, custom metrics need an adapter, and node-level scaling is separate (Cluster Autoscaler or Karpenter). Because HPA scales on the metric you give it, scaling on CPU while the real bottleneck is a connection pool accomplishes nothing. Pair it with a PodDisruptionBudget so node drains cannot take the service below a floor.
When Kubernetes is overkill
Section titled “When Kubernetes is overkill”- One or two services, small team. A managed container service (ECS, Cloud Run, App Runner) or a PaaS gives deploys and scaling without a control plane to operate.
- No platform capacity. Kubernetes is a distributed system you now run: upgrades, certificates, RBAC and networking are ongoing work.
- Serverless fits. Event-driven, spiky, short-lived work belongs on Lambda.
Follow-up questions
Section titled “Follow-up questions”- What happens between
kubectl applyand a running pod? - Why was my pod OOM-killed when memory looked fine?
- Readiness versus liveness — what breaks if you swap them?
- How would you debug a pod stuck in
Pending? InCrashLoopBackOff?
Common traps
Section titled “Common traps”- “Kubernetes is a container runtime”. It orchestrates; containerd or CRI-O runs.
- Confusing a service with an ingress. Services are L4 inside; ingress is L7 entry.
- Believing secrets are encrypted. Base64 is encoding.
- Limits without requests. The scheduler guesses and QoS degrades.