Core Concepts
Learn the fundamental building blocks of Kubernetes: Pods, Deployments, Services, and Replicasets.
Theory: The Building Blocks
Kubernetes (K8s) doesn't run containers directly; it wraps one or more containers into a higher-level structure called a Pod.
1. Pods
The smallest deployable unit. Usually, 1 Pod = 1 Container. They share network IP, storage, and lifecycle.
2. ReplicaSets & Deployments
If a Pod dies, it doesn't come back. To ensure high availability, you use a ReplicaSet to state "I always want 3 copies of this Pod running". A Deployment is a wrapper around a ReplicaSet that makes updating the application (e.g., v1 -> v2) smooth and rollback-able.
Deep Dive: Kubernetes Architecture
A Kubernetes Cluster consists of a Control Plane (the brain) and Worker Nodes (the muscle). The Control Plane makes global decisions about the cluster, while worker nodes actually run the pods.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Hands-on Labs
Complete the following tasks to master this module. Toggle the checklist items once you successfully run the logic.
kubectl run command.
Interview Prep: Core Concepts
The kubectl client validates the request and sends it to the API server. The API server stores the Pod object in etcd. The Scheduler notices the unassigned pod and assigns it to a Node. The Kubelet on that Node instructs the container runtime (like containerd) to pull the image and start the container.
A container is a runtime instance of an image (like Docker). A Pod is the smallest deployable K8s object, which acts as a wrapper that can encapsulate one or more tightly coupled containers sharing network IP and storage volumes.