Kubernetes 部署
適用情境
- 正式環境或多人協作部署
- 需要使用 Helm 管理平台固定服務
- 需要導入
workspace-operator做 workspace 動態排程 - 需要 per-workspace 網路隔離(Cilium)
- 需要 Ingress/TLS 對外公開
架構概覽
┌─────────────────────────────────────────────────────────────┐
│ Ingress Controller │
│ example.com → frontend │
│ workspace-manager.example.com → manager │
│ keycloak.example.com → keycloak │
│ workspace-runtime-{id}.example.com → runtime pod │
│ workspace-browser-{id}.example.com → browser pod │
└────────┬──────────┬──────────┬──────────────────────────────┘
│ │ │
┌─────▼────┐ ┌───▼────┐ ┌──▼───────┐ ┌──────────────┐
│ Frontend │ │Manager │ │Keycloak │ │ Workspace │
│ Deploy │ │Deploy │ │Deploy │ │ Operator │
└──────────┘ └───┬────┘ └──────────┘ │ Deploy │
│ └──────┬───────┘
┌─────▼──────┐ │ reconcile
│ Celery + │ ┌──────▼───────┐
│ Flower │ │ Workspace CR │
└────────────┘ │ (CRD) │
└──────┬───────┘
┌────────────┐ │ creates
│ PostgreSQL │ ┌──────▼───────┐
│ StatefulSet│ │ Runtime Pod │
└────────────┘ │ Browser Pod │
┌────────────┐ │ Next.js Pod │
│ Redis │ │ Service │
│ StatefulSet│ │ Ingress │
└────────────┘ │ CiliumPolicy │
┌────────────┐ └──────────────┘
│ CoTURN │
│ Deployment │
└────────────┘
Helm 管理範圍
Helm chart 管理平台固定服務:
| 資源類型 | 包含項目 |
|---|---|
| Deployment | frontend、workspace-manager、workspace-operator、keycloak、coturn |
| StatefulSet | postgres、redis |
| Service | 所有服務的 ClusterIP Service、CoTURN NodePort |
| Ingress | frontend、workspace-manager、keycloak 的統一入口 |
| ConfigMap | platform-config、workspace-routing、firewall-defaults、keycloak-realm、frontend-nginx |
| Secret | 資料庫密碼、Keycloak 密碼 |
| RBAC | workspace-operator ClusterRole、workspace-manager Role、ServiceAccount |
| CRD | workspaces.platform.aileron.io |
| Job | postgres-bootstrap(初始化資料庫) |
備註
每個 workspace 的動態資源(Pod、Service、Ingress、CiliumNetworkPolicy)不由 Helm 直接管理,而是由 workspace-operator 根據 Workspace CR 進行 reconcile。