Code to Production 01: The System on One Page¶
You can't copy a delivery pipeline you can't see whole, so this post puts all of eShop on one page: 4 services, 6 repositories, 3 environments on 1 cluster, and every gate between an issue and production. eShop is a real, running reference system on Nutanix Kubernetes Platform, and the next seven posts each take one slice of it. Read this one first and the rest will have somewhere to land.
Code to Production: the series
- The system on one page (this post)
- Ways of working
- CI gates before review
- Image gates and the supply chain
- Delivery and releases
- The platform
- Observability
- Operations and caveats
eShop is a small shop with a lot behind the counter¶
eShop is a mobile-first web app for a fictional company, eShop Co. A Customer buys a phone on hire purchase with only a national ID card, and bids in a weekly Auction of used iPhones. Staff hand over the goods and run the Auctions.
The business is small on purpose: big enough to need a database, a background worker, file storage, three third parties and a legacy core system, and small enough to read in a week. That's what makes it worth copying from. Every delivery practice in this series was needed by something in it.
The words are capitalised because they come from one glossary, eshop-infra/GLOSSARY.md, and the code, the routes, the tables and the tests all use them. You won't find "user" for a Customer or "order" for a Contract. /api/applications and contract_outbox only make sense once you know what an Application and a Contract are.
The Product page in dev: ฿29,900, Flat Rate 1.5% a month, and the calculator showing ฿1,695 a month over 24 Installments. The rule behind that number lives in the API, not the page.
The calculator is a good first test of whether you understand the business. The rule is in eshop-api/src/Eshop.Domain/Catalog/InstallmentPlan.cs: amount financed, times one plus the Flat Rate times the Term, divided by the Term, rounded up, never under ฿500. With ฿1,000 down over 12 months: (29,900 − 1,000) × 1.18 / 12 = 2,841.83, so ฿2,842.
A sale crosses four parties in ten steps¶
Follow the numbers 1 to 10. Steps 6, 7 and 10 are the interesting ones for an engineer: one transaction, a push about 30 seconds later, and a pull about 30 seconds after a Payment.
The Customer signs in with an SMS code and applies with one Product, a Term, an optional Down Payment, an ID number and an ID card photo. Two third parties run ID Verification and a Credit Check, and the Credit Decision comes back automatically within 60 seconds.
Accepting the Offer creates the Contract. From there the Enterprise System, eShop Co.'s core hire-purchase system, takes over: it owns the Contract and every Payment against it. It isn't part of eShop, and that one fact drives most of the data design below.
The whole system fits in four parts¶
Any delivery system is source, build-and-check, store and run, plus approvals and visibility. When you meet a new one, find those four first.
Left to right is the path of a change: GitLab, the runner VM, Harbor, then the cluster. Look at the red arrow: the cluster pulls images and signed manifests from Harbor and verifies them. CI only reads.
| Part | In eShop | Version | One line |
|---|---|---|---|
| Source | GitLab CE at <GITLAB> | 19.5 | Six repositories, merge requests, one issue tracker, pipelines |
| Build and check | Three runners on one VM, <RUNNER> | 19.5.3, Ubuntu 24.04 amd64 | eshop-shell runs gates, the image job and deploys; eshop-docker-amd64 runs lint and tests |
| Store | Harbor at <HARBOR>, project eshop | 2.15 | Images, signatures, SBOMs, signed manifests |
| Run | NKP workload cluster eshop-prd1 | NKP 2.19.1, Kubernetes 1.36.2 | Dev, QA, prod and the mocks |
| Entrance | eShop's own Traefik at <GATEWAY> | Gateway API | Routes by hostname and path |
| Data | PostgreSQL per environment (CloudNativePG) | 18 | eShop's own data |
| Visibility | NKP's Prometheus, Loki, Grafana, Alertmanager; plus Tempo | traces kept 7 days | Three dashboards: eShop (dev), eShop (prod), eShop pipelines |
One note on addresses, said once for the whole series. The lab has no DNS names, so the screenshots show private IP addresses and the text uses placeholders like <GITLAB>, <HARBOR> and <GATEWAY>. The environments are eshop.<GATEWAY>.nip.io (dev), qa.eshop.<GATEWAY>.nip.io and prod.eshop.<GATEWAY>.nip.io.
The six addresses are recorded in one file, clusters/eshop-prd1/addresses.env, and scripts/move-addresses.sh rewrites them in every repository, so the whole system can be moved to another environment. Post 08 covers that.
Six repositories, and one of them is the system¶
The six projects. The green ticks beside eshop-infra and eshop-web are their latest pipelines passing.
Five repositories build six images. The sixth, eshop-infra, builds nothing: it is the system.
Three arrows matter. Every service pipeline includes the shared gates from eshop-infra, every main pipeline triggers a deploy there, and every issue for all six lives in its one tracker.
| Repository | Holds | In a release |
|---|---|---|
eshop-infra | Glossary, ADRs, the one issue tracker, shared gates, deploy files, release scripts, the smoke test | It is the release |
eshop-api | .NET 10 back end; builds eshop-api and eshop-sync-master | Yes |
eshop-web | React 19 web app served by Caddy | Yes |
eshop-node-api | Node 24 image service | Yes |
thirdparty-mock | Test equipment: the mocks | Listed in ci/services.json |
eshop-loadgen | Test equipment: Locust 2.47.0 | No |
Read the folder names: ci (shared gates), clusters/eshop-prd1 (this cluster and each environment's pin), deploy, e2e (the smoke test), releases, scripts. On the right: 1 tag, 1 release, 4 environments.
A version number exists only in eshop-infra. The service repositories have no version tags and no issues of their own (ADR 0009, "One repository per service; release candidates promote the images dev tested"). Post 02 covers how the team works across them.
Harbor mirrors that layout with six image repositories.
Six repositories in project eshop. eshop-api and eshop-sync-master both come from the one eshop-api Git repository.
Three environments live on one cluster¶
The NKP console: the management cluster nkp-prd1 creates and manages the workload cluster eshop-prd1. Both show NKP v2.19.1 and Kubernetes v1.36.2.
NAME STATUS ROLES AGE VERSION
eshop-prd1-fhft6-5gxct Ready control-plane 5h31m v1.36.2
eshop-prd1-fhft6-gt62z Ready control-plane 5h29m v1.36.2
eshop-prd1-fhft6-wk8bc Ready control-plane 5h28m v1.36.2
eshop-prd1-md-0-gtv9t-zbhdd-6g7nw Ready <none> 5h30m v1.36.2
eshop-prd1-md-0-gtv9t-zbhdd-bfkwh Ready <none> 5h30m v1.36.2
eshop-prd1-md-0-gtv9t-zbhdd-csnhk Ready <none> 5h30m v1.36.2
Three control-plane nodes, three workers. Despite the "prd" in its name, eshop-prd1 holds all three environments, each in its own namespace, plus one for the mocks.
| Namespace | Hostname | What runs there |
|---|---|---|
eshop-dev | eshop.<GATEWAY>.nip.io | Every service's newest main build |
eshop-qa | qa.eshop.<GATEWAY>.nip.io | The version pinned in Git: a release candidate, or the release itself between candidates |
eshop-prod | prod.eshop.<GATEWAY>.nip.io | The release pinned in Git |
thirdparty | /thirdparty-mock/ and /loadgen/ on dev's hostname | The shared mocks and the load generator |
The walls between environments are a namespace, default-deny network policies and a database each. That's a lab trade: separate clusters give stronger walls at three times the machines and platform work. Post 06 covers the cluster.
Two controls on the cluster are worth knowing before anything else. policy-controller refuses any eShop image that eShop's key didn't sign1, and CI doesn't change the cluster at all: a deploy job publishes signed manifests to Harbor, and Flux, which NKP already runs, verifies the signature and applies them2 as a ServiceAccount named eshop-deployer. CI's own identity, eshop-ci-reader, can only read.
One change, traced from issue to production¶
One real change runs through the series: issue #3, "Product page: the browser tab names the Product", twelve lines in one file of the web app (src/pages/ProductPage.tsx), taken from an issue to dev. Open the iPhone page and the tab reads "iPhone 17 128GB · eShop". That's it.
The frames are the point. An agent or a person may do the blue box, CI does the purple ones, and the red one, the merge, is a human-only step. A red pipeline loops back to the branch.
Here's that path as one line, from eshop-infra/docs/supply-chain.md:
commit ──► merge request ──► main ──► image ──► registry ──► dev ──► release candidate ──► QA ──► sign-off ──► prod
gates gates built, signed, deploy copied by digest test a person pinned
(no image) again scanned attested + smoke digests
And as a table you can use to find your way around the series. The first half is issue #3; the second half is release 0.10.0.
| Stage | Tool | What it proves | Post |
|---|---|---|---|
Issue root/eshop-infra#3 | GitLab tracker in eshop-infra | Someone asked for the change, in the glossary's words | 02 |
Branch issue/3-product-page-title, merge request eshop-web!1 | Git, GitLab; main is protected | Every change has a diff, a pipeline and a name | 02 |
| Merge request pipeline #66, 40 seconds | Lint; Semgrep (SAST); Trivy (dependencies); gitleaks (secrets); a configuration scan; signed commits | The source is clean before anyone reviews it. No image exists yet | 03 |
| Merge | A person | The one decision in this half | 02 |
main pipeline #68, 7 minutes 4 seconds | Build, then a temporary copy of eShop on the runner; Locust, ZAP, Trivy image scan | The new image works beside the other services' newest main images | 04 |
| Push, sign, SBOM, provenance | Harbor, cosign, CycloneDX | The image is eShop's, and says what's inside and what built it. A failing gate means no image exists | 04 |
deploy-dev, pipeline #69, 3 minutes 5 seconds | Signed manifests, Flux, a Playwright smoke test (22 browser tests) | "Deployed" means "deployed and working" | 05 |
| Release candidate | scripts/release.sh X.Y.Z-rc.N | Nothing is rebuilt: the candidate copies, by digest, the images dev last ran successfully | 05 |
| QA promotion merge request | Git: QA's pin changes | Merging it is QA's approval | 05 |
| Sign-off merge request | scripts/sign-off.sh | QA's smoke test passed and a Maintainer said yes; writes the release record and tag | 05 |
| Prod promotion merge request | Git: prod's pin changes | Production runs exactly the bytes dev tested | 05 |
| Admission | policy-controller, Flux | Only signed images and signed manifests run | 06 |
| After the deploy | Grafana, Prometheus, Loki, Tempo; the watchdog every 30 minutes | You can see a request's metrics, logs and trace | 07 |
| Every day, every Monday | Re-scan of running images at 06:00; Renovate at 07:00 Monday (Bangkok time) | A vulnerability published next month is still found | 08 |
A person makes five decisions on the whole path: the merge, cutting the candidate, and three more merges (QA, sign-off, prod). Everything else is automatic. For issue #3, the first half took about a quarter of an hour from the commit to a passed smoke test in dev.
A pin is just a line in Git. This is what production's looks like in clusters/eshop-prd1/apps/prod/kustomization.yaml, with a sha256: digest beside each one:
So the history of eshop-infra is the history of what ran where.
The services are split where the work really differs¶
A split costs coordination, so it should follow a real difference: different work, a tool the work needs, or different things to reach.
One environment on top, the shared thirdparty namespace below. Trace who reaches what: only the sync master goes to SQL Server on 1433, only the image service goes to Samba on 445, and eshop-web has no outbound arrow at all.
| Service | Does | Tech | May talk to |
|---|---|---|---|
eshop-api | Everything under /api; the only service that migrates the PostgreSQL schema | .NET 10, EF Core, chiseled image | PostgreSQL, eshop-node-api, thirdparty-mock |
eshop-sync-master | Every 30 seconds: push Contracts, pull Payments and status | .NET 10, same solution, chiseled-extra image | PostgreSQL, SQL Server. Nothing calls it |
eshop-web | The UI for Customers and, under /staff, Staff | React 19, Vite 8, served by Caddy 2.11.7 | Nothing: egress: [] |
eshop-node-api | Stores and serves photos; keeps ID card photos private | Node 24, Express 5, smbclient | Samba |
The browser never knows that three programs answered. The Gateway decides by the start of the path, with one HTTPRoute per service:
NAMESPACE NAME HOSTNAMES
eshop-dev eshop-api ["eshop.<GATEWAY>.nip.io"]
eshop-dev eshop-node-api ["eshop.<GATEWAY>.nip.io"]
eshop-dev eshop-web ["eshop.<GATEWAY>.nip.io"]
eshop-prod eshop-api ["prod.eshop.<GATEWAY>.nip.io"]
# ...
thirdparty eshop-loadgen ["eshop.<GATEWAY>.nip.io"]
thirdparty thirdparty-mock ["eshop.<GATEWAY>.nip.io"]
One origin for the browser means no cross-origin configuration in the app.
Here's what the split buys, as the files show it:
- Narrow access. Only the sync master has a SQL Server login and a path to port 1433. Only the image service reaches the file share. The web server reaches nothing.
- The right tool per job. The image service needs an OS package (
samba-client); keeping it separate leaves the API's image with no shell and no package manager. - Independent rhythms. Requests versus a 30-second timer. The API and the sync master share code because they work on the same tables, and run as separate processes because the work differs.
I'll be plain about one thing: no ADR records why eShop is cut into exactly these four. The division comes from the original specification. The reasons above are what the split provides, read from the manifests and network policies.
The cost is that five images can be out of step, and one rule answers it: every merge must work with the other services' main. The temporary copy enforces it by testing a new image beside the others' newest main images. A change that crosses services ships expand-then-contract: first the side that accepts both forms, then the side that uses the new one. Never two merge requests that only work together.
All six images also follow the same four rules, and they're worth stealing as a set:
- Base images pinned by digest (
FROM node:24-alpine@sha256:...), checked by a gate - Build tools stay in the build stage; the final image is small
- Non-root, port 8080, read-only root filesystem, all Linux capabilities dropped
- Every
COPYof the service's own files into a final image sets file modes (--chmod=u=rwX,go=rX)
The key decisions are written down, with what was rejected¶
eShop has seventeen ADRs in eshop-infra/docs/adr/. These are the ones that shape the system; the rest show up in the posts that own them.
| ADR | Decision | Rejected | Post |
|---|---|---|---|
| 0001 | The Enterprise System owns Contracts once pushed; eShop keeps a read-only copy up to 30 seconds behind | One system as master for everything | this one |
| 0003 | Mock the Enterprise System with a real SQL Server | A PostgreSQL stand-in or an HTTP stub | this one |
| 0004 | The Handover is kept beside the Contract, not on it; due dates are derived on read | Writing Handover facts on a Contract eShop no longer owns | this one |
| 0005 | Developer tools get their own network arrows, and Staff may set Auction times | The specification's wording alone: a weekly-only Auction can't be tested in under a week | this one |
| 0006 | One responsive web app (PWA) instead of native mobile apps | A second front end and app-store releases | this one |
| 0007 | Release gates run in CI against a temporary copy; deploys are promotion merge requests | Testing a deployed environment; deploy approvals inside the CI system | 04, 05 |
| 0008 | A deploy counts only when its smoke test passed; sign-off is a merge | A hand-started test run with no record tied to the deployment | 05 |
| 0009 | One repository per service; release candidates promote the images dev tested | Tagging and rebuilding in every repository: a rebuild isn't the bytes dev tested | 02, 05 |
| 0011 | Only the pipeline that pushed an image signs it, and the cluster runs only those | Kyverno for one job; a webhook that fails closed | 04, 06 |
| 0012 | Images live in the lab's Harbor, trusted through its CA | Docker Hub, GitLab's registry, an insecure registry | 04 |
| 0017 | The cluster pulls its manifests, signed; the pipeline doesn't apply them | Flux reading Git, Flux image automation, Argo CD, a narrower push credential | 05, 06 |
A caveat the ADRs themselves teach: some titles don't match the implementation exactly. ADR 0011's title says "keyless", and its notes say plainly that the lab signs with a key pair, because no public Sigstore can vouch for a private GitLab. Read the note at the top of an ADR before its body.
Ownership of a Contract changes hands once, and the sync is built around that¶
ADR 0001 is the decision I'd copy first. eShop must create Contracts quickly; collections and accounting already live in the Enterprise System. So eShop owns a Contract only from the Customer's acceptance until the push.
Left is eShop's PostgreSQL, right is the Enterprise System. The push reads contract_outbox; the pull asks only for rows above the watermark and saves the new watermark with them.
The push is an outbox.3 When the Customer accepts the Offer, eshop-api writes three rows in one transaction: the Contract, its Handover row and a row in contract_outbox. The sync master delivers each one into the Enterprise table hp.contract, idempotent on the contract number.
The pull is a watermark. Each Enterprise row has a row_ver column, a SQL Server rowversion that grows on every insert and update4. The sync master keeps the highest value per table in sync_watermarks and asks only for rows above it.
Two details from eshop-api/docs/conventions.md matter if you copy this:
- Save the watermark in the same transaction as the pulled rows, under
pg_advisory_xact_lock. During a rolling update the old and new pods overlap and would otherwise insert the same rows twice. - Stop the pull at
MIN_ACTIVE_ROWVERSION(), so it never skips a row whose transaction is still open.
ADR 0004 follows from 0001. Staff record the Handover after the push, and its date starts the Installment schedule, but by then eShop doesn't own the Contract row. So Handover facts live in a separate handovers row that eShop owns for good, and Installment n falls due n months after the Handover date, derived on read.
Test equipment is part of the design, and it's fenced off¶
Test equipment is software that exists only so eShop can be demonstrated and tested. It runs once, in the thirdparty namespace, with its own network policies, and it isn't deployed from a release pin: it follows its newest main build.
The grey line at the top says it: "test equipment, not a real third party". The last two digits of an ID number pick the outcome, so a test can ask for an approval, a rejection or an under-20 refusal on purpose.
thirdparty-mock pretends to be every third party eshop-api calls: SMS (with an inbox page, so you read a sign-in code without a phone), ID Verification, Credit Check, and an admin tool for the Enterprise System with Simulate Payment, Mark overdue and Cancel Contract.
| ID ends in | The mock answers | The Customer sees |
|---|---|---|
01 (or anything else) | Verified, aged 35, Credit Limit ฿50,000 | Approved |
02 | Verified, Credit Check failed | Rejected |
03 | Verified, Credit Limit ฿5,000 | Rejected: over the limit |
04 | ID Verification failed | Rejected |
05 | Verified, aged 18 | Not eligible: must be 20 or over |
The services don't know they're talking to mocks. eshop-api has one base URL for the third parties (ThirdParty__BaseUrl), and the sync master has a SQL Server connection string.
The Enterprise mock is a real SQL Server 2022, not a stub (ADR 0003), and it earns its cost three ways. The pull depends on rowversion, which is SQL Server's own. The Enterprise tables have triggers, on which UPDATE ... OUTPUT without INTO fails. And the sync master's need for the ICU libraries (the chiseled-extra base image) comes from the real driver. A stand-in would hide all three. The cost is about 2 GB of memory and x86 only, which is why one instance is shared, with a database (enterprise_dev, enterprise_qa, enterprise_prod) and a login per environment.
eshop-loadgen is Locust with a page at /loadgen/. It gives the dashboards traffic: browsing (weight 70), applying (20) and faulty (10) Customers. Nothing starts until someone presses Start. Its limits are design: dev only, one outbound path (to the Gateway), at most 100 simulated Customers because eshop-api in dev requests only 50 millicores, and everything marked (mobile numbers 0600..., ID numbers 99..., User-Agent: eshop-loadgen/<n>).
It is not the performance gate. That has its own Locust script with a fixed load, covered in post 04.
Four pitfalls, each with a guard in place¶
| Pitfall | Why it happens | The guard in place |
|---|---|---|
| The load generator fails a deploy | Simulated Customers bid in dev's current Auction. During a deploy that Auction is the smoke test's, which expects its own Customer to win | Bidding has weight 0 unless someone turns it on, and it skips Lots whose titles start with E2E |
| PostgreSQL restarts endlessly | The image policy's webhook rewrites a tag into tag plus digest. CloudNativePG sees a different image from the one it asked for and replaces the pod, again and again | imageName carries its digest in deploy/apps/base/eshop-db/cluster.yaml, and the operator's own image is pinned in bootstrap.sh: nothing left to rewrite |
| eShop's pinned CloudNativePG operator won't install | NKP ships its own cloudnative-pg application, which owns the operator's CRDs. Two can't share a cluster | NKP's application stays disabled for this workspace and eShop's bootstrap installs the operator |
| The watchdog fails right after a deploy | It counts any pod restart in the last hour, so a restart during a rollout reads as "eshop-api ... restarted in the last hour" | None needed: the next runs pass. Read what it says before re-running it |
Test equipment can break the system it tests. The first row is the one I'd put on a wall.
What production would change¶
The delivery practices here are real and complete. The capacity and availability are not.
| Lab | Production |
|---|---|
| Dev, QA and prod on one cluster | Prod gets its own cluster, or at least its own nodes |
| One replica of each service | Two or more, with a disruption budget |
| One runner VM: if it's down, nothing builds or deploys | More than one runner machine |
| One PostgreSQL instance, 1 GiB | Replicas and tested backups |
A thirdparty namespace with shared mocks; if it's down, SMS sign-in fails in every environment at once | No mocks, no load generator, no developer routes: real providers and the real Enterprise System |
nip.io names and a lab CA your browser must be told to trust | Real names and a publicly trusted CA |
| A cosign key pair | Keyless signing, where an identity provider can vouch for the GitLab |
On the SLSA Build track, eShop's own assessment is Level 1 met, Level 2 partly, Level 3 not met5: one shell runner builds every service with a shared cache, and the signing key is a CI variable the job reads. Post 08 lists the gaps in full.
Summary¶
A one-page system description that a new team member can check against the running thing. If you're building your own, here's the list:
- One glossary, used exactly, in issues, code, routes, tables and tests
- One "system" repository holding the tracker, ADRs, shared gates, deploy files, release scripts and the smoke test; version numbers exist only there
- One table of components with versions, and one of environments with hostnames and what runs in each
- One traced change, real, with its pipeline numbers and durations, and the count of human decisions on the path (eShop: five)
- Gates before the image exists; a failing gate means no image
- Build once; promote by digest; QA and prod move only by a merge that changes a pin
- Signed images and signed manifests, verified by the cluster; CI's cluster credential is read-only
- Services split only where work, tools or reach differ, with the rule "every merge works with the others'
main" - For every shared record, the owner and the moment ownership changes, written as an ADR
- Mocks as faithful as the risk needs (the real database engine for a legacy database), fenced in their own namespace, and marked so their data is recognisable
- Every decision recorded with what was rejected; every lab shortcut named as one
Next: Post 02: Ways of working: six repositories, one tracker, protected branches, and the short list of steps only a person may take, even when a coding agent does the rest.
-
Sigstore, Kubernetes Policy Controller: an admission controller that enforces policy on a cluster from cosign's supply-chain metadata. ↩
-
Flux, OCI Repositories:
.spec.verifyenables verification of Cosign or Notation signatures on an OCI artifact. ↩ -
Chris Richardson, microservices.io, Pattern: Transactional outbox. ↩
-
Microsoft Learn, rowversion (Transact-SQL): a per-database counter incremented on every insert or update of a table with a
rowversioncolumn. ↩ -
SLSA, Security levels, Build track v1.0: L1 provenance exists, L2 a hosted platform generates and signs it, L3 a hardened build platform. ↩
Discussion
Have thoughts on this post? Share them below — questions, corrections, or your own experience are all welcome.











