deploy/k8s holds a Kustomize base (a Deployment and Service for each of the ten images, with the probes, settings and mounts from docs/deployment.md) and a prod overlay that pins every image to one commit SHA and routes only the admin portal and mobile-api's exact WhatsApp webhook path through Traefik with TLS. Secrets never enter git: deploy/k8s/secrets.example holds placeholders, the filled copy in deploy/k8s/secrets is ignored, and deploy/create-secrets.sh loads it without printing a value. deploy/set-release.sh pins or rolls back the release. deploy/check.sh (also a CI step) renders the overlay in one pinned container, validates it with kubeconform and refuses public routes to internal services, latest or untagged images, Secret data or literal secret env values, mixed SHAs and a second or rolling service-counter; --release also refuses unfilled cluster facts. --self-test proves each rule fires on its fixture. OpenSpec change: add-k8s-deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
5.7 KiB
5.7 KiB
Tasks
1. Manifest check first (red)
- 1.1 Add
deploy/check.shand its rule script.- The script renders
deploy/k8s/overlays/prodwith pinned kubectl and kubeconform images, then applies the four rules:- public routes reach only the portal and the exact webhook path;
- no image on
latestor without a tag; - no Secret data in the output;
- service-counter has exactly one replica.
- Add rule fixtures under
deploy/check-fixtures/: one passing set and one failing set per rule. - Verify:
deploy/check.sh --self-testfails each bad fixture with a message naming the offending object, and passes the good one. - Running it against the still-missing overlay fails.
- Done: 12 fixtures (one per rule, plus
bad-placeholder.yamlfor--release). The first red run passed on an empty render, so the container now stops on the first error, and--fullrequires all ten Deployments and Services.
- The script renders
2. Base manifests
- 2.1 Add
deploy/k8s/base/: a Deployment and a Service for each of the ten images, with the names, ports, probes, environment (secret refs and plain values) and mounts fromdocs/deployment.mdsections 1, 6 and 7.- service-counter: one replica,
strategy: Recreate. - Verify:
kubectl kustomize deploy/k8s/base, run in the check container, renders the ten Deployments and ten Services. kubeconform passes. - Done: 20 resources, all valid. The probe paths were checked against the running local containers. Two fixes came out of that:
- mobile-api answered 404 on liveness and readiness, so
MANAGEMENT_HEALTH_PROBES_ENABLED=trueis now in the settings; - service-email's overall health is 503 without a mail server, so the startup probe uses the liveness path.
- mobile-api answered 404 on liveness and readiness, so
- service-counter: one replica,
- 2.2 Cross-check the base against
local/docker-compose.yml: every variable a service reads locally is either set or deliberately left unset in the base.- Verify: a scripted diff of the variable names per service shows no unexplained gaps. Record the deliberate ones in
docs/deployment.md. - Done: every
${…}in eachapplication.ymlis supplied. Deliberately unset: the email keys,SMSS360_EMAIL,CUSTOMER_PORTAL_BASE_URL, Jumio, andXXL_JOB_TOKEN(listed in section 2). - The WhatsApp Secret reference is
optional: true, so mobile-api starts while WhatsApp is off.
- Verify: a scripted diff of the variable names per service shows no unexplained gaps. Record the deliberate ones in
3. Prod overlay, release pinning and routes
-
3.1 Add
deploy/k8s/overlays/prod/. It sets:- the namespace;
- the
images:list with one SHA for all ten images; - the plain settings (
ADMIN_PORTAL_BASE_URL,REDISHOST,MYSQLHOST,GCP_PROJECTand the rest); - the pull secret;
- two Traefik IngressRoutes with TLS.
Verify:
deploy/check.shpasses on the overlay (task 1 goes green). -
3.2 Add
deploy/set-release.sh <sha>, which rewrites the overlay's ten tags.- Verify: run it with a test SHA, then confirm that
check.shpasses andgit diffshows exactly ten tag lines changed. Running it withlatestor a non-hex value is refused. - Done: ten lines change. Running it with
latestor a short SHA is refused. - An all-digit SHA broke the render (YAML read it as a number), so the tags are now quoted.
2222…and1e45…both render and pass.
- Verify: run it with a test SHA, then confirm that
4. Secrets
- 4.1 Add
deploy/k8s/secrets.example/: one.envtemplate per Secret, plus anappkeys.jsonand akey.jsonplaceholder, all with placeholders only.- Add
deploy/k8s/secrets/to.gitignore. - Verify: a filled-in file under
deploy/k8s/secrets/is listed bygit check-ignore.
- Add
- 4.2 Add
deploy/create-secrets.sh. It creates or updates each Secret throughkubectl create ... --dry-run=client -o yaml | kubectl apply -f -. It refuses if a template key is missing or still holds a placeholder, and it never prints a value.- Verify: run it with
--dry-runagainst a filled test folder; it prints only the Secret names and the key names. - Verify: a missing key is refused, and the refusal names the key.
- Done: the dry run lists seven Secrets with their key names only. A missing
MYSQLPWDis refused, and so is a placeholderMYSQLPWD.
- Verify: run it with
5. CI and docs
-
5.1 Add a
deploy/check.shstep to.gitea/workflows/ci.yml, before the image push.- Verify: the workflow file parses, and the step runs locally with the same command.
-
5.2 Rewrite the deploy steps in
docs/deployment.md(sections 2 and 9) around the manifests:- create the Secrets, set the release, run the check, apply, wait for the rollout;
- roll back;
- list the open cluster facts from
design.md.
Verify: following the doc's commands in order against the check container renders and passes.
6. Verification
- 6.1 Run the full check:
deploy/check.shand its self-test, the repository's existing build and tests (unchanged), andopenspec validate add-k8s-deployment --strict.- Done: the check and the self-test pass, and
openspec validate --strictpasses. - Maven and vitest were not re-run: no module source or build file changed. Only
deploy/,docs/,.gitignoreand the CI file changed.
- Done: the check and the self-test pass, and
- 6.2 Run a server-side dry run against the real cluster:
kubectl apply -k deploy/k8s/overlays/prod --dry-run=server, by the owner or with the owner's cluster access. Record the result here.- This needs the open cluster facts filled in and access to the cluster. If access is not available before archive, leave the task unticked with a note, as was done for the WhatsApp e2e.
- Open (2026-12-03): there is no cluster access from this machine, and the cluster facts are not yet given. Owed by the owner with the first real apply.
Workflow follow-up
- Branch from
origin/main, then open a PR tomainand merge it. - Archive the change on its own branch, with its own PR.
- The first real apply happens with the owner, after the database package and Secrets are in place.