Skip to the page

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.

The 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

  1. What does Kubernetes expect from an application?
  2. What is the difference between readiness, liveness and startup probes?
  3. Why should liveness not check the database?
  4. Why must services be stateless on Kubernetes?
  5. Give a checklist you would use before a new service goes to a production cluster.

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview