You must make a FastAPI service production-ready for Kubernetes. What is your checklist?
AdvancedScenarioTesting, CI/CD, packaging & services
Answer
Situation read → From "works locally" to operable.
What I'd do →
- Run with uvicorn (or gunicorn with uvicorn workers), exec-form entrypoint, non-root user, slim image.
/healthz(no dependencies) and/readyz(dependencies with short timeouts) wired to probes.- JSON logs to stdout with request IDs;
/metricswith request count and latency histograms. - Graceful shutdown: handle SIGTERM, a
preStopsleep for endpoint propagation. - Resource requests and limits, config from env, secrets from a secret store.
- Timeouts on every outbound call.
Why → These are the properties every reliable service on Kubernetes needs.
Interview tip → The preStop sleep detail shows deep Kubernetes knowledge.
More on Testing, CI/CD, packaging & services
You join a team whose Python automation repo has no tests. Where do you start?BeginnerYour pytest suite takes 12 minutes. How do you speed it up?IntermediateA test passes locally but fails in CI only when run with the rest of the suite. What do you suspect?IntermediateYou want a reusable CI pipeline for 15 Python tool repos. What goes in it?IntermediateYour Python Docker image is 1.1 GB. How do you shrink it?IntermediateYou want to distribute an internal CLI to 200 engineers. What are your options?Intermediate