Skip to content

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

EnvCách deployGhi chú
localmake dev-<svc> / make dev-app-<name>hot reload
developDocker Composecompose per-service ở infrastructure/deployments/
stagingkubectl apply manifest thủ côngK8s VNPAY cloud
productionGitOps auto-deploymerge → pipeline → cluster

Trình tự đầy đủ theo môi trường ở Infrastructure → Operations → Trình tự Triển khai.

Deploy (nhanh)

  1. Build & push image (CI làm khi merge) - chiến lược tag ở infra.
  2. Roll out: kubectl set image deploy/<svc> <svc>=<image>:<tag> -n nx-backend (staging) hoặc merge cho prod GitOps.
  3. 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

  1. kubectl rollout undo deploy/<svc> -n nx-backend (về ReplicaSet trước), hoặc re-deploy tag tốt gần nhất.
  2. Nếu liên quan migration, rollback có thể cần migration bù - không revert schema mù quáng.
  3. 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.

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.