Testing with Kubernetes and Testcontainers
Test against real services without a shared server. Learn how throwaway containers help in a test, and how a Kubernetes cluster tells you when an app is ready.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a pop-up kitchen. A pop-up kitchen arrives with its own stove and fridge, cooks for the day, then packs everything away. Nothing is left behind and nobody shares a messy kitchen.
The next day, a clean one arrives.
A works the same way. Tom, the tester at Daily List, a to-do list app, starts a real database for a test and removes it after.
The aim is to test the real thing without leaving a mess behind.
PLAIN WORDS · 1 in this section
- throwaway
- a sketch you use once and then throw away
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A pop-up kitchen that arrives, cooks and packs away.
- Start
- Run
- Remove
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The pop-up kitchen | A throwaway container |
| Cooking for the day | The test run |
| Packing away | Removing the container |
| Checking the stove is hot | A readiness probe |
WHERE THIS PICTURE STOPS
- A kitchen is one room, but a cluster has many parts.
- A kitchen is staffed, but containers start by themselves.
- A kitchen is cleaned by hand, but removal is automatic.
HOOK
Arrive, run, pack away.
TELL A FRIEND
A pop-up kitchen: arrive, cook, pack away.
OFTEN MIXED UP WITH Docker Compose: a test environment you can start with one command. That topic builds a with Compose. This one starts services from a test and reads a Kubernetes cluster.
PRACTISE AND KEEP
Sources for this topic — 3 sources
- Market practice
Getting started with Testcontainers for Java (testcontainers.com) ↗ — Testcontainers · Actual PostgreSQL/JUnit5 tutorial: BeforeAll start, runtime JDBC parameters, AfterAll stop. Opened6 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Getting started with Testcontainers for Java (Docker docs) ↗ — Docker · Docker guide: Testcontainers lets you test against the same type of database you use in production instead of mocks (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Configure liveness, readiness and startup probes (Kubernetes) ↗ — Kubernetes · Current probe task: startup gating, readiness Service eligibility and liveness restart thresholds/policy. Opened6 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.