Skip to content
Visual explainer 14h to learn 6 steps

FastAPI → Docker → Actions → Terraform → Kubernetes → Grafana

A public repo with a README diagram that you can walk an interviewer through.

By Invicly Tech, , in Full DevOps with Python. About 14 minutes to read.

Topic 34 of 34

In short

The capstone ties every module into one repo: a tested FastAPI service, built into an image by GitHub Actions, deployed with Helm to Kubernetes on Terraform-built AWS infrastructure, and watched with Grafana.

Explained simply

The capstone is one project that uses everything from this path. You write a small web service in Python with FastAPI, package it with Docker, test and build it automatically with GitHub Actions, create the cloud servers with Terraform, run it on Kubernetes with Helm, and watch it with Grafana.

Think of it as a production line. Code goes in at one end. Each stage checks or packages it and hands it to the next. A running, monitored service comes out at the other end. Your job is to build each stage and connect them.

Do not try to build it all in one weekend. Make the thinnest version work from start to finish first: one endpoint, one test, one image, one deploy. Then improve each stage. A simple pipeline that works beats a fancy one that is half done.

The result is a public repository you can show in interviews. A clear README with a diagram lets you walk someone through the whole system in ten minutes and answer questions about every choice you made.

Press Play on a diagram to walk through it one step at a time.

FlowBuild order
  1. 1
    FastAPI and tests

    Endpoints, /health and pytest passing locally.

  2. 2
    Multi-stage Dockerfile

    Small runtime image, non-root user.

  3. 3
    Actions pipeline

    Lint, test, build, push image tagged with SHA.

  4. 4
    Terraform infra

    VPC, cluster and registry with remote state.

  5. 5
    Helm deploy

    Chart with Deployment, Service, Ingress and probes.

  6. 6
    Grafana dashboards

    Request rate, errors, latency and logs.

  7. 7
    README diagram

    Explain the architecture and how to run it.

LayersFinal architecture
  1. 1
    GitHub repo and Actions

    Code, CI pipeline and image builds.

  2. 2
    Container registry

    Versioned images, tagged by git SHA.

  3. 3
    Kubernetes via Helm

    FastAPI Pods behind a Service and Ingress.

  4. 4
    AWS via Terraform

    VPC, subnets, cluster and IAM roles.

  5. 5
    Prometheus, Loki, Grafana

    Metrics, logs and dashboards across the stack.

CycleThe loop you demo: change, ship, observe
  1. 1
    Open a PR

    Code change plus test

  2. 2
    CI checks

    Lint, pytest, image build

  3. 3
    Merge and push

    Image tagged with the commit SHA

  4. 4
    Helm rollout

    Probes gate the new Pods

  5. 5
    Watch Grafana

    Errors and latency stay flat, or roll back

  6. Back to step 1

In depth

Repository layout: everything as code in one place

Keep the app and its delivery in one repository, so a single pull request can change code, image, chart and infrastructure together and reviewers see the full picture. A clear layout also makes your README easier to write.

Put the Python package in app/ and tests in tests/. The Dockerfile and a .dockerignore sit at the root. The pipeline lives in .github/workflows/. Terraform goes in infra/, split into modules/ (reusable pieces like the VPC) and envs/dev and envs/prod (small root configs with their own state and tfvars). The Helm chart lives in charts/api with one values file per environment. Dashboards are JSON files in observability/dashboards, and alert rules sit next to them.

Add a Makefile or a few scripts with the commands you run most (make test, make build, make deploy-dev). Interviewers notice when a repo can be run by a stranger with three commands from the README.

