Ravindra BagaleCourses & study guides मराठी

Chapter 18: Kubernetes Workloads

Chala mitrano, aaj aapan Kubernetes workloads: Pod, ReplicaSet, Deployment, DaemonSet, StatefulSet, Job. Khara kaam madhe YAML madhe kind: Deployment. HPA pan ithe. Ghabru naka: pratyek object ek chota example.

What you will learn in this chapter

  • Why one Docker host is not enough at Netflix or Infosys scale
  • Pod phases, and why a bare Pod is only a lab
  • ReplicaSet, the older ReplicationController, and Deployment
  • DaemonSet, StatefulSet, Job and CronJob
  • kubectl get, describe, logs and delete
  • How a Service spreads traffic, and the HorizontalPodAutoscaler
  • Safety: privileged, requests, namespaces

Concepts in this chapter

  1. 18.1Why Kubernetes — Compose does not survive a dead host
  2. 18.2What this solves that Docker alone does not
  3. 18.3A Pod, and the phase you can quote
  4. 18.4Bare Pod — lab only, dies and stays dead
  5. 18.5ReplicaSet — keep N Pods
  6. 18.6ReplicationController — the older name
  7. 18.7Deployment — the YAML you actually open
  8. 18.8DaemonSet — one per node
  9. 18.9StatefulSet — stable name and disk
  10. 18.10Job and CronJob
  11. 18.11kubectl get, describe, logs, delete
  12. 18.12The Service spreads traffic across ready Pods
  13. 18.13Autoscaling — HPA, and two names to recognise
  14. 18.14Safety basics
  15. 18.15Lab — Deployment, not a bare Pod

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 Grab, the ride hailing company, working from Singapore. Wei Ling Tan leads the team, and we look after the fare estimate service. Costs are counted in SGD. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Grab is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.

0 / 12

Easy Scale a deployment

Why: More replicas handle a sale-day traffic spike.

What to do: Scale deployment fare-estimate in grab-prod to 2 replicas.

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 Apply a manifest

Why: Declarative apply keeps the cluster equal to the files in Git.

What to do: Apply the manifest k8s/fare-estimate.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 Watch a rollout

Why: CI should wait until the new pods are ready.

What to do: Watch the rollout status of deployment fare-estimate in grab-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 Update the image

Why: Changing the image starts a rolling update with no downtime.

What to do: Set the container app of deployment fare-estimate in grab-prod to image grab/fare-estimate:1.8.8.

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 Requests and limits

Why: Requests let the scheduler place pods; limits stop one pod from starving others.

What to do: Write a Pod fare-estimate (container app, image grab/fare-estimate:1.8.8) 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 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 grab-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 Create a deployment quickly

Why: Imperative create is handy for a quick test.

What to do: Create a deployment fare-estimate with image grab/fare-estimate:1.8.8 and 3 replicas in grab-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 fare-estimate in namespace grab-prod with 3 replicas, selector and pod label app: fare-estimate, container app image grab/fare-estimate:1.8.8.

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 Roll back a deployment

Why: A bad release must be undone in seconds.

What to do: Roll deployment fare-estimate in grab-prod back to the previous revision.

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 Autoscale on CPU

Why: Autoscaling adds pods at peak and saves money at night.

What to do: Autoscale deployment fare-estimate in grab-prod between 2 and 10 pods at 70% CPU.

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 HPA manifest

Why: Autoscaling rules in Git are reviewed and repeatable.

What to do: Write an autoscaling/v2 HorizontalPodAutoscaler fare-estimate targeting Deployment fare-estimate, minReplicas 2, maxReplicas 10, CPU utilization 70%.

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.

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 fare-estimate (container app, image grab/fare-estimate:1.8.8) with a readinessProbe httpGet /ready on port 5000 and a livenessProbe httpGet /health on port 5000 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: 33 revision, interview and comparison cards for this chapter · मराठी cards