FastAPI Cheatsheet 11 — Docker, Kubernetes, and Deploy
Cheatsheet: Dockerfile (multi-stage, distroless), Uvicorn flags, K8s deployment, probes, HPA, lifespan, graceful shutdown.
Cheatsheet: Dockerfile (multi-stage, distroless), Uvicorn flags, K8s deployment, probes, HPA, lifespan, graceful shutdown.
Production observability: structlog with contextvars, OTEL tracing, Prometheus metrics, log/trace correlation, and the patterns that pay back.
Cheatsheet: CORS, GZip, sessions, request ID, timing, body inspection, custom ASGI middleware, ordering rules.
Production FastAPI: Uvicorn / Hypercorn / Granian, Dockerfile, K8s deployment, HPA, graceful shutdown, and the operational checklist.
Cheatsheet: customize OpenAPI title/description, exclude routes, tag groups, custom servers, JS clients.
Cheatsheet: Read/Create/Update model trio, PATCH partial updates, Pagination class, filter from class.
Cheatsheet: BaseSettings, env_file, secrets directory, lru_cache, CLI integration, multi-env config.
Cheatsheet: 422 patterns, deps not resolving, async/sync mismatch, CORS, OpenAPI weirdness, and quick fixes.
Cheatsheet: offset/limit, keyset, opaque cursor encoding, total counts, generic Page[T] response model.
Cheatsheet: ETag, Cache-Control, Redis cache, fastapi-cache, conditional GET, invalidation.