MapCapstone repository layout
capstone-repo/
  • app/ and tests/
    • main.py with /healthz and /readyz
    • test_api.py with pytest
  • Dockerfile
    • Multi-stage, non-root
    • .dockerignore
  • .github/workflows/
    • ci.yml: lint, test, build, push
    • deploy.yml: helm upgrade
  • infra/
    • modules/vpc
    • envs/dev
    • envs/prod
  • charts/api/
    • templates/
    • values-dev.yaml
    • values-prod.yaml
  • observability/
    • dashboards/*.json
    • alerts.yml

Make the service production-shaped from day one

The service can be tiny, but it should behave like a real one, because every later stage depends on it. Give it two health endpoints. /healthz (liveness) only says the process is alive, and never checks the database, or a database outage would make Kubernetes restart every Pod. /readyz (readiness) checks that the app can serve traffic, for example that the database answers.

Read all settings from environment variables (pydantic-settings is a clean way), so the same image runs in dev and prod with different config. Log JSON to stdout with a request ID, and expose /metrics with a request counter and a latency histogram. Handle SIGTERM gracefully: uvicorn finishes in-flight requests on shutdown, which matters during rolling updates.

Tests come first in the pipeline, so make them fast and independent of the network. FastAPI's TestClient calls the app in-process, and dependency overrides let you swap the real database for a fake one.

  • Liveness: am I alive? Readiness: can I take traffic right now?
  • Same image everywhere; only environment variables differ
  • Pin dependencies in requirements.txt or a lock file for repeatable builds

The pipeline: from merge to running Pods

On every pull request, the workflow runs lint (ruff), tests (pytest) and a Docker build without pushing. On a merge to main it does the same, then pushes the image tagged with the git commit SHA, so every running Pod can be traced to an exact commit. Avoid deploying latest: it hides which version runs and breaks rollbacks.

Do not store AWS access keys in GitHub secrets. Use OpenID Connect (OIDC): the workflow gets a short-lived token from GitHub (it needs permissions: id-token: write), and aws-actions/configure-aws-credentials exchanges it for temporary credentials by assuming an IAM role whose trust policy only allows your repository and branch.

The deploy job then runs aws eks update-kubeconfig and helm upgrade --install with --set image.tag set to the SHA and --wait, so the job fails if the new Pods never become ready. Use a GitHub environment for prod with required reviewers, which gives you a manual approval gate.

SequenceMerge to main, keyless deploy
GitHub Actions
AWS STS
ECR
EKS cluster
  1. 1Lint, test, build image
    GitHub Actions to GitHub Actions: Lint, test, build image
  2. 2AssumeRoleWithWebIdentity (OIDC token)
    GitHub Actions to AWS STS: AssumeRoleWithWebIdentity (OIDC token)
  3. 3Temporary credentials, about 1 hour
    AWS STS to GitHub Actions: Temporary credentials, about 1 hour
  4. 4Push api:SHA
    GitHub Actions to ECR: Push api:SHA
  5. 5helm upgrade --install --set image.tag=SHA --wait
    GitHub Actions to EKS cluster: helm upgrade --install --set image.tag=SHA --wait
  6. 6Nodes pull api:SHA
    EKS cluster to ECR: Nodes pull api:SHA
  7. 7Rollout ready, job passes
    EKS cluster to GitHub Actions: Rollout ready, job passes

Infrastructure with Terraform, and keeping the bill small

Terraform creates the network, the cluster, the registry and the IAM roles. Use well-known registry modules (terraform-aws-modules/vpc/aws and terraform-aws-modules/eks/aws) rather than writing an EKS cluster by hand; they encode many details that are easy to get wrong. Keep state in an S3 bucket with versioning; since Terraform 1.10 the S3 backend can lock with use_lockfile = true, without a DynamoDB table.

Cloud costs are real. In us-east-1, an EKS control plane costs about 0.10 USD per hour (around 73 USD per month) before any nodes, and a NAT gateway about 0.045 USD per hour plus data charges. Use small node types, one NAT gateway in dev, and run terraform destroy when you finish a session. Set an AWS Budget alert on day one.

A fully valid alternative: run Kubernetes locally with kind, and use Terraform only for cheap pieces like the ECR repository and the IAM role for OIDC. Say so in the README; it shows judgment.

CompareWhere to run the cluster
kind on your laptop
  • Free
  • Fast to create and delete
  • No real load balancer or IAM
  • Great for building the chart
EKS via Terraform
  • About 73 USD per month for control plane alone
  • Real ALB, IAM roles and nodes
  • Closest to what employers run
  • Destroy after each session

Telling the story: README and interview walkthrough

The README is the front door. Start with one sentence about what the service does, then the architecture diagram, then a Quick start (run locally with Docker Compose), then How it deploys (the pipeline and the Helm release), then Observability (a screenshot of the dashboard), then Decisions and trade-offs. Draw the diagram with a tool that stores text, such as Mermaid in the README itself, so it can be reviewed and updated like code.

In an interview, follow one change through the system: a developer opens a pull request, CI runs tests, merge pushes an image tagged with the SHA, Helm rolls it out with probes guarding the rollout, and Grafana shows traffic moving to the new version. Then be ready for why questions: why Helm rather than raw manifests, why OIDC instead of keys, how you would roll back (helm rollback), what happens if a Pod crashes, and what you would add next (autoscaling, canary releases, tracing). Honest notes about limitations score better than pretending it is perfect.

  • Include one screenshot of the Grafana dashboard with real traffic
  • List the exact commands to reproduce, and to destroy, everything
  • Write down 3 to 5 decisions with the alternative you rejected

Learn it in 6 short steps

About 2h 20m each. Track them with a timer in your plan.

  1. 1
    Build and test the FastAPI service~2h 20m
  2. 2
    Containerise it with a multi-stage image~2h 20m
  3. 3
    Add a GitHub Actions build pipeline~2h 20m
  4. 4
    Provision infrastructure with Terraform~2h 20m
  5. 5
    Deploy to Kubernetes with Helm~2h 20m
  6. 6
    Add Grafana dashboards and a README diagram~2h 20m

Key points

  • Get each stage working end to end before polishing any single one.
  • Everything is code: app, Dockerfile, workflow, Terraform and Helm chart.
  • A README diagram and clear run steps make the repo easy to walk through.
  • Destroy cloud resources with terraform destroy when you are done to avoid bills.

Key terms

Tap a card to flip it. 0/4 known

Examples

dockerfile
FROM python:3.12-slim AS build
WORKDIR /app
COPY requirements.txt .
RUN pip install --prefix=/install -r requirements.txt

FROM python:3.12-slim
WORKDIR /app
COPY --from=build /install /usr/local
COPY app/ app/
USER 1000
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Multi-stage image for the FastAPI service.

Build the thinnest end-to-end slice first

Step 1: write a FastAPI app with a single /healthz endpoint and one pytest test. Step 2: build the image and run it locally. Step 3: create a kind cluster and load the image into it, so no registry is needed yet. Step 4: create a minimal chart with helm create and set the image to the local tag. Step 5: install and port-forward to prove the whole path works. Only after this slice runs do you add the database, the real pipeline, Terraform and dashboards. Each new stage then breaks one thing at a time.

bash
pytest -q                                   # 1 test passes
docker build -t api:dev .
docker run --rm -p 8000:8000 api:dev        # curl localhost:8000/healthz
kind create cluster --name capstone
kind load docker-image api:dev --name capstone
helm create charts/api                       # then edit values.yaml
helm upgrade --install api charts/api \
  --set image.repository=api --set image.tag=dev --set image.pullPolicy=Never --wait
kubectl port-forward svc/api 8080:80         # curl localhost:8080/healthz

The deploy job in GitHub Actions with OIDC and Helm

Step 1: grant the job permission to request an OIDC token. Step 2: assume the deploy role (its trust policy allows only this repo's main branch). Step 3: log in to ECR and build and push the image tagged with the SHA. Step 4: fetch kubeconfig for the cluster. Step 5: helm upgrade --install with the SHA tag and --wait, so a broken release fails the job. The role ARN and names are placeholders to replace with your own.

yaml
deploy:
  runs-on: ubuntu-latest
  environment: prod
  permissions: { id-token: write, contents: read }
  steps:
    - uses: actions/checkout@v4
    - uses: aws-actions/configure-aws-credentials@v4
      with: { role-to-assume: "arn:aws:iam::123456789012:role/gha-deploy", aws-region: us-east-1 }
    - id: ecr
      uses: aws-actions/amazon-ecr-login@v2
    - run: |
        IMAGE=${{ steps.ecr.outputs.registry }}/api:${{ github.sha }}
        docker build -t "$IMAGE" . && docker push "$IMAGE"
        aws eks update-kubeconfig --name capstone --region us-east-1
        helm upgrade --install api charts/api -n prod --create-namespace -f charts/api/values-prod.yaml \
          --set image.repository=${{ steps.ecr.outputs.registry }}/api --set image.tag=${{ github.sha }} --wait

Quick reference

  • Get one thin slice working end to end before improving any single stage
  • Tag images with the git SHA; never deploy latest
  • Use GitHub OIDC with an IAM role instead of storing AWS keys as secrets
  • /healthz for liveness (process only), /readyz for readiness (dependencies)
  • helm upgrade --install ... --wait fails the job if new Pods never become ready
  • helm history api lists revisions; helm rollback api 3 returns to revision 3
  • Set an AWS Budget alert on day one and run terraform destroy after each session
  • README order: what it does, diagram, quick start, deploy, observability, decisions

Common mistakes

  • Building everything at once and debugging five broken layers together.
  • Leaving a cluster and NAT gateway running for weeks and getting a surprise bill.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Why should the liveness probe not check the database?

Question 2

2What is the main benefit of tagging images with the git commit SHA?

Question 3

3How should the GitHub Actions workflow authenticate to AWS?

Question 4

4Which order of work is most likely to succeed?

Question 5

5What does --wait add to helm upgrade --install in the deploy job?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Add /healthz and /readyz endpoints to the FastAPI app and a pytest test for each.

  2. Exercise 2medium

    Write values-dev.yaml and values-prod.yaml for the chart so dev runs 1 replica with small limits and prod runs 3 replicas with larger limits, then install dev.

  3. Exercise 3hard

    Write a Python smoke test that the pipeline runs after deploy: it calls /healthz and /readyz on the public URL, retries for up to 2 minutes, and exits non-zero on failure so the job can trigger helm rollback.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Do I need to pay for AWS to finish the capstone?
Not necessarily. You can run the cluster locally with kind and use Terraform only for low-cost pieces, or create the EKS stack for a few hours and destroy it. Set a budget alert either way.
How long does the capstone take?
Plan for around 14 focused hours if you have done the earlier modules, more if you debug cloud networking for the first time. Getting the thin slice working usually takes the first third.
What do interviewers look for in a DevOps portfolio project?
A repo they can understand quickly: a clear diagram, reproducible commands, automated tests and deploys, secrets handled properly, and honest notes about trade-offs and next steps.
Should I use Helm or plain Kubernetes manifests?
Write plain manifests first so you understand them, then convert to a Helm chart for per-environment values and easy rollbacks. Mentioning that you know both is a plus.
ShareXLinkedInWhatsApp