Code to Production 05: Delivery and Releases, Dev to QA to Prod¶
Build the image once, then move that exact digest from dev to QA to prod. In eShop, dev follows every merge to main, while QA and prod move only when a person merges a promotion merge request that pins images by digest. In the example release, 0.10.0, the path from QA's deploy to a tested prod takes about twelve minutes, and nothing is rebuilt.
Code to Production: the series
- The system on one page
- Ways of working
- CI gates before review
- Image gates and the supply chain
- Delivery and releases (this post)
- The platform
- Observability
- Operations and caveats
Three environments, two ways to move¶
All three environments run on one workload cluster, eshop-prd1, each in its own namespace. A fourth namespace, thirdparty, holds the shared mocks.
| Environment | Runs | Moves when | Decided by |
|---|---|---|---|
dev (eshop-dev) | every service's newest main image | a service's main pipeline pushes an image, or eshop-infra's main changes what dev is made of | merging to main |
shared mocks (thirdparty) | newest main images of thirdparty-mock and eshop-loadgen | the same, for those two projects | merging to main |
QA (eshop-qa) | one release candidate X.Y.Z-rc.N, pinned in Git | a QA promotion merge request is merged | QA |
prod (eshop-prod) | one release X.Y.Z, pinned in Git | a prod promotion merge request is merged | the production approver |
Nothing deploys because a tag appeared. Under ADR 0007 ("Release gates run in CI against a temporary copy; deploys are promotion PRs"), a deploy is a reviewed commit with an author and a date, and you revert it like any other commit.
Follow the arrows into each namespace: dev and the mocks are triggered by service pipelines, QA and prod only by a merged promotion. The dashed arrows are the same images moving forward by digest.
The pin is a few marked lines in a Kustomize overlay¶
The pin lives in clusters/eshop-prd1/apps/<env>/kustomization.yaml. Every pinned line ends in a marker comment:
commonAnnotations:
eshop.io/release: "0.10.0" # release-pin: prod
images:
- name: <HARBOR>/eshop/eshop-api
newTag: "0.10.0" # release-pin: prod
digest: "sha256:2fa4a298...8dbb865814" # release-pin: prod
- name: <HARBOR>/eshop/eshop-web
newTag: "0.10.0" # release-pin: prod
digest: "sha256:0cf4d684...79328be81" # release-pin: prod
# ...
The annotation names the Git tag whose deploy/apps/<env> gets rendered. With newTag and digest both set, Kustomize writes <image>:0.10.0@sha256:...1, and the runtime pulls by digest. The tag in that reference is a label for people; repointing 0.10.0 in the registry changes nothing that runs.
Nobody edits these lines by hand. scripts/pin-release.sh reads and writes them:
scripts/pin-release.sh prod # prints the pinned release
scripts/pin-release.sh --images prod # each image as <image>:<version>@sha256:<digest>
scripts/pin-release.sh prod X.Y.Z # rewrites every "# release-pin: prod" line
scripts/pin-release.sh --suspended qa # exit 0 when qa has no release yet
0.10.0
<HARBOR>/eshop/eshop-api:0.10.0@sha256:2fa4a29880c73450220d260ae54113d4b3aa1348ab913105c2345a8dbb865814
<HARBOR>/eshop/eshop-sync-master:0.10.0@sha256:55474cc37951abe27b67b52cdb4ef41baf602f411a1d7ff6c3d888a2f29144f7
<HARBOR>/eshop/eshop-web:0.10.0@sha256:0cf4d684c20fa59e3a325ca336bdd744a7fa4c38cf98d38fb74e90d79328be81
<HARBOR>/eshop/eshop-node-api:0.10.0@sha256:b6949b0e5f16830662266db3dfbbbf12a54c05414f1e62a1a88328ba57061ee0
Reading is strict: disagreeing versions, a missing digest line, or anything that isn't an exact X.Y.Z or X.Y.Z-rc.N fails. The validate job reads both pins on every merge request, so a broken hand edit fails before anyone can merge it.
Dev's overlay has no pin at all. Each deploy asks Harbor for every service's newest main-<sha>-<ts> tag, so dev always shows what the next release would contain.
GitLab shows the difference on one screen, because each deploy job declares an environment:2.
Read the commit titles: prod's and QA's latest successful Deployments are merges of promote/prod-0.10.0 and promote/qa-0.10.0-rc.1, so somebody decided. Dev's and the mocks' are ordinary main commits. The grey Waiting entries are manual jobs nobody started.
The pipeline publishes signed manifests; the cluster applies them¶
Every environment is pull-based (ADR 0017, "The cluster pulls its manifests, signed; the pipeline stops applying them"). GitLab CI decides what to deploy and when, renders the manifests, and runs the smoke test. Flux, which NKP already runs on the cluster, does the one thing that needs write access: verify and apply.
The reason is the credential: no write credential leaves the cluster. A pipeline that applies manifests itself needs a kubeconfig that can change every workload in four namespaces, and whoever reads that CI variable controls what runs. The kubeconfig GitLab holds belongs to eshop-ci-reader, which can only read.
Images are signed and checked at admission (post 04). Pulling gives the manifests, which say which images run and with what privileges, the same check on the cluster.
The two amber boxes are the pull-based part: publish the manifests signed, then wait until Flux reports that exact digest applied. The dashed line is the only thing CI does to the cluster's control plane: read status.
A service merge triggers one job in eshop-infra¶
Every service's main pipeline ends in a trigger job, defined once in eshop-infra/ci/service-image.gitlab-ci.yml:
deploy:
stage: deploy
inherit:
variables: false
rules:
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE =~ /^(push|web|api)$/ && $CI_PROJECT_NAME =~ /^(thirdparty-mock|eshop-loadgen)$/
variables:
ESHOP_DEPLOY: thirdparty
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE =~ /^(push|web|api)$/
variables:
ESHOP_DEPLOY: dev
trigger:
project: $[[ inputs.infra-project ]]
branch: main
strategy: depend
strategy: depend makes the service's pipeline wait for the downstream one and take its result, so a failed smoke test in dev turns the developer's own pipeline red. (GitLab's current docs steer new setups toward strategy: mirror3; eShop uses depend.)
In eshop-infra, the downstream pipeline runs exactly one job, deploy-dev. All deploy jobs extend .deploy, which sets resource_group: eshop-prd1-$ESHOP_ENV. Three services merging within a minute start three deploy-dev jobs; they run one after another, and each takes whatever is newest when it starts.
What deploy-eshop-prd1.sh does for dev¶
- Finds each service's newest
main-<sha>-<ts>image (scripts/gates/latest-main-image.sh). An unreadable registry fails the job: "could not read" is never taken as "nothing there". - Renders the overlay with
kubectl kustomizeinto onemanifests.yaml. - Publishes it with
scripts/ci/publish-manifests.shas the OCI artifact<HARBOR>/eshop/eshop-manifests:devand signs the digest with cosign4, the same key that signs images. - Polls Flux's
OCIRepositoryandKustomizationeshop-devin namespaceeshop-cievery 10 seconds, for up to 15 minutes. - Waits for PostgreSQL and every Deployment's rollout.
- Writes
reports/deployed-images.txt, one digest per image. - Runs the Playwright smoke test.
Flux's side is one file per environment, clusters/eshop-prd1/platform/pull/dev.yaml, applied by a cluster admin:
kind: OCIRepository
metadata:
name: eshop-dev
namespace: eshop-ci
spec:
interval: 1m
url: oci://<HARBOR>/eshop/eshop-manifests
ref:
tag: dev
verify:
provider: cosign
secretRef:
name: eshop-manifests-public-key
# ...
kind: Kustomization
spec:
interval: 10m
sourceRef:
kind: OCIRepository
name: eshop-dev
serviceAccountName: eshop-deployer
targetNamespace: eshop-dev
prune: false
wait: true
verify makes the source refuse a package eShop's key didn't sign5. serviceAccountName makes Flux apply as eshop-deployer, so it can do only what that account's RoleBindings allow in the four eShop namespaces6. wait: true means Ready only when everything applied is healthy, which is what the job waits for.
The tag dev moves with every deploy. What makes a package trusted is its signature, never its tag.
The proof is two equal digests in the job log¶
This is the log of one deploy-dev job, trimmed:
--- publish clusters/eshop-prd1/apps/dev for the cluster to pull
tlog entry created with index: 4049358337
published <HARBOR>/eshop/eshop-manifests@sha256:81483203eb11ce48f46edac44bac8b939df7d0f56df6a6ff48950224bda7fad9
--- wait for Flux to apply it (Kustomization eshop-ci/eshop-dev)
applied by Flux: sha256:81483203eb11ce48f46edac44bac8b939df7d0f56df6a6ff48950224bda7fad9
--- wait
--- deployed images
--- smoke test of dev: https://eshop.<GATEWAY>.nip.io
22 passed (3.7m)
Smoke test of dev passed
Deployed: https://eshop.<GATEWAY>.nip.io
Compare line 45 (published ...@sha256:81483203...) with line 47 (applied by Flux: sha256:81483203...). Same digest, ten seconds apart: Flux applied the package this job signed, not an older one.
The job goes on only when the Kustomization's last applied revision is the digest it just published and Ready is True. If verification fails, it stops at once with "Flux refused the artifact", and the environment keeps what it runs.
A cluster admin sees the same from the other side:
$ kubectl -n eshop-ci get ocirepository,kustomization
NAME READY APPLIED
eshop-dev True dev@sha256:81483203eb11ce48f46edac44bac8b939df7d0f56df6a6ff48950224bda7fad9
eshop-prod True prod@sha256:f8be0cd46bede86822ede91a565a68cbd6f6e405e17e6c524ec60242a30f7701
# ...
SourceVerified: True Succeeded: verified signature of revision prod@sha256:f8be0cd4...
Why an OCI artifact and not a Git source¶
ADR 0017 gives three reasons:
- Dev's images are chosen at deploy time and written nowhere in Git. A Git source would need a bot committing image tags to protected
main. - QA's and prod's manifests come from two places (the release tag's
deploy/andmain's pins), which the render already joins. - An artifact can be signed with the same key and tools as the images.
Flux over Argo CD is the simpler choice: NKP already runs and upgrades Flux.
What it costs: a deploy has two actors and can wait up to a minute before Flux notices the package, because the source looks once a minute and CI has no right to ask Flux to hurry. A Flux outage stops deploys. And Flux re-applies the last package every 10 minutes, so a field changed by hand in the cluster is put back.
A deploy is finished only when the smoke test passes¶
ADR 0008 ("Smoke tests run on every deploy, report as GitHub Deployments, and sign-off is a PR") decides that a deploy counts only once the smoke test has passed against it. The title says GitHub; the ADR's note says the decision stands on GitLab, with GitLab Deployments as the record.
The test is the Playwright suite in eshop-infra/e2e/: 11 tests in two projects, phone (390 by 844) and desktop (1280 by 800). 22 passed is the number to look for in every deploy log.
It's a wide test on purpose. One run does hire purchase end to end (SMS sign-in, an approved Application, a Contract that must appear in the mock Enterprise System, a Payment synced back) and an auction a Customer wins. A health check would be faster but can't see a Contract that never reached the Enterprise System.
There's no separate reporting step. The smoke script's exit code is the job's result, and GitLab sets the Deployment's status from the job. So a green deploy-dev means "Flux applied my package", "the rollout finished" and "the test passed", in one status that release scripts can query.
Three things to know before you copy this:
- A failed Deployment rolls nothing back. The new images are running in dev; the status says they didn't pass.
ESHOP_SMOKE=0skips the test, and the Deployment is still Success. The release scripts can't tell it from a tested one, so never use it on a deploy a candidate or sign-off will stand on.- The test proves only what it covers. Issue #3 changes the Product page's tab title, the 22 tests don't check that page's title, so a person verifies it in the browser.
Release 0.10.0: three merges are the three approvals¶
Every human decision is a merge of a merge request that CI prepared. Release 0.10.0 is the worked example for every step below.
Red boxes are people, purple boxes are jobs. Four decisions: cut a candidate, approve for QA, sign off, approve production. The two arrows into Harbor are copies by digest, never builds.
Step 1: a Maintainer tags a candidate¶
The script prints a plan and asks Push? [y/N]. For a new minor's first candidate it merges origin/main into release/0.x and tags that merge commit with an annotated v0.10.0-rc.1.
It refuses unless dev's latest Deployment succeeded, because the candidate copies what dev last ran. --force skips that one check and writes "Cut with --force: dev's latest Deployment was ..." into the tag message, so the override stays visible. It also refuses a commit carrying a skip-ci marker: a tag with no pipeline gets no images, and tags are never moved.
Step 2: release-candidate copies, it doesn't build¶
Six seconds for a release candidate. That's the right number when no Dockerfile runs.
The job reads the newest successful Deployments of dev and thirdparty, downloads each job's reports/deployed-images.txt, and copies every image in ci/services.json to <HARBOR>/eshop/<service>:0.10.0-rc.1 with crane copy, which keeps the digest7. That's why the deploy artifacts are kept for a year.
Because the digest is unchanged, the candidate keeps what's attached to it in the registry: its SBOM and its signature. An image the job can't resolve fails it; nothing untested is filled in to complete the set.
ADR 0009 ("One repository per service; release candidates promote the images dev tested") gives the reason a candidate is never a rebuild: with one repository per service, a rebuild means five tags kept in step, and a rebuild isn't the bytes dev tested. The trade-off: a candidate is "whatever dev last ran successfully", a moment in time, not a commit per service chosen by a person. The release record restores that link.
Step 3: the bot opens the QA promotion; merging it is QA's approval¶
Author eshop-promotion, 1 commit, 1 change. The description says what merging does, lists five images by digest, and states "nothing was rebuilt".
The author is a project access token, eshop-promotion, stored as a protected, masked variable. v* is a protected tag only Maintainers can create, so nobody reaches that token by pushing a tag of their own.
- The Changes tab shows one file, and only lines ending in
# release-pin: qa - The merge request's own pipeline passed (
validaterenders every overlay and reads both pins) - Any older candidate's open promotion is closed
Step 4: deploy-qa deploys the pin and tests it¶
The merge changes QA's kustomization.yaml on main, and that path starts deploy-qa. It's the dev script with two differences: it takes deploy/ from the tag v0.10.0-rc.1 with git archive, and the images are the pinned digests. No registry lookup decides anything.
The last three lines are the ones that matter. The (release 0.10.0-rc.1) in brackets shows the pin chose what was deployed.
QA doesn't move until someone merges another promotion, so people can test there as long as they need. In the example release, sign-off follows within minutes.
Step 5: the sign-off merge request carries the evidence¶
After every deploy-qa, the job sign-off-mr checks QA's latest Deployment of the pinned candidate. If it succeeded, the job opens "Sign off v0.10.0-rc.1", whose only commit adds releases/0.10.0.md.
The first paragraph says merging is the sign-off and only a Maintainer's merge counts. Each image line ends in the commit it was built from and "SBOM attached; signed".
The thing being signed is in the diff the person reviews. The record names the candidate, each image's digest and source commit, the gates' pipelines, and QA's evidence: Deployment 14, job 59 and its Playwright report.
If QA's pin moves to another candidate, or a re-test fails, the job closes the stale merge request with a comment. A later pass opens it again.
Step 6: what sign-off refuses¶
Merging the record runs the job sign-off. scripts/sign-off.sh checks everything first and changes nothing until all of it passes. Each failure ends with a line starting "Sign-off refused:".
| It refuses when | Why it matters |
|---|---|
| the push doesn't add exactly one record naming an existing, annotated candidate tag | the record is the unit of sign-off |
| whoever merged isn't a Maintainer or Owner (access level 40 or more) | anyone else's merge signs off nothing |
main doesn't pin QA to exactly that candidate | you sign off what QA runs |
| QA's latest Deployment of it since the pin last changed didn't succeed | stale evidence is refused, not trusted |
a candidate image is missing, or an X.Y.Z image exists with another digest | release tags are never overwritten |
| a candidate image's digest differs from QA's pin or from the record | a tag repointed since would differ |
| an image's digest has no CycloneDX SBOM in the registry | every release ships its SBOMs |
the tag vX.Y.Z already exists from something else | version numbers are used once |
Then it acts, in a fixed order: copy each image to :0.10.0 by digest, push the annotated tag v0.10.0 on the candidate's commit, publish the GitLab Release with each SBOM as an asset, open the prod promotion. Images come before the tag so the tag never names images that don't exist. Every step is skipped if an earlier run did it, so a half-failed sign-off is finished by re-running the job.
Look at the deploy stage: deploy-prod and deploy-qa are manual and unstarted. A sign-off deploys nothing. Remember that manual deploy-qa; it's the first pitfall below.
One page answers who signed off, from which candidate, on what evidence. The assets below hold one <service>-0.10.0.cdx.json per image.
Step 7: the prod promotion is a nine-line diff¶
One file, +9 −10. Every changed line ends in # release-pin: prod. The extra deleted line is the first-release suspend marker (# release-pin-until: prod).
Merging it is the production approval. It can wait for a maintenance window, or never be merged; closing it costs nothing. The merge runs deploy-prod, which ends with 22 passed (3.4m), Smoke test of prod passed and Deployed: ... (release 0.10.0) in 4 minutes 28 seconds.
eshop-api's digest sha256:2fa4a298... sits in the release record, in merge request !3 as 0.10.0-rc.1, in !5 as 0.10.0, on the Release page and in prod's pin. In Harbor, one eshop-web artifact carries three tags: its main build tag, 0.10.0-rc.1 and 0.10.0.
Rollback is a promotion to an older release¶
There's no rollback command. A rollback is a promotion merge request that pins prod to an earlier release:
git checkout -b promote/prod-X.Y.Z origin/main
scripts/pin-release.sh prod X.Y.Z
git commit -am "eshop-prod: roll back to vX.Y.Z"
Without PIN_IMAGES, the script takes the digests from releases/X.Y.Z.md. That's why the record lists digests and why sign-off refuses a record that disagrees with the registry: the record is what a rollback pins.
A rollback moves images. It doesn't move data. eshop-api migrates the database forwards on start and nothing migrates it back, so the older release runs against the newer schema. And it needs an earlier release to go to: with only one release, the way back is forward with a patch.
- Check the data first:
git diff <earlier> <later> -- src/Eshop.Data/Migrationslists the migrations the older release doesn't know about - Check the release still exists:
git ls-remote --tags origin vX.Y.Zprints one line, and Harbor has theX.Y.Ztag for each service - Check the signing key that signed it is still trusted by the cluster
- Open the promotion with
scripts/promotion-pr.sh prod X.Y.Zand merge it like any other
Patches come from release/0.x, under one rule¶
There's no hotfix process either. A patch is a candidate X.Y.Z-rc.N with Z above 0.
- Fix it on the service's
mainfirst, by a normal merge request. Dev tests it. - Merge the same fix into the service's
release/0.x. That push runs the same gates and pushes an image taggedrelease-0.x-<sha>-<ts>. - Run
scripts/release.sh 0.10.1-rc.1in eshop-infra. release-candidatestarts fromv0.10.0's images and swaps in only the patched service's newerrelease-0.ximage.- From there it's the same flow: QA promotion, sign-off, prod promotion.
The untouched services in a patch are byte-for-byte the released ones. The caveat: a patched image never ran in dev, so QA is the first place the patched set runs together.
The one rule: every fix that lands on a release/N.x branch must also land on main. Otherwise the next minor, made from main, brings the bug back.
scripts/release.sh enforces it at the one moment breaking it would lose work: before merging main into release/N.x for a new minor, it runs git cherry over the branch's commits and refuses if any is missing from main by patch-id. That check covers eshop-infra only; in the service projects the rule rests on order of work and review.
Pitfalls, and the guard for each¶
| Pitfall | Why it happens | The guard in place |
|---|---|---|
| Sign-off refuses with QA green | Every main pipeline that doesn't change QA's pin carries deploy-qa as a manual job, and GitLab 19.5 lists such a job as a Deployment with status blocked from the moment the pipeline exists. The sign-off merge creates one itself, so "QA's latest Deployment" is a job nobody started. | scripts/lib/qa.sh skips blocked Deployments and reads the one before. If a script reads a platform's records as evidence, learn every state they can have, including the ones that mean "nothing happened". |
Harbor refuses a repository named eshop/manifests | Harbor reads /manifests/ in an address as the registry API's own word (/v2/<name>/manifests/<reference>), cuts the name to eshop and answers "invalid repository name". | The package is eshop/eshop-manifests. Don't name a repository after a word of the registry API. |
| A file changes what a deploy does, and merging it deploys nothing | On a push, a deploy job runs only when a path in its changes: list changed. clusters/eshop-prd1/pull-deploys.txt lists the environments the cluster pulls, so editing it changes how a deploy works. | The file is in the changes: list of deploy-dev and deploy-thirdparty. When a file starts to change what a job does, add it to the paths that start the job. |
| Retrying the pipeline doesn't retry the deploy | Retrying a service's failed main pipeline re-runs its failed jobs, not its trigger job. | Retry the deploy trigger job itself, or start a pipeline by hand on eshop-infra's main. |
| A pipeline started through the API never runs | workflow: rules that accept only push and web drop a pipeline started through the REST API without an error, and it triggers no deploy. | The shared rules accept api as well, as in the trigger job's rules above. |
What production would change¶
- One cluster for everything is a lab arrangement. Namespaces, network policies and a limited deployer separate the environments, but they share nodes, the Gateway and the control plane. Give prod its own cluster.
- One account makes every decision. In the example release,
@rootmerges !3, !4 and !5 within twelve minutes. The separation of duties is in the design, not the practice. Give the three merges to different roles, and check which approval rules your GitLab edition enforces; Community Edition has fewer than the paid ones. - The smoke test writes to prod. It creates Customers, a Contract and an Auction on every deploy. That's fine against mocks. With real customers you need a read-only or clearly marked synthetic check.
- Pulling keeps the cluster's write credential out of CI, not the signing key. Whoever can run a job on eshop-infra's protected
maincan still sign a package the cluster will apply. The control is still on what reachesmain(post 02). - The overlay follows
main, not the release. The digest fixes the images and the tag fixesdeploy/apps/<env>, butclusters/eshop-prd1/apps/<env>and its components come frommainat deploy time. Review component changes with all three environments in mind.
Summary¶
- Build each image once; name it by digest everywhere a decision is recorded
- Let dev follow
mainautomatically; move QA and prod only by merging a pin change - Keep the pin in Git as marked lines, written by one script and validated on every merge request
- Make the release candidate a copy of what dev last ran successfully (
crane copy, by digest), never a rebuild - Have the pipeline publish signed manifests and the cluster verify and apply them; give CI a read-only kubeconfig
- Make the deploy job wait for the exact digest it published before testing
- Count a deploy as done only when the smoke test passed, and record it somewhere a script can query
- Put the sign-off evidence in the diff: digests, source commits, SBOM status, the QA Deployment
- Re-check everything at the moment of the sign-off merge, and make every step safe to re-run
- Roll back with the same promotion merge request, pinned from the release record
- Land every release-branch fix on
mainfirst, and have the release script refuse when one is missing
Next: Post 06: The platform: the NKP cluster underneath all of this, and the identities that are allowed to read it, deploy to it and administer it.
-
GitLab Docs, Environments: an environment is a deployment target, and deploy jobs create its deployments. ↩
-
GitLab Docs, Downstream pipelines: trigger jobs, multi-project pipelines,
strategy: dependandstrategy: mirror, and recreating a downstream pipeline by retrying its trigger job. ↩ -
Sigstore, Signing other types: cosign signs any artifact stored in an OCI registry, not only container images. ↩
-
Flux, OCIRepository:
.spec.verifywithprovider: cosignand a Secret of trusted public keys. ↩ -
Flux, Kustomization:
.spec.serviceAccountNameimpersonation,.spec.pruneand.spec.wait. ↩ -
go-containerregistry, crane copy: "Efficiently copy a remote image from src to dst while retaining the digest value". ↩
Discussion
Have thoughts on this post? Share them below — questions, corrections, or your own experience are all welcome.











