From 973e7af303cd9bd5cca7061ed3685c2ae4c25d07 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 12:07:32 +0800 Subject: [PATCH] docs: deployment handover note for the cluster manager Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf --- docs/deployment-handover.md | 117 ++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 docs/deployment-handover.md diff --git a/docs/deployment-handover.md b/docs/deployment-handover.md new file mode 100644 index 0000000..9cf334d --- /dev/null +++ b/docs/deployment-handover.md @@ -0,0 +1,117 @@ +# Deployment handover: ins-landing-page + +For: cluster manager. Date: 2026-12-01. + +## What this is + +A single landing page for Infinity Networks Security's hotel technology services, with a lead form. Visitors submit name, work email, phone, company and the service they're interested in. Leads are stored in PostgreSQL and read by the sales team in DBeaver or as a CSV export. There is no admin UI. + +- Public URL: `https://ins-landing.containerverse.dev` +- Repo: `gitea.containerverse.dev/ngqile/ins-landing-page`, moving to `solvway/ins-landing-page` +- App: Node 22, one dependency (`pg`), image `gitea.containerverse.dev/solvway/ins-landing-page:ins-landing-page-prd-latest` +- Deploy pattern: the same as **dynamic-qr** (Traefik Gateway API, cert-manager, Longhorn, Calico, `krrd.sh` rollout from CI) + +## What gets deployed + +Everything lives in namespace `ins-landing-page`. Nothing outside it is changed. + +| File | Contents | +|---|---| +| `k8s/00-namespace.yaml` | Namespace | +| `k8s/20-postgres.yaml` | Postgres 18 StatefulSet `postgres` (1 replica), Longhorn PVC `ins-landing-page-postgres` (2 Gi, RWO), headless Service `postgres` | +| `k8s/40-app.yaml` | Deployment `ins-landing-page` (1 replica, uid 1000, read-only root filesystem), init container waiting for Postgres, Service on port 3000 | +| `k8s/50-gateway.yaml` | Certificate `ins-landing-page-tls` (ClusterIssuer `lets-encrypt`, HTTP-01), Gateway (HTTP 8000 → redirect, HTTPS 8443), HTTPRoutes, Traefik Middleware `lead-rate-limit` | +| `k8s/60-network-policy.yaml` | Default deny; allows Traefik → app (3000), app → Postgres (5432), Traefik → ACME solver (8089) | +| `k8s/examples/secret.yaml` | Example only, never applied (`k apply -f k8s/` does not recurse) | + +Resource requests are small: app 20m CPU / 48 Mi (limit 192 Mi); Postgres 100m CPU / 128 Mi (limit 1 Gi). + +The app creates its `leads` table itself on first start. There is no migration step. The schema is in `docs/schema.sql` for reference. + +## Before the first install + +1. **Repo transfer.** Move the repo to the `solvway` org. CI needs the org secrets `PACKAGE_USER`, `PACKAGE_RW_KEY`, `DRONECICD_SSH_USERNAME`, `DRONECICD_SSH_HOST`, `DRONECICD_SSH_KEY`, `TELEGRAM_TOKEN`, `TELEGRAM_TO` and, optionally, `MICROSOFT_TEAMS_WEBHOOK_URL`: the same set as dynamic-qr. +2. **Merge PR #1 into `main`, only after the transfer.** The push to `main` runs CI: it runs the tests against a throwaway Postgres, then builds and pushes the image. On the first run the rollout step finds no Deployment and skips itself; that's expected. +3. **DNS.** Add `ins-landing.containerverse.dev` in Cloudflare, pointing at the cluster like the other `containerverse.dev` hosts (proxied). +4. **Backups. Please confirm before go-live.** The leads are the only business data, and they live only on the `ins-landing-page-postgres` volume. These manifests set up no backup. Either confirm that a Longhorn recurring backup covers this volume, or schedule a `pg_dump`. + +## First install + +On the microk8s host (`k` = `microk8s kubectl`): + +```bash +k apply -f k8s/00-namespace.yaml + +# Database password. Hex only: it is embedded in a postgres:// URL. +k -n ins-landing-page create secret generic ins-landing-page-db \ + --from-literal=POSTGRES_PASSWORD="$(openssl rand -hex 24)" + +# Registry pull secret, as for dynamic-qr +k -n ins-landing-page create secret docker-registry regcred \ + --docker-server=gitea.containerverse.dev --docker-username= --docker-password= + +k apply -f k8s/ +k -n ins-landing-page rollout status statefulset/postgres +k -n ins-landing-page rollout status deployment/ins-landing-page +``` + +## Check it works + +```bash +k -n ins-landing-page get pods # postgres-0 and ins-landing-page-… Running +k -n ins-landing-page get certificate # ins-landing-page-tls READY=True (can take a minute) +k -n ins-landing-page logs deploy/ins-landing-page # "listening on :3000" +curl -sI https://ins-landing.containerverse.dev/ # HTTP/2 200 +curl -sI http://ins-landing.containerverse.dev/ # 301 to https +``` + +To check the form without creating a lead, submit it with a Gmail address. The page shows "Please use your work email…" and nothing is stored. A real test submission writes a row. If you make one, delete it afterwards, or tell sales to ignore it. + +## Updates + +- **Code:** every push to `main` runs the tests, builds `ins-landing-page-prd-latest`, and rolls the Deployment through `./krrd.sh ins-landing-page ins-landing-page`. It's guarded the same way as dynamic-qr, so an older run never rolls back a newer commit. +- **Manifests:** changes are applied by hand with `k apply -f k8s/`. +- **Rollouts:** the app pod sleeps 3 s before shutting down, so Traefik stops routing to it first and form posts aren't dropped. + +## Day-to-day operations + +**Logs:** `k -n ins-landing-page logs deploy/ins-landing-page`. Only errors are logged, never lead data or passwords. + +**Export leads to CSV** (read-only, times in Malaysia time): + +```bash +k -n ins-landing-page exec -i postgres-0 -- psql -q -v ON_ERROR_STOP=1 -U ins -d ins -f - \ + < docs/export-leads.sql > leads.csv +``` + +**DBeaver access for sales or ops:** Postgres is not exposed outside the cluster. + +```bash +k -n ins-landing-page port-forward svc/postgres 15432:5432 +# from another machine: ssh -L 15432:127.0.0.1:15432 @ +``` + +Connect to `127.0.0.1:15432`, database `ins`, user `ins`. Get the password with `k -n ins-landing-page get secret ins-landing-page-db -o jsonpath='{.data.POSTGRES_PASSWORD}' | base64 -d`. Recommend a **read-only connection** in DBeaver: this is the live data. + +**Changing the database password:** the password is read only when the database is first created. Run `ALTER USER ins PASSWORD ''` in Postgres first, then update the secret and restart the app. Changing only the secret locks the app out, and it will crash-loop. + +## Things to know + +- **Rate limit.** `POST /api/leads` allows 5 requests per minute per visitor (burst 5), keyed on the right-most `X-Forwarded-For`, which Cloudflare sets. This assumes Traefik trusts that header only from Cloudflare, as it does for dynamic-qr's office-only middleware. If Cloudflare's proxy is turned off, all visitors share one limit. +- **Postgres.** It runs as the `ins` user, which also owns the database. Every query is parameterised. The image tag is `postgres:18`, the major version only, as in dynamic-qr. +- **Personal data (PDPA).** Leads contain names, emails and phone numbers. Keep CSV exports out of shared drives and delete them when done. +- **Not wired yet.** There are no metrics or alerts. `GET /` is the only health signal; the probes use it. + +## Rollback + +- **App:** the image tag is mutable (`…-prd-latest`), so roll back by reverting the commit on `main` and letting CI rebuild. In an emergency, `k -n ins-landing-page scale deploy/ins-landing-page --replicas=0` takes the page down without touching the data. +- **Data:** never delete the PVC `ins-landing-page-postgres` without a backup. Deleting the namespace deletes it. + +## Open items, not blocking the install + +- Content placeholders on the page: follow-up timeframe, installation timeline, hotel photo. These are with the page owner. +- Backup confirmation (see above). + +## Contact + +Questions about the app: the repo owner (ngqile). Full details: `README.md` in the repo.