Kubernetes is a platform for running containerized applications across a cluster of computers. This cheat sheet helps students connect the main Kubernetes objects to the jobs they perform, such as scheduling, networking, scaling, and updating apps. It is useful because Kubernetes has many parts, and clear relationships make troubleshooting and exam review easier.
The core idea is that users describe the desired state of an application, and Kubernetes works to keep the actual state matching it. Pods run containers, Deployments manage repeated Pods, and Services provide stable network access. Commands such as kubectl get pods, kubectl apply -f file.yaml, and kubectl describe service name help inspect and manage resources.
Key Facts
- A cluster is a set of machines that run Kubernetes, with a control plane managing worker nodes.
- The control plane includes the API server, scheduler, controller manager, and etcd database.
- A node is a worker machine that runs Pods using components such as kubelet, kube-proxy, and a container runtime.
- A Pod is the smallest deployable Kubernetes unit and can contain one or more tightly connected containers.
- A Deployment manages replicated Pods and supports rolling updates using the relationship Deployment -> ReplicaSet -> Pods.
- A Service gives Pods a stable network name and IP, even when the actual Pods are replaced.
- A ConfigMap stores nonsecret configuration data, while a Secret stores sensitive values such as passwords or tokens.
- The command kubectl apply -f file.yaml creates or updates Kubernetes resources from a YAML file.
Vocabulary
- Cluster
- A group of machines managed by Kubernetes to run containerized applications.
- Control Plane
- The set of Kubernetes components that makes scheduling decisions and maintains the desired state of the cluster.
- Node
- A worker machine in a Kubernetes cluster that runs Pods and reports its status to the control plane.
- Pod
- The smallest Kubernetes object that can run containers, usually representing one instance of an application.
- Deployment
- A Kubernetes object that manages replicas of an application and updates Pods safely over time.
- Service
- A Kubernetes object that provides stable networking access to a changing set of Pods.
Common Mistakes to Avoid
- Confusing Pods with containers is wrong because a Pod is a Kubernetes wrapper that may contain one or more containers.
- Deleting a Pod managed by a Deployment does not permanently remove the app because the Deployment will usually create a replacement Pod.
- Using a Pod IP for long-term communication is wrong because Pod IPs can change when Pods restart or are replaced.
- Putting passwords in a ConfigMap is unsafe because ConfigMaps are meant for nonsecret configuration data, not sensitive credentials.
- Assuming kubectl create and kubectl apply are always the same is incorrect because apply updates resources declaratively from the saved configuration.
Practice Questions
- 1 A Deployment is configured with replicas: 4. One Pod crashes and is deleted. How many replacement Pods should Kubernetes create?
- 2 A Service routes traffic to 3 healthy Pods. If a rolling update temporarily creates 2 new Pods while 3 old Pods still exist, how many Pods might receive traffic if all 5 match the Service selector?
- 3 Write the kubectl command to display all Pods in the current namespace.
- 4 Explain why a web app should usually be exposed through a Service instead of having users connect directly to individual Pod IP addresses.