Skip to content

Lab 12 submission - Advanced Kubernetes Resilience#361

Open
N1qro wants to merge 38 commits into
inno-devops-labs:mainfrom
N1qro:feature/lab12
Open

Lab 12 submission - Advanced Kubernetes Resilience#361
N1qro wants to merge 38 commits into
inno-devops-labs:mainfrom
N1qro:feature/lab12

Conversation

@N1qro

@N1qro N1qro commented Jul 17, 2026

Copy link
Copy Markdown

Lab 12 - Advanced Kubernetes Resilience

  • Task 1 done - Scaled the application services, added four PodDisruptionBudgets, configured gateway topology spreading, and verified failover and eviction blocking.
  • Task 2 done - Added graceful gateway shutdown behavior and applied a concurrent PostgreSQL index migration under live load.
  • Bonus Task done - Executed the complete expand-and-contract rename from event_date to scheduled_at with three migrations and two events-service deploys.
  • Optional HPA observation not completed.

Summary

  • Scaled events, payments, and notifications to two replicas
  • Added PDBs for gateway, events, payments, and notifications
  • Added gateway topology spreading, preStop, readiness, and termination-grace settings
  • Verified zero gateway 5xx during pod failure and gateway restart tests
  • Added CREATE INDEX CONCURRENTLY migration with Alembic autocommit
  • Executed the five-step expand-and-contract migration under mixed load
  • Preserved the existing events API response while moving the database to scheduled_at
  • Verified the final schema, migration rollback path, seed compatibility, and zero 5xx delta
  • Documented commands, outputs, observations, and design answers in submissions/lab12.md

N1qro and others added 30 commits June 12, 2026 17:34
Lab 1 submission - deploy, break, understand
Lab 2 submission - inspect, optimize, trace
Lab 3 submission - monitor, observe, define SLOs
Lab 4 submission - deploy, probe, helm
Lab 5 submission - CI/CD, GitOps, rollback
Lab 6 submission - alerting, responding
Fix CI manifest update push race
Lab 7 submission - Progressive Delivery
Lab 8 submission - Chaos Engineering
Lab 9 submission - Stateful Services and DB Reliability
Copilot AI review requested due to automatic review settings July 17, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR delivers the Lab 12 “Advanced Kubernetes Resilience” submission by hardening the QuickTicket Kubernetes deployment (replicas, PDBs, rollout behavior), executing an online schema change workflow (expand/contract rename to scheduled_at), and documenting/validating the work with updated monitoring assets and lab writeups.

Changes:

  • Increased service resilience via replica scaling, PodDisruptionBudgets, and gateway Rollout termination/readiness/topology-spread adjustments.
  • Added Alembic migrations (including concurrent index work) and performed an expand-and-contract rename from event_datescheduled_at, including seed data updates and events-service query updates.
  • Updated observability artifacts (Grafana dashboard panels, Prometheus rule wiring) and added supporting runbook/handbook + CI workflow updates.

Reviewed changes

