# Tasks ## 1. Manifest check first (red) - [x] 1.1 Add `deploy/check.sh` and its rule script. - The script renders `deploy/k8s/overlays/prod` with pinned kubectl and kubeconform images, then applies the four rules: - public routes reach only the portal and the exact webhook path; - no image on `latest` or 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-test` fails 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.yaml` for `--release`). The first red run passed on an empty render, so the container now stops on the first error, and `--full` requires all ten Deployments and Services. ## 2. Base manifests - [x] 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 from `docs/deployment.md` sections 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=true` is now in the settings; - service-email's overall health is 503 without a mail server, so the startup probe uses the liveness path. - [x] 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 each `application.yml` is supplied. Deliberately unset: the email keys, `SMSS360_EMAIL`, `CUSTOMER_PORTAL_BASE_URL`, Jumio, and `XXL_JOB_TOKEN` (listed in section 2). - The WhatsApp Secret reference is `optional: true`, so mobile-api starts while WhatsApp is off. ## 3. Prod overlay, release pinning and routes - [x] 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_PROJECT` and the rest); - the pull secret; - two Traefik IngressRoutes with TLS. Verify: `deploy/check.sh` passes on the overlay (task 1 goes green). - [x] 3.2 Add `deploy/set-release.sh `, which rewrites the overlay's ten tags. - Verify: run it with a test SHA, then confirm that `check.sh` passes and `git diff` shows exactly ten tag lines changed. Running it with `latest` or a non-hex value is refused. - Done: ten lines change. Running it with `latest` or 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…` and `1e45…` both render and pass. ## 4. Secrets - [x] 4.1 Add `deploy/k8s/secrets.example/`: one `.env` template per Secret, plus an `appkeys.json` and a `key.json` placeholder, all with placeholders only. - Add `deploy/k8s/secrets/` to `.gitignore`. - Verify: a filled-in file under `deploy/k8s/secrets/` is listed by `git check-ignore`. - [x] 4.2 Add `deploy/create-secrets.sh`. It creates or updates each Secret through `kubectl 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-run` against 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 `MYSQLPWD` is refused, and so is a placeholder `MYSQLPWD`. - The real path ran in the check container, with `kubectl apply` stubbed: - the `co-lite` namespace is created first, because the first run comes before any apply; - seven Secrets carry the right keys and decode to the filled values; - the registry Secret is a dockerconfigjson for `gitea.containerverse.dev`; - no value appears on stdout. - mobile-api's probes were proven on a throwaway container. Without `MANAGEMENT_HEALTH_PROBES_ENABLED` its liveness and readiness paths are missing; with it, all three return 200. ## 5. CI and docs - [x] 5.1 Add a `deploy/check.sh` step to `.gitea/workflows/ci.yml`, before the image push. - Verify: the workflow file parses, and the step runs locally with the same command. - [x] 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 - [x] 6.1 Run the full check: `deploy/check.sh` and its self-test, the repository's existing build and tests (unchanged), and `openspec validate add-k8s-deployment --strict`. - Done: the check and the self-test pass, and `openspec validate --strict` passes. - Maven and vitest were not re-run: no module source or build file changed. Only `deploy/`, `docs/`, `.gitignore` and the CI file changed. - [ ] 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 to `main` and 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.