Guide

Kubernetes keeps a cluster of machines running the containers you declared. You do not say "start three processes on node 7." You say "I want three replicas of this pod, always," and controllers keep working until the cluster matches that wish. That idea, desired state plus continuous reconciliation, is the core of the system. Everything else is vocabulary on top of it.

If you do not know containers yet, start with containers. A pod is one or more containers that share a network address and volumes, running on one node.

Read in order

StepConceptWhat it answers
1The control plane and the reconciliation loopWhat runs the cluster, and how does it keep things running?
2Pods and workload objectsWhich object should run my app: a Deployment, StatefulSet, DaemonSet or Job?
3Services and DNSHow does a client reach a pod whose IP keeps changing?
4Config, storage and labelsWhere do settings, secrets, disks and names live?
5Debugging CrashLoopBackOffA pod keeps crashing. What do you check, in what order?

Common mistakes across the topic

  • Treating pods as permanent. Pods are ephemeral. If a node dies, the pod is gone and a controller makes a new one with a new IP.
  • Running naked pods in production. Nothing recreates a pod that has no controller.
  • Assuming NetworkPolicy works. Without a CNI plugin that supports it, NetworkPolicy objects do nothing and raise no error.
  • Treating Secrets as encrypted. By default they are only base64 in etcd.

Managed or self-managed

For almost every product company, use a managed control plane (EKS, GKE or AKS). The provider runs the control plane, patches it and backs up etcd. Your team owns node pools, networking, add-ons and workload YAML. Build your own control plane only if a platform team's full-time job is running it.

Key takeaways

  • Kubernetes compares desired state in the API with what is running, and acts to close the gap.
  • Pods are ephemeral. Deployments keep replicas. StatefulSets, DaemonSets and Jobs cover sticky identity, per-node agents and batch work.
  • Services give stable names and virtual IPs. Readiness decides who gets traffic.
  • Debug with describe, logs --previous and events before you guess.
  • Use a managed control plane, and spend your effort on workloads and automation.

Further learning

The official concepts docs are the reference for every object on this page.

Kubernetes concepts (official docs)The Concepts section helps you learn about the parts of the Kubernetes system and the abstractions Kubernetes uses to represent your cluster, and helps you obtain a deeper understanding of how Kubernetes works.Kubernetes

Carson Anderson's "Kubernetes Deconstructed" peels the cluster from end-user objects down to controllers, scheduling and networking. It is the best single talk for the mental model above.

Kubernetes Deconstructed: Understanding Kubernetes by Breaking It Down - Carson Anderson, DOMOCNCF [Cloud Native Computing Foundation]