6 KiB
Site images: immutable sha tags pinned in git
Every first-party site image runs from a tag pinned in this repo and is rolled
by Flux. CI builds and pushes :<commit-sha> and prints the exact ref; the
operator copies that ref into the Deployment manifest. There are no cluster
credentials in any site repo — CI cannot roll a Deployment and cannot read a
kubeconfig.
This replaces the old model (:latest + imagePullPolicy: Always + CI patching
kubectl.kubernetes.io/restartedAt through a site-deployer ServiceAccount
token). That path is gone: the SA/Role/RoleBinding were removed and the
KUBE_CONFIG action secrets deleted.
Operator flow
-
Push to a site repo (or
workflow_dispatchit). The workflow builds the amd64 image, pushes<registry>/<image>:<sha>, and ends with a### Pin this in sirius/homek8s …step that prints the ref. It also pushes:latest, but nothing in the cluster reads:latest— it is a convenience pointer for humans only. -
Edit the Deployment in
apps/base/<app>/deployment*.yaml:image: forgejo.siriusdevops.com/sirius/<image>:<sha> imagePullPolicy: IfNotPresent -
Commit + push
master, then force the Flux recheck (gitrepository first, kustomization second — anappsannotate that still reports the previous sha has not fetched the commit):kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite kubectl -n flux-system annotate kustomization apps reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite -
Verify: the pod template changed, so the Deployment rolls within ~1m and the pod reports the pinned ref.
kubectl -n <ns> get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[0].imageID}{"\n"}{end}'imageIDmust name:<sha>and carry the digest the registry returns for that tag (Docker-Content-Digest, below).
Rollback is git revert of the pin commit — Flux reconciles back in ~1m.
Why the site repos are not Flux sources
The only GitRepository cluster-wide is flux-system → sirius/homek8s. Flux
owns the manifests; the site repos own only their image builds. The content
revision a visitor sees is therefore chosen by the tag committed here, not by
whatever CI pushed last. A site repo push alone changes nothing in the cluster.
Current pins
| Namespace | Deployment | Image ref |
|---|---|---|
| siriusdevops | siriusdevops-site | siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13 |
| siriusdevops | siriusdevops-contact | siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13 |
| sirius-growth | sirius-growth-site | sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b |
| sirius-growth | sirius-growth-portal | sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481 |
| sirius-growth | sirius-growth-contact | sirius-growth-contact@sha256:cba0a5c67fee639dea78b568cbdf5889b2c78cc2c9cf85b02964ce17d60aab31 |
| piedmont | piedmont-site | phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e |
| piedmont | piedmont-contact | phs-contact@sha256:da61fc7943881f801fe6201749c01e364df6475d2460d6d17c8a6b48009f0056 |
Each pin was chosen as the tag whose manifest is the image already running (identical config digest), so pinning was a no-op for visitors.
The two digest-pinned contact APIs
sirius-growth-contact and phs-contact have no CI build path: neither
sirius-growth/.forgejo/workflows/* nor sirius/websites/.forgejo/workflows/deploy-handyman.yml
builds them (the source dirs contact-api/ and phs-contact-api/ exist, but no
workflow pushes them; the registry only ever held :latest). They were built by
hand before the workflows were trimmed. Per the no-invented-pipelines rule they
are pinned by @sha256: digest — immutable, but there is no tag for an operator
to bump. If a build step is ever added for them, move them to :<sha> like the
rest. Both deployments run the same image content their pods already ran.
Registry facts
-
Registry:
forgejo.siriusdevops.com(Forgejo packages,[packages] ENABLED = true). -
Reads/writes need a
read:package/write:packagescoped token; the stored~/.git-credentialsoauth2 token is git-scoped and is rejected by/v2/. -
Tags do not expire.
package_cleanup_rulehas zero rows andapp.inihas no cleanup cron, so a pinned:<sha>stays resolvable. -
Prove a pin
Tfor imageIwithout pulling anything:curl -s -u "sirius:$TOK" -H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json' \ -D - -o /dev/null "https://forgejo.siriusdevops.com/v2/sirius/$I/manifests/$T" | grep -i docker-content-digest
Pitfalls
docker buildx imagetools create(the:latestpromote step) wraps a single-arch image in an index, so the:latestdigest differs from the:<sha>digest even though the content is identical. Compare the config digest, or compare the running pod's digest to the:<sha>tag, never:latestvs the sha tag.- The amd64 runner's job image (
node:20-bullseye) has no docker CLI, so the site workflows fetch the binaries each run — and both hosts have been observed to stall for the full 300s (curl: (28) … 0 out of 0 bytes). The static docker client triesdownload.docker.comthenmirrors.aliyun.com; buildx is copied out of thedocker:27-dindimage the runner already holds (docker create docker:27-dind→docker cp …/cli-plugins/docker-buildx), with the GitHub release URL only as a fallback. Before that change a three-attempt retry of the GitHub CDN failed all three times inside a job container while the same URL fetched fine outside one. runs-onmatters: site images arelinux/amd64and only siriussec serves them. Build them ondocker-amd64/deploy-arm64, never on the arm64dockerrunner.