Operations
1. Deployment
| Thuộc tính | Giá trị |
|---|---|
| Image | registry/outreach:<tag> |
| Replicas (mặc định) | 1 (traffic thấp; API stateless) |
| Resources (req/lim) | nhỏ — CPU/memory theo baseline cluster |
| HPA target | CPU (tùy chọn; traffic bùng nổ khi campaign) |
| Probes | GET /healthz (live), GET /readyz (ready) |
| Snowflake ID | 10 (APP_ENV_NODE_ID) |
| Migration mode | bun run migrate:dev / boot job; seed idempotent (alwaysRun) |
Traefik labels
yaml
labels:
- "traefik.enable=true"
- "traefik.http.routers.outreach.rule=PathPrefix(`/v1/api/outreach`)"
- "traefik.http.services.outreach.loadbalancer.server.port=3000"Nhiều replica là an toàn: WebSocket emitter backed bởi Redis, nên bất kỳ replica nào cũng có thể broadcast tới mọi subscriber. Snowflake worker
10phải unique theo từng process đang chạy nếu scale quá một — phối hợpAPP_ENV_NODE_ID.
2. Observability
| Signal | Nguồn | Nơi xem |
|---|---|---|
| Logs | stdout (key-value có cấu trúc) | kubectl logs <pod> / Loki |
| Metrics | Prometheus /metrics (nếu bật) | Grafana |
| Traces | no-op (chưa nối tracer) | — |
| Health | GET /healthz, GET /readyz | Gateway portal |
| API spec | GET /v1/api/outreach/doc/openapi.json, /doc (Scalar) | Browser |
Trường log quan trọng
| Trường | Nguồn | Ghi chú |
|---|---|---|
requestId | header X-Request-Id | Propagate cross-service |
inquiryId | WS notify | Inquiry SENT | inquiryId: %s | rooms: %j |
rooms | WS notify | Room quan sát đích |
3. Security
| Mối quan tâm | Biện pháp |
|---|---|
| AuthN | JWT (ES256, JWKS từ identity) trên CRUD + statistics |
| Endpoint public | /inquiries/submit, /subscribers/subscribe, /subscribers/unsubscribe không xác thực theo thiết kế |
| Lạm dụng / spam | Không có rate limit tích hợp — dựa vào middleware Traefik + WAF trước submit/subscribe public |
| Unsubscribe token | Snowflake unsubscribeToken, ẩn khỏi API response; chỉ token hợp lệ mới deactivate được — xem ADR-0001 |
| AuthZ | Permission Casbin seed cho OWNER/EMPLOYEE/CASHIER |
| Secrets | K8s Secret mount làm env (DB, Redis password) |
| TLS | Kết thúc tại gateway |
| Network policy | Cilium — cho phép gateway + identity JWKS + Redis + Postgres |
| Soft-delete | deletedAt; không hard-delete theo mặc định |
4. Runbook
4.1 Lớp Alert
| Alert | Trigger | Check | Fix | Escalate |
|---|---|---|---|---|
outreachHighErrorRate | 5xx >5% trong 5m | log level=error | inspect kết nối DB / Redis | on-call backend |
outreachSubmitFlood | spike submit RPS | metric Traefik | bật/tăng rate limit tại gateway | on-call SRE |
outreachWSNotReady | cảnh báo lặp Socket event service not ready | Redis health | restart pod / check Redis | on-call backend |
4.2 Thao tác thường gặp
| Thao tác | Lệnh |
|---|---|
| Tail log | kubectl logs -n <ns> -f deploy/outreach |
| Re-run seed | chạy migration (seed alwaysRun, idempotent) — chỉ operator chạy |
| Verify spec live | mở /v1/api/outreach/doc |
| Triage spam | đánh dấu các yêu cầu vi phạm CANCELLED qua CRUD admin |
Không có Kafka replay và không có BullMQ queue cho service này — không có gì để drain hay replay.
5. Trang liên quan
- Configuration
/runbook/— runbook trung tâm cho sự cố cross-service- Decisions