Skip to content

Kubernetes kustomize manifests + cargo xtask release that pins the image tag - #36

Merged
schmitch merged 2 commits into
mainfrom
claude/kubernetes-kustomize-release
Oct 20, 2026
Merged

schmitch merged 2 commits into
mainfrom
claude/kubernetes-kustomize-release

Conversation

@schmitch

Copy link
Copy Markdown
Member

Summary

Kubernetes manifests (deploy/kubernetes), kustomize with components

  • base/: the Forge server. It has a Deployment, Service, ServiceAccount and a ConfigMap generator for non-secret FORGE_* settings. Secrets come from a forge-env Secret through envFrom.
    • Probes follow docs/deployment.md: a startup probe on /healthz gives migrations 5 min, liveness is /healthz, readiness is /readyz.
    • Shutdown: preStop sleeps 10 s, the termination grace period is 300 s, and rolling updates use maxUnavailable: 0.
    • The root filesystem is read-only. /tmp is an emptyDir (6 Gi, above the 4 GiB staging budget).
    • It runs as non-root with RuntimeDefault seccomp and drops all capabilities.
    • enableServiceLinks: false. A Service named forge would otherwise inject FORGE_PORT=tcp://…-style variables into Forge's own config namespace.
  • components/:
    • ingress: Ingress with TLS and ingress-nginx body-size/buffering/timeout annotations.
    • httproute: a Gateway API HTTPRoute instead of the Ingress.
    • redis: in-cluster Redis with a password and a NetworkPolicy.
    • high-availability: 2 replicas, topology spread and a PodDisruptionBudget.
    • postgres: an in-cluster PostgreSQL 17 StatefulSet.
    • s3-versitygw: an in-cluster versitygw on a PersistentVolume.
    • image-latest: runs :latest with imagePullPolicy: Always.
  • overlays/production: external PostgreSQL and S3, Redis, 2 replicas, Ingress.
  • overlays/evaluation: everything in-cluster.
  • Both overlays generate forge-env from a git-ignored forge.env, with a committed forge.env.example. Both namespaces enforce the restricted Pod Security Standard, and every workload meets it.
  • The backing-service components read their passwords from the same forge-env Secret. They build Forge's connection URLs with $(VAR) expansion from envFrom.
  • deploy/ is now in .dockerignore, so a local forge.env can't end up in the image build context.

Pinned image tag, updated before the tag is created

  • The base pins ghcr.io/schmitch/forge with images: newTag: 0.1.0.
  • New cargo xtask release <version> [--no-tag]:
    • Sets the version in Cargo.toml, Cargo.lock (cargo update --workspace), web/package.json and the base's newTag.
    • Renames ## [Unreleased] in CHANGELOG.md to the new version and updates the links at the bottom. A section that already exists is kept as is.
    • Commits release: vX.Y.Z and creates the annotated tag. It never pushes.
    • It refuses a dirty tree, an existing tag, a bad version, an empty [Unreleased], and tagging off main/master. --no-tag is the release-PR flow for a protected main.
  • release.yml now also refuses a tag whose Kubernetes base names a different version. So deploy/kubernetes/base?ref=vX.Y.Z always deploys image X.Y.Z.

CI

  • New kubernetes job in ci.yml. It renders every overlay, and the base with each component on its own, then validates the output with kubeconform -strict (Kubernetes 1.33 schemas plus the Gateway API CRD catalog).
  • kustomize 5.7.1 and kubeconform 0.7.0 are downloaded with pinned SHA-256 checksums (checked against the upstream checksum files).

Docs

  • deploy/kubernetes/README.md, a "Releasing" section in DEVELOPMENT.md, links from README.md and docs/deployment.md, and CHANGELOG.md entries.

Test plan

  • cargo test -p xtask: 8 new unit tests for the version, newTag, package.json and changelog edits. One of them checks that the real files each match exactly once.
  • cargo clippy -p xtask --all-targets -D warnings, cargo fmt --all --check
  • .github/scripts/kustomize-check.sh 1.33.0 locally: 70 resources in 9 renders, all valid (strict).
  • Ran cargo xtask release end to end in a scratch clone:
    • 0.2.0 produced the expected 5-file commit and tag.
    • The release.yml guard and the release-notes awk both work on that commit.
    • 0.1.0 (the first release) tags without an empty commit.
    • Every refusal case fails before writing any file.
    • --no-tag on a branch commits only.
  • Simulated the CI install step (download, sha256sum -c, extract) locally.
  • Not applied to a live cluster. No cluster is reachable from this environment. The evaluation overlay is worth a kubectl apply -k on kind/k3d before merging.

Notes

  • release.yml already publishes to ghcr.io/schmitch/forge on v*.*.* tags, but no tag exists yet, so no image has been published. cargo xtask release 0.1.0 && git push --atomic origin main v0.1.0 is the first release.
  • GHCR packages can start out private. If so, either make the package public after the first push or add imagePullSecrets to the forge ServiceAccount.
  • The preStop.sleep action needs Kubernetes 1.30 or later.

Generated by Claude Code

A base for the Forge server (Deployment, Service, ServiceAccount, a
ConfigMap of non-secret FORGE_* settings; secrets from a `forge-env`
Secret), components for an Ingress or HTTPRoute, in-cluster Redis,
PostgreSQL and versitygw, two replicas with a PDB, and following
:latest, plus a production and an evaluation overlay. Every workload
meets the restricted Pod Security Standard. The base pins the image
to the release version.

CI renders every overlay and the base with each component and
validates the output with kubeconform (strict).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hTuRP6x9Hu6EqeHq2Ce7a
`cargo xtask release <version>` sets the version in Cargo.toml,
Cargo.lock, web/package.json and the image tag of the Kubernetes base,
turns CHANGELOG.md's [Unreleased] section into the release's, commits
and creates the annotated tag (default branch only; --no-tag for a
release pull request). It never pushes.

The release workflow now also refuses a tag whose Kubernetes base names
another image version, so the manifests at a tag always deploy that
tag's image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hTuRP6x9Hu6EqeHq2Ce7a
@schmitch
schmitch marked this pull request as ready for review October 20, 2026 18:40
@schmitch
schmitch merged commit bce2ac8 into main Oct 20, 2026
9 checks passed
@schmitch
schmitch deleted the claude/kubernetes-kustomize-release branch October 20, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants