Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
23 KiB
Co-Lite Deployment Handover
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The deployer writes the manifests and rolls them out. The database package goes to the DBA.
Spec: openspec/specs/release-packaging/spec.md. Local stack for comparison: local/README.md.
1. Images
CI (.gitea/workflows/ci.yml) builds every module on each push to main, runs all tests, and only then pushes. Each image is tagged with the commit SHA and with latest. Deploy SHA tags. Roll back by deploying the previous SHA.
Image (gitea.containerverse.dev/solvway/…) |
Kubernetes Service name (must match) | Port | Exposed |
|---|---|---|---|
co-lite-admin-portal |
admin-portal |
3000 | Yes, through Traefik |
co-lite-mobile-api |
mobile-api |
80 | No, internal only |
co-lite-api-gateway |
api-gateway |
80 | No, internal only |
co-lite-service-auth |
service-auth |
80 | No |
co-lite-service-system |
service-system |
80 | No |
co-lite-service-counter |
service-counter |
80 | No |
co-lite-service-member |
service-member |
80 | No |
co-lite-service-log |
service-log |
80 | No |
co-lite-service-email |
service-email |
80 | No |
The Service names matter:
- The gateway routes to
http://service-auth,http://service-systemand so on, on port 80. The names are fixed in its config. - mobile-api and the portal find the gateway and mobile-api through
APIGATEWAYURLandMOBILE_API_BASE_URL.
Health probes:
- Java services: liveness
GET /actuator/health/liveness, readinessGET /actuator/health/readiness. Spring Boot turns these on by itself on Kubernetes.GET /actuator/healthalso works everywhere. - Admin portal: it has no health endpoint. Use a TCP probe on port 3000, or
GET /login, which returns 200 without a session.
The Java images run as root and listen on port 80 (the base image sets no user). A cluster that enforces runAsNonRoot or the restricted Pod Security level must allow them.
Images carry no configuration or secrets. Everything below is supplied at runtime. CI fails a build whose image holds a key file or a secret with a built-in default (local/image-check.sh). Leave BUILD_PROFILE unset. JAVA_OPTS is optional, for example -Xmx512m.
2. Order of setup
- The DBA prepares MySQL (section 3).
- Create the Pub/Sub topics and the service-account key (section 5).
- Create the Secrets and mounted files (sections 6 and 7).
- Deploy, in this order:
service-system,service-auth,service-counter,service-member,service-log,service-email;api-gateway;mobile-api;admin-portal.
- Add the Traefik route (section 8).
- Sign in as the first admin at
https://co-lite.containerverse.devand set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
3. Database (for the DBA)
Server: MySQL 8.0, with these two settings:
log_bin_trust_function_creators = 1. The schema creates functions and triggers, and with binary logging on that otherwise needs the SUPER privilege, which managed MySQL does not grant.innodb_strict_mode = OFF. Some inherited tables are wideutf8mb3tables that strict mode rejects.
Connections: the services connect without TLS (useSSL=false in their datasource URL), so the server must accept non-TLS connections from the cluster. To require TLS instead, override SPRING_DATASOURCE_URL on each database service.
Package: this package sets up an empty server once. Later changes ship their own SQL, which is applied on top of it. The files are in openspec/changes/archive/2026-11-30-add-release-ci-packaging/sql/. Run the files in this order, on an empty server:
| File | What it does |
|---|---|
00-schemas.sql |
Creates the five schemas: service-counter, service-email, service-log, service-member, service-system |
01-schema.sql |
All tables, functions and triggers. No data. |
02-reference.sql |
Reference data: countries, currencies, banks, messages, settings, roles, modules. No customer data. |
03-colite.sql |
The Co-Lite company, the lead and event tables, the lead index, and the back-office modules. |
04-first-admin.sql |
The first administrator. Fill in <ADMIN_EMAIL> and <BCRYPT_HASH> first (see below). |
Making the hash. The password never has to appear in shell history:
read -rs PW; printf '%s' "$PW" | docker run --rm -i httpd:2.4-alpine htpasswd -inBC 10 "" | tr -d ':\n'; unset PW
After running 04, SELECT LENGTH(password) FROM \service-system`.`user` WHERE id = 1;must return 60. The administrator signs in asadmin` and must set a new password before anything else.
Later SQL, after the package, in this order:
| File | What it does |
|---|---|
openspec/changes/archive/2026-11-30-add-admin-email-listing/sql/01-email-module.sql |
Adds the Emails back-office module (BO_EMAILS). |
openspec/changes/archive/2026-11-30-add-admin-login-security/sql/01-login-audit.sql |
Creates the login_audit table (admin login history; the lockout reads it). DDL: run it with a user that may create tables, not the services' user. |
openspec/changes/archive/2026-11-30-add-admin-login-security/sql/02-lockout-settings.sql |
Adds ADMIN_LOGIN_MAX_ATTEMPT (5) and sets the admin block period to 15 minutes: 5 failed sign-ins in 15 minutes lock the username. |
openspec/changes/archive/2026-11-30-add-admin-login-security/sql/03-login-security-module.sql |
Adds the Login security back-office module (BO_LOGIN_SECURITY). |
99-rollback.sql in the same folder undoes the three and deletes the login history.
| File | What it does |
|---|---|
openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/01-audit-event.sql |
Creates service-log.audit_event (the admin audit trail). DDL: run it with a user that may create tables, not the services' user. |
openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/02-audit-log-module.sql |
Adds the Audit log back-office module (BO_AUDIT_LOG). No role gets it; super admins grant it under Roles. |
99-rollback.sql in the same folder undoes the two and deletes the audit trail.
| File | What it does |
|---|---|
openspec/changes/archive/2026-11-30-add-company-scoping/sql/01-company-code-status.sql |
Gives each company a sign-in code and a status. Company 1 becomes INS (code ins) and a second company CV (code cv) is added. DDL. |
openspec/changes/archive/2026-11-30-add-company-scoping/sql/02-company-columns.sql |
Adds the company to events and emails (existing rows go to INS) and makes interests one list shared by every company. DDL. |
openspec/changes/archive/2026-11-30-add-company-scoping/sql/03-admin-login-names.sql |
Super admins (role 1) get no company and keep their username. Every other admin moves to INS and is renamed username@ins. It stops without changing anything if an admin username already contains @. |
Run the three in order, with a user that may alter tables. File 03 ends every admin session: everyone signs in again, staff with company ins. 99-rollback.sql in the same folder undoes the three. It fails on the username unique key once two companies have a user with the same username; rename one of them first.
| File | What it does |
|---|---|
openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/01-status-change.sql |
Creates service-counter.event_lead_status_change (every event-lead status change with its time and user) and an index on event_lead for the dashboard. DDL. |
openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/02-status-change-backfill.sql |
Gives event leads captured before this release a history: OPEN at capture, and the current status at the last update. These times are approximate. Safe to run twice. |
openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/03-dashboard-module.sql |
Adds the Dashboard back-office module (BO_DASHBOARD). No role gets it; super admins grant it under Roles. |
Run the three in order before the new images go live: the new services-counter writes to the table from 01 on every capture and status edit, and fails without it. 01 needs a user that may create tables. 99-rollback.sql in the same folder undoes them and deletes the status history.
| File | What it does |
|---|---|
openspec/changes/archive/2026-12-01-add-qr-self-registration/sql/01-registration-link.sql |
Creates service-counter.registration_link (QR registration codes) and adds source, consent_at and consent_notice_id to event_lead. Existing event leads become STAFF. DDL. |
openspec/changes/archive/2026-12-01-add-qr-self-registration/sql/02-company-privacy-notice.sql |
Creates service-system.company_privacy_notice and gives every existing company the default English and Bahasa Malaysia privacy notice, with the company's name filled in. DDL. |
Run both before the new images go live: the new services-counter reads the new event_lead columns on every lead query and fails without them. Both need a user that may create tables. 99-rollback.sql in the same folder undoes them and deletes the codes, the notices and the consent records.
Review the privacy notice before go-live. The seeded text is a starting template written for the PDPA, not legal advice. INS and CV should each have theirs checked; a super admin changes it under Companies → Privacy notice. A company with no notice has no working QR codes.
Database user:
- Create one user with
SELECT, INSERT, UPDATE, DELETE, EXECUTEon the five schemas. EXECUTE is needed: service-member calls a stored function. - Every Java service reads the same variables (section 6):
MYSQLHOST,MYSQLPORT,MYSQLUSER,MYSQLPWD. - Each service connects to its own schema.
4. Redis
Use the existing Redis. Every Java service reads REDISHOST; the port is fixed at 6379.
5. Google Pub/Sub
The services publish and subscribe through Google Pub/Sub. It is not replaced in phase 1.
- Project: use a Google Cloud project, and give its id as
GCP_PROJECT. - Service account: create one with the Pub/Sub Publisher and Pub/Sub Subscriber roles, and download a JSON key. Mount the key into every Java image except
api-gateway(section 7), and setGCP_CREDENTIAL_FILE=file:/var/secrets/gcp/key.json. - Topics and subscriptions: use
local/pubsub/topics.txt. Each line is a topic name, optionally followed by a subscription name. Some topics appear on several lines with different subscriptions (e.g.update-sync-topic): create each topic once, then every subscription listed for it. Subscriptions use default settings. - Audit log:
audit-event-topicwithaudit-event-subscriptioncarries admin audit events from mobile-api to service-log. It is intopics.txt; service-log also creates both at startup if they are missing. Keep the subscription's default of not retaining acknowledged messages: the events carry admin usernames and IPs.AUDIT_RETENTION_DAYS(section 6) must be at least 1, or service-log does not start.
6. Environment variables
Secret values go in a Kubernetes Secret. Plain values can go in a ConfigMap or straight into the Deployment.
Shared by the six services (auth, system, counter, member, log, email) and mobile-api (every Java image except api-gateway, which needs only JWT_TOKEN):
| Variable | Kind | Value |
|---|---|---|
JWT_TOKEN |
Secret | HS512 signing key, at least 32 characters. Must be the same value as JWT_SECRET on mobile-api. |
GCP_PROJECT |
Plain | Google Cloud project id |
GCP_CREDENTIAL_FILE |
Plain | file:/var/secrets/gcp/key.json (the mounted key) |
REDISHOST |
Plain | Redis host |
XXL_JOB_TOKEN |
Secret | Optional. Leave unset. |
Also read by service-system, service-counter, service-member, service-log and service-email:
| Variable | Kind | Value |
|---|---|---|
MYSQLHOST |
Plain | MySQL host |
MYSQLPORT |
Plain | 3306 |
MYSQLUSER |
Secret | Database user (section 3) |
MYSQLPWD |
Secret | Its password |
service-system only: JUMIO_TOKEN and JUMIO_SECRET (Secret). These are for identity checks Co-Lite does not use. Leave them unset.
service-auth only:
| Variable | Kind | Value |
|---|---|---|
AES_SECRET_KEY |
Secret | Random, 32 characters |
USER_AUTH_API_SECRET |
Secret | Random, at least 32 characters |
service-email only. No email or SMS provider has been chosen yet (see section 10). Choosing one takes more than its key: the provider, the sender addresses and the SMTP host are written in application.yml with Tastefully and Containerverse values. Spring lets an environment variable override any setting (upper-cased, . becomes _ and - is dropped). So when a provider is chosen, also set:
EMAIL_PROVIDER: one ofMAIL_JET,SEND_GRID,MAIL_GUN,SMTP(today it isMAIL_JET);EMAIL_SENDERandEMAIL_SENDERNAME: the From address and name;- for Mailjet,
MAILJET_SENDER; for SendGrid,SENDGRID_SENDER; - for SMTP,
SPRING_MAIL_HOST,SPRING_MAIL_PORTandSPRING_MAIL_USERNAME; - for Mailgun,
MAILGUN_API_BASE_URLandMAILGUN_API_MESSAGES_URL, if the domain is notmail.containerverse.dev.
The keys:
| Variable | Kind |
|---|---|
MAILGUN_API_KEY |
Secret |
SENDGRID_API_KEY |
Secret |
MAILJET_API_KEY |
Secret |
MAILJET_SECRET_KEY |
Secret |
SMTP_PASSWORD |
Secret |
SMSS360_APIKEY |
Secret |
SMSS360_EMAIL |
Plain |
mobile-api:
| Variable | Kind | Value |
|---|---|---|
APIGATEWAYURL |
Plain | http://api-gateway |
APIKEY |
Secret | The key mobile-api sends to the gateway. Must equal the key of an entry in appkeys.json (section 7). |
AUTH_API_KEYS |
Secret | The keys mobile-api accepts from its clients, comma-separated, each <key>:APP. The admin portal's MOBILE_API_KEY must be one of them. |
JWT_SECRET |
Secret | Same value as JWT_TOKEN |
CUSTOMER_PORTAL_BASE_URL |
Plain | The customer portal is not deployed in phase 1. When unset, it falls back to a Tastefully address that only the member referral link uses, which Co-Lite does not use. Set it once a customer portal exists. |
service-log:
| Variable | Kind | Value |
|---|---|---|
AUDIT_RETENTION_DAYS |
Plain | Optional (default 730). Admin audit events older than this many days are deleted daily at 03:30. |
api-gateway: only JWT_TOKEN (same value as everywhere). No Pub/Sub, Redis or database settings, and no key.json mount. It reads its client keys from the mounted appkeys.json (section 7).
admin-portal:
| Variable | Kind | Value |
|---|---|---|
MOBILE_API_BASE_URL |
Plain | http://mobile-api (no trailing slash) |
MOBILE_API_KEY |
Secret | One of the keys in mobile-api's AUTH_API_KEYS (without the :APP suffix) |
SESSION_SECRET |
Secret | Required. Random, at least 32 characters. Signs the session cookie. If it is unset, the portal falls back to MOBILE_API_KEY, which ties the two together. |
SESSION_COOKIE_NAME |
Plain | Optional (default colite_admin). The cookie is always __Host- prefixed and Secure, so the portal must be served over HTTPS. |
SESSION_IDLE_TTL |
Plain | Optional, seconds (default 3600) |
SESSION_ABSOLUTE_TTL |
Plain | Optional, seconds (default 28800) |
SESSION_REFRESH_GRACE |
Plain | Optional, seconds (default 300) |
Generate each random value separately, for example with openssl rand -base64 48.
7. Mounted files
| File | Mounted into | Path | Content |
|---|---|---|---|
appkeys.json |
api-gateway |
/deployments/appkeys/appkeys.json |
The clients allowed to call the gateway (example below) |
key.json |
every Java image except api-gateway |
/var/secrets/gcp/key.json |
The Pub/Sub service-account key (section 5) |
appkeys.json holds one entry, for mobile-api. Keep it that way: mobile-api is what checks who may change whose password, so no other client may get a key that reaches the gateway's /user/ routes.
[
{
"key": "<the APIKEY value given to mobile-api>",
"name": "Co-Lite mobile-api",
"desc": "mobile-api calls to the gateway",
"type": "BO",
"allowList": ["/"],
"ipList": ["<pod CIDR of the cluster, or 0.0.0.0/0>"]
}
]
type,allowListandipListare required. The gateway reads all three on every request, and a missing one fails every call.allowListentries are matched anywhere in the request URL (["/"]allows everything).ipListis a list of CIDR ranges.typeis one ofBO,APP,MB,SK,TP,PG,RS,KYC. UseBO. Never useTP: it skips login-token checks entirely.
8. Traefik
Route co-lite.containerverse.dev to the admin-portal Service on port 3000, with TLS. Only the admin portal is public: the browser talks to the portal, and the portal talks to mobile-api inside the cluster. Do not expose mobile-api, api-gateway or the services.
QR registration pages (/r/<code>) are served by the admin portal on the same host, so nothing new is routed. mobile-api rate-limits visitors by the address the portal sends: the last entry of X-Forwarded-For, which is the one Traefik adds. That works whether Traefik appends to or replaces the header. If another proxy or load balancer sits in front of Traefik, the last entry is that proxy's address and every visitor shares one limit; the portal's clientIp would then have to change (or use the PROXY protocol). If the portal sees no X-Forwarded-For and no X-Real-Ip at all, every visitor shares the portal pod's limit.
9. Secret templates
There is no template yet for service-email (its keys wait for the email provider) or service-system (its Jumio keys stay unset). Kubernetes Secrets hold base64 values. Encode each one with printf '%s' 'value' | base64 -w0. These are templates: replace every <…> and never commit the filled-in files.
apiVersion: v1
kind: Secret
metadata:
name: co-lite-shared
type: Opaque
data:
JWT_TOKEN: <base64>
MYSQLUSER: <base64>
MYSQLPWD: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-service-auth
type: Opaque
data:
AES_SECRET_KEY: <base64>
USER_AUTH_API_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-mobile-api
type: Opaque
data:
APIKEY: <base64>
AUTH_API_KEYS: <base64>
JWT_SECRET: <base64, same value as JWT_TOKEN>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-admin-portal
type: Opaque
data:
MOBILE_API_KEY: <base64>
SESSION_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-gateway-appkeys
type: Opaque
data:
appkeys.json: <base64 of the whole appkeys.json file>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-gcp-key
type: Opaque
data:
key.json: <base64 of the service-account JSON key>
10. Known gaps at go-live
- No email provider yet. Staff onboarding does not need one: the admin types each new user's first password, and "Set temporary password" on a user's page unlocks a user who forgot theirs. Both force a password change at the next sign-in. Forgot-password and "Send password reset" still create an email with a temporary password. Nobody receives it, but
service-emailsaves every email first, so a super admin (or a role granted Emails) can read it under Emails and pass the password on in person. The user must change it at the next sign-in. Grant Emails narrowly: it shows every saved email, including other users' temporary passwords, member email-verification codes, and contact or distributor form submissions with the sender's personal data. - Sign-in lockout. 5 failed sign-ins within 15 minutes lock a username, even with the right password, until 15 minutes after the first of those failures, and unknown usernames are counted too. Anyone who knows a username can therefore lock it on purpose. An admin with Login security can unlock it at once (Locked tab), and can change the limits there. If every super admin is locked, wait out the period. The lock check fails open: if
service-systemis down, sign-in still works without the lockout. - Companies and super admins. INS and CV each see only their own leads, events, event leads, users, emails, login history and audit log. Staff sign in with their company code, username and password. A super admin leaves Company blank, sees every company (with a company picker in the header), and is the only one who can manage companies, roles, interests, lockout settings and password rules. Changing a company's code renames its staff's sign-in names and signs them out; deactivating a company blocks its staff from signing in. Emails sent from public forms and other system emails have no company, so only super admins see them. Do not give a company's old code to another company while sessions opened under the old code may still be valid: such a session token would resolve to the new company's user of the same name. When in doubt, never reuse a code.
- Lead dashboard. Users whose role has the Dashboard module see lead captures, wins, conversion and overdue follow-ups on the home page, for this month, last month or a custom range of up to two years in Malaysian time. A lead counts as converted when its status at an event is WON. Wins and days to win come from the status history, which starts with this release; for older leads it is approximate (see section 3).
- QR self-registration. Visitors scan a code and register themselves as a lead at an event. Each event has an event code, and each team member has a personal code that assigns the visitor to them; staff with Events see and switch them off on the event page, and every staff user finds their own under My QR codes in the user menu. Codes work until the event's end date (Malaysian time). A registration never edits an existing lead: differences go into that event lead's notes for staff to check. Each visitor IP may load 120 registration pages in 10 minutes across all events, and submit 60 registrations per event in 10 minutes; there is no CAPTCHA. For a reprintable code with scan counts, paste the code's link into the dynamic-qr console and print that code instead; no visitor data reaches dynamic-qr.
- Gateway paths open to the public registration. The internal gateway lets a few exact read paths and the registration write through without a user token, so mobile-api can serve visitors who are not signed in. Keep the gateway unexposed (above); the design notes in the change folder list the paths and the risk.
- Time zone. The Java images run with
TZ=Asia/Kuala_Lumpur(set in thedocker-java-21base image), and stored times such as capture, consent and notice times are Malaysian local time. Do not overrideTZon the services. - Reference data from Tastefully. It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live.
- Other Tastefully defaults. The sender addresses in
service-emailand theCUSTOMER_PORTAL_BASE_URLfallback point at Tastefully. Override them as described in section 6. - Leaked SMS key. An SMS360 API key from Tastefully was in
service-email's config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account. - Deploy by SHA, not
latest. CI pushes the images one by one, so if a push fails halfway,latestcan differ between images.