In Module 1, we learned that Kubernetes is like a city planner for containers, managing them to keep applications running smoothly. Now, we’ll explore the core concepts of Kubernetes—pods, nodes, and clusters—and get hands-on with kubectl
, the tool you’ll use to talk to Kubernetes. By the end of this module, you’ll understand how Kubernetes organizes applications and how to interact with a cluster.
A Kubernetes cluster is like a city where your applications live. It’s made up of multiple servers (called nodes) working together to run your containers. Think of the cluster as the entire city, with different parts handling specific tasks.
A cluster has two main components:
Control Plane: The city hall, which makes decisions and manages the cluster. It’s the brain of Kubernetes, handling tasks like scheduling containers and keeping everything in sync.
Worker Nodes: The buildings where the actual work happens. These nodes run your applications inside containers.
Let’s break down the key pieces of this city.
A pod is the smallest unit in Kubernetes, like an apartment in our city analogy. It’s where one or more containers live. Containers in the same pod share the same resources (like storage and network) and work closely together, like roommates sharing a kitchen.
For example:
Analogy: Think of a pod as a lunch tray holding one or more dishes (containers). The tray makes it easy to move everything together, but if the tray breaks, the kitchen (Kubernetes) replaces it with a new one.
A node is a server (physical or virtual) in the Kubernetes cluster, like a building in our city. Nodes are where pods run. There are two types of nodes:
Control Plane Nodes: These run the components that manage the cluster, like the scheduler (decides where pods go) and the API server (handles communication).
Worker Nodes: These run your application pods. Each worker node has tools like the kubelet (a Kubernetes agent) that talks to the control plane and manages containers.
Fun Fact: A small cluster might have one node acting as both control plane and worker, like a small town where the mayor also runs the local shop. In bigger clusters, these roles are separated.
Let’s put it together with a diagram :
Explanation:
The API Server is like the city’s communication hub. You send commands to it (via kubectl
), and it tells the cluster what to do.
The Scheduler decides which node a pod should run on, based on resources and needs.
The Controller Manager ensures the cluster stays in the desired state (e.g., replacing crashed pods).
etcd is a database that stores the cluster’s configuration, like a city’s record book.
Cloud Controller Manager allows Kubernetes to interact with the underlying cloud provider’s infrastructure. It is not optional if you’re running Kubernetes on a cloud platform like AWS, GCP, Azure, etc., but optional if you’re running Kubernetes on-premises or in an environment that doesn’t rely on a cloud provider’s APIs.
Worker nodes run pods and include the following key components:
kubectl
kubectl
(pronounced “cube control”) is your command-line tool for interacting with Kubernetes, like a walkie-talkie to talk to the city hall. You’ll use it to create, inspect, and manage pods, nodes, and other resources.
Basic Commands:
kubectl get nodes
: Lists all nodes in the cluster.kubectl get pods
: Lists all pods in the current namespace (a way to organize resources, like neighborhoods in a city).kubectl describe pod <pod-name>
: Shows details about a specific pod.Let’s try some kubectl
commands using a free online sandbox. No installation is needed yet—we’ll cover setting up your own cluster later.
Go to Play with Kubernetes (https://labs.play-with-k8s.com/) or Katacoda Kubernetes Playground (https://www.katacoda.com/courses/kubernetes/playground).
kubectl get nodes
kubectl get pods --all-namespaces
kubectl run my-web-pod --image=nginx --restart=Never
This creates a pod named my-web-pod running an Nginx web server. Check it with kubectl get pods. View details with kubectl describe pod my-web-pod.
Note for Beginners: If you’re not ready for hands-on, just follow along. The commands above show how Kubernetes organizes resources. We’ll do more hands-on in later modules.
Answers: 1-C, 2-B, 3-C
kubectl
(https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-intro/)In Module 3, we’ll dive into Containers and Docker Basics, learning how containers are created and why they’re essential for Kubernetes. You’ll try running a container locally or in a sandbox to prepare for deploying apps in Kubernetes.