Chapter 15: Kubernetes Introduction
Friends, today we learn Kubernetes — not one server, a cluster manager that restarts failed pods. Pod, Deployment, Service, Namespace, why an orchestrator after Compose, and kubectl get/describe/logs/apply. Do not fear: one kind cluster, one Deployment.
मित्रांनो, आज आपण Kubernetes शिकूया — एक server नाही, cluster manager जो failed pods restart करतो. Pod, Deployment, Service, Namespace, Compose नंतर का orchestrator, आणि kubectl get/describe/logs/apply. घाबरू नका: एक kind cluster, एक Deployment.
दोस्तों, आज हम Kubernetes सीखेंगे — एक server नहीं, cluster manager जो failed pods restart करता है. Pod, Deployment, Service, Namespace, Compose के बाद क्यों orchestrator, और kubectl get/describe/logs/apply. घबराओ मत: एक kind cluster, एक Deployment.
What you will learn in this chapter
- Why orchestrators after Compose
- Pod, Deployment, Service, Namespace
- kubectl get, describe, logs, apply
- Local kind cluster for labs
- Deploy badge API and reach it safely
Concepts in this chapter
- 15.1Why Kubernetes after Compose
- 15.2Primary local tool — kind
- 15.3Core objects — Pod, Deployment, Service, Namespace
- 15.4kubectl everyday verbs
- 15.5Manifest sketch — Deployment + Service for badge API
- 15.6Reaching the app — port-forward (kind-friendly)
- 15.7Rolling update and rollback (light)
- 15.8Probes — readiness vs liveness (awareness)
- 15.9Config and secrets — concepts only
- 15.10Troubleshooting table
- 15.11Security basics (pointer)
- 15.12Anti-patterns
- 15.13Lab — kind cluster, deploy, curl
Review and practice
- ★15.12b Declarative apply vs imperative run
- ★15.12c Resource requests (awareness)
- ★15.12d Loading a local image into kind (common lab snag)
- ★15.12e Namespaces and who can break what
The chapter recap is at the end of the last concept page.
Practice Tasks
Suppose we are on the DevOps team at Amul, the dairy co-operative company, working from Anand. Hetal Patel leads the team, and we look after the milk collection app. Costs are counted in INR. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Amul is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.
0 / 12
Easy List pods in a namespace
Why: Pods are where the app runs; this is your first look.
What to do: List the pods in the namespace amul-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Create a namespace
Why: Namespaces keep teams and environments apart.
What to do: Create the namespace amul-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Pod manifest
Why: Every K8s object starts with apiVersion, kind, metadata and spec.
What to do: Write a Pod named milk-collection with one container app using image amul/milk-collection:1.9.5 and containerPort 3000.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Easy Apply a manifest
Why: Declarative apply keeps the cluster equal to the files in Git.
What to do: Apply the manifest k8s/milk-collection.yaml.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Describe a pod
Why: Events at the bottom of describe explain most crashes.
What to do: Show details and events of the pod milk-collection-7d9f in amul-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Pods with node and IP
Why: Knowing the node helps when one machine is unhealthy.
What to do: List pods in amul-prod with extra columns (node, IP).
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Pods in all namespaces
Why: Cluster-wide views catch problems outside your own namespace.
What to do: List pods across all namespaces.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Apply a whole folder
Why: One command rolls out every manifest of the release.
What to do: Apply every manifest in the folder k8s/ to namespace amul-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Deployment manifest
Why: A Deployment keeps the wanted number of pods alive.
What to do: Write a Deployment milk-collection in namespace amul-prod with 3 replicas, selector and pod label app: milk-collection, container app image amul/milk-collection:1.9.5.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Medium Requests and limits
Why: Requests let the scheduler place pods; limits stop one pod from starving others.
What to do: Write a Pod milk-collection (container app, image amul/milk-collection:1.9.5) requesting cpu 250m and memory 256Mi, limited to cpu 500m and memory 512Mi.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Medium Shell inside a pod
Why: Inside the pod you can test DNS and files directly.
What to do: Open an interactive sh in pod milk-collection-7d9f in amul-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Hard Readiness and liveness probes
Why: Readiness stops traffic to a pod that is not ready; liveness restarts a stuck one.
What to do: Write a Pod milk-collection (container app, image amul/milk-collection:1.9.5) with a readinessProbe httpGet /ready on port 3000 and a livenessProbe httpGet /health on port 3000 with initialDelaySeconds 10.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Ravi Sir's Cards: 37 revision, interview and comparison cards for this chapter · मराठी cards