Thiết kế Kiến trúc Enterprise End-to-End
🎯 Mục tiêu: Tạo Architecture Decision Record (ADR) và diagram đầy đủ cho hệ thống capstone multi-cloud; xác định rõ private/public/hybrid boundaries, network topology, identity federation, và data flow.
🧰 Công cụ / nền tảng: VS Code + Mermaid extension, Git, GitHub. Tùy chọn: draw.io (diagrams.net) cho diagram phức tạp.
📦 Chuẩn bị: Repo capstone mới trên GitHub; VS Code với Markdown Mermaid extension; đã đọc lý thuyết 1.2 (kiến trúc tổng thể).
▶️ Các bước (CLI):
# 1. Tạo repo capstone
mkdir ~/capstone-enterprise && cd ~/capstone-enterprise
git init
mkdir -p docs/adr infra/terraform infra/k8s app
# 2. Viết ADR-001 (Architecture Decision Record)
cat > docs/adr/ADR-001-multi-cloud-strategy.md <<'EOF'
# ADR-001: Multi-Cloud Architecture Strategy
## Status: Accepted
## Date: 2026-05-23
## Context
Doanh nghiệp cần: (a) giữ DB nhạy cảm on-prem (data sovereignty),
(b) co giãn nhanh trên Azure cho workload chính,
(c) DR trên AWS us-east-1, (d) CI/CD hoàn toàn tự động.
## Decision
Hybrid + Multi-cloud: private k3s (on-prem) + Azure AKS (primary prod)
+ AWS EKS (DR/burst). Kết nối qua Azure VPN Gateway + Site-to-Site VPN.
IaC: Terraform với separate state per cloud. GitOps: ArgoCD.
## Consequences
(+) Data sovereignty đảm bảo; vendor diversity cho DR.
(-) Tăng complexity vận hành; cần team hiểu cả Azure và AWS.
(-) Egress cost cần monitor liên tục (FinOps).
EOF
# 3. Tạo architecture diagram (Mermaid)
cat > docs/architecture.md <<'EOF'
# Capstone Architecture
## Network Topology
\`\`\`mermaid
graph TB
subgraph OnPrem["Private Cloud (on-prem k3s)"]
DB[(PostgreSQL\nDB nhạy cảm)]
VAULT[HashiCorp\nVault]
PROM[Prometheus\nAgent]
end
subgraph AzureProd["Azure — Primary Production"]
AKS[AKS Cluster\nprod namespace]
ACR[Azure Container\nRegistry]
KV[Azure Key Vault\n+ Private Endpoint]
AGW[Application Gateway\n+ WAF]
end
subgraph AWS["AWS — DR / Burst"]
EKS[EKS Cluster\ndr namespace]
ECR[Elastic Container\nRegistry]
R53[Route 53\nHealth Check]
end
subgraph CICD["CI/CD Layer (GitHub)"]
GH[GitHub\nSource of Truth]
GHA[GitHub Actions\nCI Pipeline]
ARGO[ArgoCD\nCD / GitOps]
end
DEV([Developer]) -->|git push| GH
GH --> GHA
GHA -->|docker build + scan| ACR
GHA -->|docker build + scan| ECR
GHA -->|update manifests| ARGO
ARGO -->|sync| AKS
ARGO -->|sync| EKS
AKS -->|VPN S2S| DB
AKS --> KV
AGW --> AKS
R53 -->|failover| EKS
PROM -->|remote_write| AKS
\`\`\`
## Data Flow
\`\`\`mermaid
sequenceDiagram
participant U as User
participant AGW as App Gateway (WAF)
participant AKS as AKS (prod)
participant DB as PostgreSQL (on-prem)
participant VAULT as Vault
U->>AGW: HTTPS request
AGW->>AKS: Forward (TLS termination)
AKS->>VAULT: Get DB credentials
VAULT-->>AKS: Dynamic secret (TTL 1h)
AKS->>DB: Query via VPN tunnel
DB-->>AKS: Result
AKS-->>U: Response
\`\`\`
EOF
# 4. Commit
git add docs/
git commit -m "feat: add ADR-001 and full architecture diagrams"
git remote add origin https://github.com/<username>/capstone-enterprise.git
git push -u origin main
🖥️ Đối chiếu GUI / Portal:
Dùng diagrams.net (draw.io) để vẽ diagram visual nếu muốn, xuất sang PNG rồi nhúng vào docs. GitHub render Mermaid inline từ file .md — không cần tool riêng.
✅ Kết quả mong đợi: File ADR-001 có đủ Context/Decision/Consequences; file architecture.md render 2 diagram (network topology + data flow sequence) đúng trên GitHub; repo đã push public.
🧹 Cleanup: Không xóa — đây là living documentation, cập nhật khi kiến trúc thay đổi ở các lab tiếp theo.