Lesson 1 of 11 · 11 min · Core objects

Kubernetes architecture and Pods

Covers: Kubernetes 1.34 (k3s); kubectl 1.34. Updated 13 Nov 2026. Part of the DevOps Engineer roadmap.

What you will learn

  • The problem Kubernetes solves
  • Control plane and node components
  • The declarative model and reconciliation loops
  • Pods: containers that share a network and storage
  • The kubectl commands for creating, inspecting and debugging objects

In simple words

Docker runs containers on one machine. A real product needs many containers on many machines, restarted when they crash and moved when a machine dies. Kubernetes is the manager that does this. You tell it what you want, such as "three copies of my app", and it keeps working until that is true.

Words to know

  • Cluster: the group of machines that Kubernetes manages as one.
  • Node: one machine in the cluster.
  • Pod: the smallest thing Kubernetes runs: one container, or a few that belong closely together.
  • kubectl: the command you use to talk to Kubernetes.
  • Desired state: what you asked for. Kubernetes keeps comparing it with what is really running.

Why Kubernetes

Docker runs containers on one machine. Real systems need many containers on many machines, with:

  • scheduling (which machine has room for this container?),
  • self-healing (restart what crashes; replace what is on a dead machine),
  • scaling (more copies when busy),
  • service discovery and load balancing (how do containers find each other as they move?),
  • rolling updates and rollbacks,
  • configuration and secrets management,
  • storage attachment.

Kubernetes (K8s) is the open-source system that does all of this. You tell it what you want (three copies of this image, reachable on port 80) and it works continuously to make reality match. It runs anywhere: managed services (Amazon EKS, Google GKE, Azure AKS), on-premises, or locally for learning (kind, minikube, k3s).

Architecture

