Triển khai
Cách deploy, chạy migration và rollback. Cơ chế đầy đủ (CI/CD, image tag, manifest, GitOps) ở Infrastructure → Operations - trang này là recipe nhanh.
Môi trường
| Env | Cách deploy | Ghi chú |
|---|---|---|
| local | make dev-<svc> / make dev-app-<name> | hot reload |
| develop | Docker Compose | compose per-service ở infrastructure/deployments/ |
| staging | kubectl apply manifest thủ công | K8s VNPAY cloud |
| production | GitOps auto-deploy | merge → pipeline → cluster |
Trình tự đầy đủ theo môi trường ở Infrastructure → Operations → Trình tự Triển khai.
Deploy (nhanh)
- Build & push image (CI làm khi merge) - chiến lược tag ở infra.
- Roll out:
kubectl set image deploy/<svc> <svc>=<image>:<tag> -n nx-backend(staging) hoặc merge cho prod GitOps. - Theo dõi:
kubectl rollout status deploy/<svc> -n nx-backend.
Migration DB
Migration chạy dưới dạng Job trước khi bản mới nhận traffic - không bao giờ chạy tay vào prod. Template + thứ tự ở infra → Migration Jobs. Dev: bun run migrate:dev từng package.
Rollback
kubectl rollout undo deploy/<svc> -n nx-backend(về ReplicaSet trước), hoặc re-deploy tag tốt gần nhất.- Nếu liên quan migration, rollback có thể cần migration bù - không revert schema mù quáng.
- Xác nhận khỏe, rồi viết post-mortem.
Chi tiết rollback: Infrastructure → Operations → Rollback.
Secret
Secret là SealedSecret giải mã thành K8s Secret - xem Infrastructure → Configuration. Không bao giờ để giá trị secret thật trong repo hay wiki.