Kubernetes: shipping a service · core
What your service owes the platform
Kubernetes can run any container, but it replaces pods at any time and sends signals, so a service must be stateless, configurable from outside, observable and ready to stop cleanly.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- An image in a registry with an immutable tag, listening on a non-privileged port, running as non-root.
- Configuration from environment variables or mounted files, and secrets from Secrets (ideally synced from a secrets manager). Nothing environment-specific in the code or the image.
- Stateless: no sessions, uploads or caches that must survive on local disk. Pods are replaced at any time.
- Logs as structured lines to stdout and stderr, not files. Metrics (a Prometheus endpoint or OpenTelemetry) and traces.
- Probes: readiness (can I take traffic now?), liveness (am I stuck? do not check dependencies), startup (slow boots). A liveness probe that checks the database restarts every pod when the database is slow.
- Graceful shutdown on SIGTERM: stop accepting work, finish in-flight work, close connections, exit before the grace period ends.
- Resource requests and limits, and a PodDisruptionBudget so voluntary disruptions do not take too many pods at once.
- Health endpoints are cheap and do not hit the database on every call.
The red pen
Common traps: mistake → fix
Mistake: A liveness probe should check that the database works
Fix: Liveness checks only whether this process is stuck. A dependency check turns one outage into a restart loop.
Mistake: Writing logs to a file inside the container is fine
Fix: Files vanish with the pod. Write to stdout.
Mistake: The pod keeps running for months
Fix: Pods are replaced often. Never keep state in one.
Easy to hard
Questions interviewers ask, easy to hard
- What does Kubernetes expect from an application?
- What is the difference between readiness, liveness and startup probes?
- Why should liveness not check the database?
- Why must services be stateless on Kubernetes?
- Give a checklist you would use before a new service goes to a production cluster.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.