TodayTools

Kubernetes flashcards

Run containers across many machines: declare what you want and the cluster keeps it that way.

Donate
Beginner friendly, starts from zero
Section
How to study
0
KubernetesStart from zero · 1 of 12

What is Kubernetes, in one plain sentence?

Kubernetes is a system that runs your apps across many computers and looks after them: it starts them, restarts them when they crash and moves them when a machine fails.

A tireless manager for your apps, awake all night.

All topics

Kubernetes at a glance

Kubernetes runs your apps across many computers and keeps them running the way you asked.

Like a harbour master who places every container on a ship and sends a new one when one is lost.

Words you will meet

Container
An app packed with everything it needs to run anywhere
Pod
The smallest thing Kubernetes runs, wrapping one container
Node
One computer in the cluster that runs pods
Cluster
A group of computers that Kubernetes manages as one
Manifest
A YAML file that says what you want running
kubectl
The command you type to talk to the cluster
Service
A steady name and address that finds the right pods

The steps

  1. 1. Start from zero (12 cards): What Kubernetes is, why it exists, and the words you need before Core basics.
  2. 2. Core basics (16 cards): Desired state, pods, Deployments, Services, labels and the kubectl moves you use from day one.
  3. 3. Next steps (17 cards): Config and secrets, Service types, traffic in, probes, resources, failure states, rollouts, storage and jobs.
  4. 4. Go deeper (18 cards): Control plane internals, reconciliation, stateful and node-level workloads, autoscaling, placement, security, disruption and delivery.
All 12 cards in Start from zero
What is Kubernetes, in one plain sentence?
Kubernetes is a system that runs your apps across many computers and looks after them: it starts them, restarts them when they crash and moves them when a machine fails.
Before Kubernetes, what happened when a server died at 3 a.m.?
Someone was woken up, logged in to machines one by one, and started the app again by hand. Adding more machines for a busy day was slow, manual work too.
Where do you already meet Kubernetes without seeing it?
Many large streaming, shopping, travel and payment apps run on it behind the scenes. When an app stays up during a huge sale or replaces a broken part in seconds, it is often doing that work.
What is a good everyday picture of Kubernetes?
A harbour master at a busy port. Apps arrive packed in standard boxes, and he decides which ship carries each box, watches them all, and sends a new box if one is lost.
What are a container and an image?
A container is an app packed with everything it needs, so it runs the same on any computer, like a packed lunchbox. An image is the saved recipe you start containers from; Docker is the common tool that builds them.
What are a node, a VM and a cluster?
A node is one computer that runs your apps. It is often a VM, a pretend computer made by software on a bigger machine. A cluster is a group of nodes that Kubernetes manages as one.
What is a pod?
A pod is the smallest thing Kubernetes runs: a wrapper around one container, sometimes with a small helper container beside it. Kubernetes places pods on nodes.
What do manifest, YAML and desired state mean?
A manifest is a file saying what you want, such as three copies of my app. It is written in YAML, a simple text format of names and values. That wish is the desired state, and Kubernetes keeps making it true.
What are an IP address and DNS, in plain words?
An IP address is a computer's number on a network, like a phone number. DNS is the phone book that turns a name such as api into that number.
Your first tiny win: what does this command show?
kubectl is the tool you type to talk to the cluster, get means show me, and pods says what to list. The output shows each pod and that it is Running.
What do you need before you start?
A computer with a terminal (the window where you type commands) and Docker installed. That is enough to run a small practice cluster on your own laptop, with no cloud account or bill.
After this topic, what will you be able to do?
Read and write manifests, run several copies of an app, give it a steady name with a Service, scale it up for a busy day and find out why a pod will not start.
Kubernetes cheatsheet

Look around

  • kubectl get pods -A -o wide All pods with node and IP
  • kubectl get deploy,svc,ing -n billing Several kinds at once
  • kubectl describe pod NAME Details plus events
  • kubectl get pod NAME -o yaml Full live object
  • kubectl top pods --sort-by=memory Live usage (metrics-server)
  • kubectl explain deploy.spec.strategy Field docs from the cluster

Change things

  • kubectl diff -f k8s/ Preview changes
  • kubectl apply -f k8s/ --server-side Declarative apply
  • kubectl apply -k overlays/prod Apply a Kustomize overlay
  • kubectl set image deploy/api api=IMG:2.5.0 Change the image
  • kubectl rollout status deploy/api Wait for a rollout
  • kubectl rollout undo deploy/api Back to previous revision
  • kubectl rollout restart deploy/api Restart pods, e.g. after config change

Debug

  • kubectl logs deploy/api -f --since=10m Follow recent logs
  • kubectl logs POD --previous Logs of the crashed container
  • kubectl exec -it deploy/api -- sh Shell in a pod
  • kubectl port-forward svc/api 8080:80 Local tunnel to a Service
  • kubectl events --types=Warning Recent warnings
  • kubectl debug -it POD --image=busybox --target=api Ephemeral debug container

Access and context

  • kubectl config get-contexts List clusters you can reach
  • kubectl config use-context prod Switch cluster
  • kubectl config set-context --current --namespace=billing Default namespace
  • kubectl auth can-i '*' '*' --as=system:serviceaccount:ns:sa Check permissions
  • kubectl drain NODE --ignore-daemonsets --delete-emptydir-data Empty a node safely
  • kubectl cordon NODE Stop new pods landing on a node

Pod states and what they mean

  • Pending Not scheduled: resources, taints, volumes
  • ContainerCreating Pulling image or mounting volumes
  • ImagePullBackOff Bad name, no pull secret, rate limit
  • CrashLoopBackOff Keeps crashing; check logs --previous
  • OOMKilled (exit 137) Over the memory limit
  • Running 0/1 Ready Readiness probe failing
  • Completed Job pod finished with exit 0
Donate