Ravindra BagaleCourses & study guides मराठी

DevOps

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.

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

  1. 15.1Why Kubernetes after Compose
  2. 15.2Primary local tool — kind
  3. 15.3Core objects — Pod, Deployment, Service, Namespace
  4. 15.4kubectl everyday verbs
  5. 15.5Manifest sketch — Deployment + Service for badge API
  6. 15.6Reaching the app — port-forward (kind-friendly)
  7. 15.7Rolling update and rollback (light)
  8. 15.8Probes — readiness vs liveness (awareness)
  9. 15.9Config and secrets — concepts only
  10. 15.10Troubleshooting table
  11. 15.11Security basics (pointer)
  12. 15.12Anti-patterns
  13. 15.13Lab — kind cluster, deploy, curl

Review and practice

  1. ★15.12b Declarative apply vs imperative run
  2. ★15.12c Resource requests (awareness)
  3. ★15.12d Loading a local image into kind (common lab snag)
  4. ★15.12e Namespaces and who can break what

The chapter recap is at the end of the last concept page.

Practice Tasks

About this scenario

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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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).

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. 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.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Use "- " for list items and fill each value from the task.
  4. Check the colons and spacing, then click Check answer.

Ravi Sir's Cards: 37 revision, interview and comparison cards for this chapter · मराठी cards