Ravindra BagaleCourses & study guides मराठी

DevOps

Chapter 16: Capstone — Ship It End-to-End

Friends, today is the capstone — from laptop code to a health / badge URL. Repo: app + Dockerfile + Compose + Actions sketch, deploy path (SSH/Ansible or kind), README runbook (deploy, rollback, smoke). Do not fear: small steps, daily commits.

What you will learn in this chapter

  • Assemble app, Docker, CI and deploy pieces
  • Write a runbook: deploy, rollback, health
  • Choose one deploy path and finish it
  • Complete a secrets-safe checklist
  • Clean up lab resources the same day

Concepts in this chapter

  1. 16.1Why a capstone — one story you can tell
  2. 16.2Scope — what "done" means
  3. 16.3Suggested repo layout
  4. 16.4Application minimum bar
  5. 16.5CI/CD minimum bar
  6. 16.6Deploy path A — VM + image (SSH or Ansible)
  7. 16.7Deploy path B — kind
  8. 16.8Runbook — the three commands humans need
  9. 16.9End-to-end checklist (print or tick in CHECKLIST.md)
  10. 16.10Demo script (optional homework)
  11. 16.11Common capstone failure modes
  12. 16.12Linking other courses

Review and practice

  1. ★16.12b Definition of done — acceptance demo
  2. ★16.12c Timebox plan (suggested)
  3. ★16.12d Evidence pack (what trainers like)
  4. ★16.12e Honesty over theatre

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 Instagram, the social media company, working from Menlo Park. Daniel Kim leads the team, and we look after the photo upload API. Costs are counted in USD. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Instagram is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.

0 / 12

Easy Push to the registry

Why: The servers pull from the registry, so the image must be there.

What to do: Push registry.instagram.example.com/photo-upload:1.3.6.

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/photo-upload.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 Scale a deployment

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

What to do: Scale deployment photo-upload in instagram-prod to 4 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.

Medium Tag for a registry

Why: A registry push needs the registry address in the image name.

What to do: Add a second name registry.instagram.example.com/photo-upload:1.3.6 to the local image instagram/photo-upload:1.3.6.

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 Deploy only after tests pass

Why: needs makes the deploy job wait for, and depend on, the test job.

What to do: Workflow on push with two jobs on ubuntu-latest: test (run: npm test) and deploy (run: ./deploy.sh us-east-1) that needs test.

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 instagram-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 photo-upload with image instagram/photo-upload:1.3.6 and 3 replicas in instagram-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 Build and push an image from CI

Why: Every merge to main gives a fresh image in the registry.

What to do: Workflow on push to main. Job image on ubuntu-latest. Steps: actions/checkout@v4; docker/login-action@v3 with registry ghcr.io, username ${{ github.actor }}, password ${{ secrets.GITHUB_TOKEN }}; docker/build-push-action@v6 with push true and tags ghcr.io/instagram-photo-upload:${{ github.sha }}.

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 photo-upload (container app, image instagram/photo-upload:1.3.6) 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.

Hard Log in to a registry from CI

Why: Passing the password on stdin keeps it out of shell history and process lists.

What to do: The token is in the variable REG_TOKEN. Log in to registry.instagram.example.com as user ci-bot, reading the password from stdin.

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 Compose: wait for a healthy database

Why: The app crashes if it starts before the database is ready.

What to do: Write compose.yaml: db (mysql:8.0) with a healthcheck whose test is ["CMD", "mysqladmin", "ping", "-h", "localhost"] and interval 10s; app (image instagram/photo-upload:1.3.6) that depends_on db with condition service_healthy.

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 Add a HEALTHCHECK

Why: Docker and orchestrators restart containers that stop answering.

What to do: Write a Dockerfile: FROM instagram/photo-upload:1.3.6, then a HEALTHCHECK every 30s with timeout 3s that runs curl -f http://localhost:5000/health || exit 1.

How:
  1. Start with FROM and the base image.
  2. Set WORKDIR, then COPY files and RUN install steps, one instruction per line.
  3. Add ENV, EXPOSE or USER lines if the task asks.
  4. End with CMD (or ENTRYPOINT) and click Check answer.

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