A cluster has a control plane (the brains) and worker nodes (the muscle).

                 ┌───────────────── control plane ─────────────────┐
 kubectl ───────▶│ API server ◀──▶ etcd (the cluster's database)   │
                 │     ▲        scheduler    controller manager    │
                 └─────┼───────────────────────────────────────────┘
                       │ watches / reports
        ┌──────────────┴───────────────┐   ┌─────────────────────┐
        │ node 1: kubelet, kube-proxy, │   │ node 2: ...          │
        │ container runtime, [Pods]    │   │                     │
        └──────────────────────────────┘   └─────────────────────┘

Control plane:

  • kube-apiserver: the front door. Everything (kubectl, controllers, nodes) talks to the cluster through this REST API. It authenticates, authorises and validates requests.
  • etcd: the consistent key-value store holding all cluster state. Back it up (or use a managed control plane that does).
  • kube-scheduler: picks a node for each new Pod, based on resource requests, constraints, affinities and taints.
  • kube-controller-manager: runs the controllers, loops that make actual state match desired state (Deployment, ReplicaSet, Node, Job controllers and more).

On each node:

  • kubelet: the agent. It watches for Pods assigned to its node and tells the container runtime to run them, runs probes, and reports status.
  • Container runtime: containerd or CRI-O (Docker Engine is no longer needed; images are the same OCI images).
  • kube-proxy: programs the node's network rules so that Services work.
  • Plus add-ons: CoreDNS (cluster DNS), a CNI network plugin, and often an ingress controller and metrics.

In our lab (k3s) all of this runs on one node; kubectl get pods -n kube-system shows coredns, the storage provisioner and more running as ordinary Pods.

The declarative model

You do not issue commands like "start 3 containers". You submit objects describing the desired state (usually as YAML), and controllers reconcile reality:

desired state (in etcd)  ──compare──  actual state (what is running)
        └────────── controller acts to close the gap, forever ───────┘

If a Pod dies, the controller sees "3 wanted, 2 exist" and creates another. This is why Kubernetes is called self-healing. It is also why you change things by editing the desired state (kubectl apply) rather than fixing instances by hand: manual changes get reverted. Keep manifests in Git (GitOps) so the repository is the source of truth.

Every object has: apiVersion, kind, metadata (name, namespace, labels) and spec (desired state). The system fills in status (actual state). Labels are key-value tags; selectors use them to group objects (a Service finds its Pods by label). That loose coupling is central to Kubernetes.

The Pod

A Pod is the smallest thing Kubernetes runs: one or more containers that are scheduled together onto one node and share:

  • one network namespace: one IP address, and localhost between the containers,
  • optionally volumes,
  • a lifecycle (they start and stop together).

Most Pods have one container. A second container (a sidecar) is used for helpers such as log shippers or proxies. We created a Pod with an nginx container and a sidecar:

apiVersion: v1
kind: Pod
metadata:
  name: multi
  labels:
    app: demo
spec:
  containers:
    - name: app
      image: nginx:1.27-alpine
    - name: sidecar
      image: busybox:1.36
      command: ["sh", "-c", "while true; do echo sidecar tick; sleep 5; done"]
kubectl apply -f pod.yaml
kubectl get pod multi
NAME    READY   STATUS    RESTARTS   AGE
multi   2/2     Running   0          37s

2/2 means both containers are ready. Show logs and run a command in one named container (-c):

kubectl logs multi -c sidecar            # -> sidecar tick
kubectl exec multi -c app -- ps          # nginx master is PID 1 in its container

The sidecar can reach nginx on localhost because the containers share the Pod's network namespace:

kubectl exec multi -c sidecar -- wget -qO- http://localhost:80   # returns the nginx welcome page

Pods are ephemeral

Pods are cattle, not pets. Each Pod gets its own IP, but when it dies it is gone and a replacement gets a different IP. Deleting a bare Pod ends it for good (kubectl delete pod web, then NotFound): nothing recreates it. So you almost never create bare Pods in production; you use a Deployment (next lesson), which creates and replaces Pods for you. Run bare Pods only for quick tests and debugging.

Other things worth knowing:

  • Pod phases: Pending (accepted, not yet running), Running, Succeeded, Failed. kubectl get also shows reasons such as ContainerCreating, CrashLoopBackOff, ImagePullBackOff (troubleshooting lessons).
  • Init containers run to completion before the main containers (wait for a database, run migrations).
  • restartPolicy (Always by default) controls restart of containers within the Pod.
  • A Pod runs on one node; it is never split.

kubectl essentials

kubectl is the command-line client. It reads cluster credentials from ~/.kube/config (a kubeconfig with clusters, users and contexts; kubectl config get-contexts, use-context).

kubectl get pods                       # list (-A all namespaces, -o wide more columns, -w watch, -l app=web by label)
kubectl get pod multi -o yaml          # the full object, including status
kubectl describe pod multi             # human-readable details and EVENTS (your best debugging view)
kubectl logs multi -c app -f           # logs (--previous for the last crashed container)
kubectl exec -it multi -- sh           # a shell inside
kubectl apply -f manifest.yaml         # create or update from a file (declarative)
kubectl delete -f manifest.yaml
kubectl explain pod.spec.containers    # built-in documentation of every field
kubectl api-resources                  # all object kinds (69 in our small cluster)
kubectl run x --image=nginx:1.27-alpine --dry-run=client -o yaml   # generate a starting manifest

--dry-run=client -o yaml prints the YAML that a command would create, a fast way to write manifests. kubectl diff -f file.yaml shows what an apply would change. Short names: po (pods), deploy, svc, ns, cm, pv, pvc.

Events at the bottom of kubectl describe told the story of our first Pod: Scheduled (assigned to a node by the scheduler), Pulling (kubelet fetching the image), then Created and Started. Read events in order whenever something does not start.

Managed Kubernetes and what you operate

With EKS/GKE/AKS the provider runs the control plane; you manage node groups (or use serverless nodes), upgrades, add-ons, access (IAM), networking and your workloads. Self-managing control planes (kubeadm, kops) is a large operational commitment. Kubernetes is powerful and complex: for a small app, a managed container service or even Docker Compose on a VM may be the better choice. Learn it because the industry uses it, and use it where its scale and features pay for the complexity.

Common mistakes

  • Running bare Pods that nobody restarts.
  • Treating Pod IPs as stable. Use Services.
  • Editing live objects by hand (kubectl edit) without updating Git, so the next apply reverts the fix or hides drift.
  • Putting many unrelated containers in one Pod. Containers that scale independently belong in separate Pods.
  • latest image tags. The same problem as in Docker, worse at scale.
  • Forgetting the namespace (-n) and thinking objects are missing.

Try it yourself

  1. Start a local cluster (kind, minikube or k3s). Run kubectl get nodes and kubectl get pods -A.
  2. Create the two-container Pod above, show logs of each container and prove the sidecar reaches nginx on localhost.
  3. Delete the Pod and confirm nothing recreates it.
  4. Use kubectl explain to find what restartPolicy accepts, and --dry-run=client -o yaml to generate a Pod manifest.

Check yourself

What does the kube-scheduler do, and what does the kubelet do?

The scheduler chooses a node for each unscheduled Pod. The kubelet on that node runs the Pod's containers via the container runtime, runs probes and reports status.

What does it mean that Kubernetes is declarative?

You describe the desired state and controllers continually reconcile the actual state to match, instead of you issuing step-by-step commands.

What do containers in the same Pod share?

The network namespace (one IP, localhost) and any volumes mounted into them; they are scheduled together and share a lifecycle.

Why shouldn't you run production workloads as bare Pods?

Nothing recreates a bare Pod if it or its node dies. Controllers such as Deployments create replacements and keep the desired number running.

Interview questions

Explain what happens when you run kubectl apply -f deployment.yaml.

kubectl sends the object to the API server, which authenticates, authorises and validates it and stores it in etcd. The Deployment controller creates a ReplicaSet, which creates Pods; the scheduler assigns each Pod to a node; the kubelet there pulls the image and starts the containers and reports status back.

What is etcd and why does it matter?

The distributed key-value store holding all cluster state. If it is lost without a backup, the cluster's configuration is lost, so it must be backed up and highly available.

What are labels and selectors for?

Labels are key-value tags on objects; selectors choose objects by label. Services, Deployments, NetworkPolicies and more use them to find their Pods.

Summary

  • Kubernetes runs containers across machines with scheduling, self-healing, scaling, discovery and rollouts.
  • Control plane: API server, etcd, scheduler, controllers. Nodes: kubelet, runtime, kube-proxy.
  • You declare desired state; controllers reconcile; labels and selectors connect objects.
  • A Pod is one or more containers sharing a network and lifecycle; Pods are ephemeral, so use controllers.

Going deeper

See how much of this you can explain

A free mock interview asks you new questions on Kubernetes for DevOps Engineer and scores every answer, with what to fix.