The cluster pulls the site's images; CI only rolls them out
Images from GHCR instead of builds on the node, a deploy account that can do two verbs on two objects, and a preprod namespace beside production
The node stopped building the site from a working directory and started pulling the images CI publishes. The deploy account can touch two named deployments and nothing else, and preprod got its own namespace and database.
At first the site reached the cluster the simple way: a script copied a working directory to the node, and the images were built there. That path is fragile. What runs is whatever was on a laptop at the time, and nothing connects it to a commit. Meanwhile the site's CI was already publishing images to GHCR on every push to main, and nothing was pulling them.
Pull, don't build
Both deployments, web and api, now pull their images from GHCR. The packages are private, so the cluster holds a pull secret for the registry. The old copy-and-build script stays only as a documented fallback, and its header now says so.
A deploy account that can do almost nothing
The deploy job in the site's CI needs to talk to the cluster. The obvious credential to hand it is the cluster administrator's, which would put a key that can do anything into GitHub's secret storage in order to perform two verbs on two objects.
Instead, the cluster has a dedicated ServiceAccount:
exactly what a rollout needs.
can say why. An image that cannot be pulled is the likely failure, and it is invisible without this.
namespace.
The credential is generated by a script the owner runs, and goes from the terminal into GitHub and nowhere else.
Preprod beside production
The next step added a preprod namespace that tracks main, with the same two deployments and:
application. Sharing a server would have meant changing the application to express an infrastructure decision, and would have left preprod holding a credential that can write production's data.
limited to the owner.
Its API configuration is generated from the application's schema rather than copied from production. Since then, a merge to main lands on preprod, and only a release tag reaches production.