DevOps

Kubernetes

Kubernetes is a container orchestration system that deploys, scales and heals applications across a cluster of servers.

What it is

Kubernetes was created at Google from experience with its internal system Borg, open sourced in 2014 and handed to the CNCF. It became the standard for container orchestration and the first CNCF project to reach graduated status (2018).

You describe the desired state in YAML (a Deployment: 3 replicas of this image), and controllers keep reconciling reality to it: restart crashed pods, spread them across nodes, run rolling updates. Services and Ingress handle networking, ConfigMaps and Secrets handle configuration.

It is powerful but complex. Many teams choose managed Kubernetes (EKS, GKE, AKS) instead of running their own cluster.

Use it when

  • You have many services that must scale and update without downtime.
  • You need self-healing, rolling updates and declarative configuration.
  • The team can invest in a platform, or you have a managed cluster.
  • You need portability across clouds and own servers.

Avoid it when

  • You have one or two apps: Docker Compose, a PaaS or serverless is simpler and cheaper.
  • A small team without time to operate a cluster.
  • You need to ship an MVP quickly.

Key concepts

Pod
The smallest deployable unit: one or more containers sharing network and storage.
Deployment
Describes the desired number of pod replicas and the update strategy.
Service / Ingress
A Service gives a stable address to a set of pods, Ingress routes external HTTP traffic.
Control loop
A controller compares desired and actual state and fixes the difference.
Namespace
A logical partition of a cluster to isolate teams or environments.

Example

A Deployment with three replicas: Kubernetes keeps them alive and updates them gradually.

Cheat sheet

Kubernetes cheat sheet
Command or codeWhat it does
kubectl get pods -APods in all namespaces
kubectl apply -f deployment.yamlApply a manifest
kubectl describe pod my-podPod details and events
kubectl logs -f my-podFollow pod logs
kubectl exec -it my-pod -- shShell inside a pod
kubectl port-forward svc/web 8080:80Forward a service port to local
kubectl scale deployment web --replicas=3Change the replica count
kubectl rollout status deployment/webRollout status
kubectl rollout undo deployment/webRoll back to the previous version
kubectl get events --sort-by=.lastTimestampLatest cluster events
kubectl delete -f deployment.yamlDelete resources from a manifest

How to learn it

  1. Master Docker first: Kubernetes runs containers, so images and Dockerfiles must already be familiar.
  2. Take the Kubernetes basics course on ShortLesson and start a local cluster with kind, minikube or Docker Desktop.
  3. Learn the objects: Pod, Deployment, Service, and deploy your app from a YAML manifest with kubectl apply.
  4. Add a ConfigMap and a Secret, environment variables and readiness and liveness probes.
  5. Set up an Ingress for external access and resource requests and limits for containers.
  6. Learn to debug: kubectl describe, logs, events, and work through CrashLoopBackOff and ImagePullBackOff.
  7. Try Helm for templating and a rolling update with a rollback (rollout undo).
  8. Read about StatefulSet, PersistentVolume, RBAC and GitOps (Argo CD) once you reach a production cluster.

Interview questions

  1. 1. What is a pod and why, if we have containers?

    A pod is a group of containers that always run together on one node and share network and volumes. That allows a main container with a sidecar, for example for logs or a proxy.

  2. 2. How does a Deployment differ from a StatefulSet?

    A Deployment is for stateless apps where pods are interchangeable. A StatefulSet gives pods stable names and their own volumes, so it fits databases and brokers.

  3. 3. How do liveness and readiness probes work?

    Liveness checks whether a container is alive and restarts it on failure. Readiness checks whether it can accept traffic: until ready, the Service sends it no requests.

  4. 4. How does Kubernetes do a rolling update?

    It creates pods of the new version, waits for their readiness and gradually removes old ones within maxSurge and maxUnavailable. If something goes wrong, you can roll back.

Interview questions from the bank

Comparisons with this technology

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).