Copilot reviewed 57 out of 58 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
submissions/runbooks/quickticket-handbook.md New operational handbook/runbook content for QuickTicket.
submissions/lab1.md Lab 1 submission writeup.
submissions/lab2.md Lab 2 submission writeup.
submissions/lab3.md Lab 3 submission writeup.
submissions/lab4.md Lab 4 submission writeup.
submissions/lab5.md Lab 5 submission writeup.
submissions/lab6.md Lab 6 submission writeup.
submissions/lab7.md Lab 7 submission writeup.
submissions/lab8.md Lab 8 submission writeup.
submissions/lab9.md Lab 9 submission writeup (migrations/backup/restore work).
submissions/lab10.md Lab 10 submission writeup (reliability review/load testing).
submissions/lab11.md Lab 11 submission writeup (notifications + resilience patterns).
submissions/lab12.md Lab 12 submission writeup (advanced K8s resilience + migrations).
monitoring/prometheus/rules.yml Adds/defines SLO-related recording rules.
monitoring/prometheus/prometheus.yml Prometheus scrape config (loads rules file).
monitoring/grafana/dashboards/golden-signals.json Replaces placeholder panels with latency/saturation/SLO panels.
migrations/versions/0001_baseline_pre_existing_schema.py Alembic baseline revision.
migrations/versions/0002_add_email_column_to_events.py Alembic migration: add email column.
migrations/versions/0003_index_events_event_date_concurrently.py Alembic migration: concurrent index creation/drop for event_date.
migrations/versions/0004_add_events_scheduled_at.py Alembic migration: add nullable scheduled_at.
migrations/versions/0005_backfill_events_scheduled_at.py Alembic migration: backfill + enforce NOT NULL on scheduled_at.
migrations/versions/0006_drop_events_event_date.py Alembic migration: drop event_date (contract step).
migrations/env.py Alembic environment configuration.
migrations/README Alembic migrations README.
migrations/script.py.mako Alembic script template.
locustfile.py In-cluster Locust scenario for gateway load testing.
k8s/redis.yaml Redis Deployment/Service manifest.
k8s/postgres.yaml Postgres Deployment/Service with PVC-backed storage.
k8s/events.yaml Events Deployment/Service manifest (2 replicas, env/probes).
k8s/payments.yaml Payments Deployment/Service manifest (scaled to 2 replicas).
k8s/notifications.yaml Notifications Deployment/Service manifest (scaled to 2 replicas).
k8s/gateway.yaml Gateway Rollout updates (graceful shutdown, topology spread, analysis steps).
k8s/pdb.yaml Adds PDBs for gateway/events/payments/notifications.
k8s/analysis-template.yaml Defines canary error-rate AnalysisTemplate.
k8s/backup-cronjob.yaml Adds Postgres backup CronJob manifest.
k8s/chart/Chart.yaml Helm chart metadata.
k8s/chart/values.yaml Helm chart values for QuickTicket components.
k8s/chart/templates/gateway.yaml Helm template for gateway resources.
k8s/chart/templates/events.yaml Helm template for events resources.
k8s/chart/templates/payments.yaml Helm template for payments resources.
k8s/chart/templates/postgres.yaml Helm template for postgres resources.
k8s/chart/templates/redis.yaml Helm template for redis resources.
docker-compose.monitoring.yaml Wires Prometheus rules file into docker-compose monitoring setup.
app/seed.sql Updates seed schema/data to use scheduled_at instead of event_date.
app/gateway/main.py Implements retry/circuit-breaker/rate-limiter logic and adds payments failure handling.
app/events/main.py Switches reads/order to scheduled_at (aliased to preserve API response shape).
app/notifications/main.py Adds notifications service implementation and metrics.
app/notifications/requirements.txt Notifications service dependencies.
app/notifications/Dockerfile Builds notifications service image (non-root user).
app/gateway/Dockerfile Updates gateway Dockerfile (non-root user).
app/events/Dockerfile Updates events Dockerfile (non-root user).
app/payments/Dockerfile Updates payments Dockerfile (non-root user).
app/gateway/.dockerignore Adds dockerignore for gateway build context.
app/events/.dockerignore Adds dockerignore for events build context.
app/payments/.dockerignore Adds dockerignore for payments build context.
alembic.ini Adds Alembic configuration.
.gitignore Adjusts ignored paths to allow committing lab artifacts/manifests.
.github/workflows/ci.yml Adds CI workflow to build/push images and update manifests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/gateway/main.py
Comment on lines +385 to 395
except httpx.RequestError:
return JSONResponse(
status_code=503,
content={
"error": "payments_unavailable",
"message": "Payment service is temporarily down. Your reservation is held — try again in a few minutes.",
"reservation_id": reservation_id,
},
)
except httpx.TimeoutException:
raise HTTPException(504, "Payment service timeout")
Comment thread app/gateway/Dockerfile
Comment on lines +8 to 12
EXPOSE 8080
RUN addgroup --system app && adduser --system --ingroup app app
USER app

EXPOSE 8080
Comment thread app/events/Dockerfile
Comment on lines +8 to 12
EXPOSE 8081
RUN addgroup --system app && adduser --system --ingroup app app
USER app

EXPOSE 8081
Comment thread app/payments/Dockerfile
Comment on lines +8 to 12
EXPOSE 8082
RUN addgroup --system app && adduser --system --ingroup app app
USER app

EXPOSE 8082
Comment thread k8s/notifications.yaml
Comment on lines +19 to +20
image: quickticket-notifications:v1
imagePullPolicy: Never
Comment on lines +24 to +30
def downgrade() -> None:
op.add_column(
"events",
sa.Column("event_date", sa.TIMESTAMP(timezone=True), nullable=True),
)
op.execute("UPDATE events SET event_date = scheduled_at")
op.alter_column("events", "event_date", nullable=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants