Files
SpecialX 2229309a1e feat: initialize parent-bff service with full core features
add complete parent-bff implementation including:
- GraphQL endpoint with depth/cost validation
- ChildGuard越权校验 with redis cache and singleflight
- parallel orchestration with partial failure fallback
- three-level cache fallback strategy (Redis + LRU + downstream)
- Kafka consumer for cache invalidation and notification push
- opossum circuit breaker for downstream services
- Prometheus metrics and SLO alerts
- Helm chart for k8s deployment with multi-environment configs
- Grafana dashboard for observability
- complete unit and integration tests
2026-07-10 18:49:06 +08:00
..

K8s 部署说明

状态:已迁移到 Helm Chart 管理。本目录保留 namespace.yaml 作为基础资源,其余资源通过 helm/ 下的 chart 部署。

目录结构

infra/k8s/
├─ namespace.yaml              # 基础命名空间4 个system/services/monitoring/ingress
└─ helm/                       # Helm Chart 仓库
   ├─ edu-platform/            # 平台级 chartnamespace/configmap/secret/ingress/hpa
   │  ├─ Chart.yaml
   │  ├─ values.yaml           # 全局默认值
   │  ├─ values-dev.yaml       # 开发环境覆盖
   │  ├─ values-staging.yaml   # 预发布环境覆盖
   │  ├─ values-prod.yaml      # 生产环境覆盖
   │  └─ templates/
   │     ├─ _helpers.tpl
   │     ├─ namespace.yaml
   │     ├─ configmap.yaml
   │     ├─ secret.yaml        # 骨架;生产请用 External Secrets Operator
   │     ├─ ingress.yaml
   │     └─ hpa.yaml           # 全局 HPA 示例(默认不渲染)
   ├─ api-gateway/             # 服务级 chart完整迁移自原 manifest
   │  ├─ Chart.yaml
   │  ├─ values.yaml
   │  └─ templates/
   │     ├─ _helpers.tpl
   │     ├─ deployment.yaml
   │     ├─ service.yaml
   │     ├─ configmap.yaml
   │     └─ hpa.yaml
   ├─ iam/                     # 业务服务 chart 桩P2
   ├─ core-edu/                # 业务服务 chart 桩P3
   ├─ content/                 # 业务服务 chart 桩P4
   ├─ msg/                     # 业务服务 chart 桩P5
   ├─ data-ana/                # 业务服务 chart 桩P4
   └─ ai/                      # 业务服务 chart 桩P5

命名空间规划

Namespace 用途
edu-system 系统组件(数据库代理、配置等)
edu-services 业务微服务api-gateway / iam / core-edu / content / msg
edu-monitoring 监控栈Prometheus / Grafana / Alertmanager
edu-ingress 入口控制器NGINX Ingress / cert-manager

部署方式

1. 安装平台级 chart命名空间 / 全局 ConfigMap / Secret / Ingress

# 开发环境
helm install edu-platform ./helm/edu-platform -f ./helm/edu-platform/values-dev.yaml

# 生产环境
helm install edu-platform ./helm/edu-platform -f ./helm/edu-platform/values-prod.yaml \
  --set secret.data.MYSQL_PASSWORD=<base64> \
  --set secret.data.JWT_SECRET=<base64> \
  --set secret.data.REDIS_PASSWORD=<base64>

2. 安装服务级 chart

# api-gateway
helm install api-gateway ./helm/api-gateway

# 其他业务服务iam / core-edu / content / msg / data-ana / ai
helm install iam ./helm/iam
helm install core-edu ./helm/core-edu
# ...

3. 应用基础命名空间(如未通过 helm 安装 edu-platform

kubectl apply -f namespace.yaml

验证

# lint 所有 chart
helm lint helm/edu-platform helm/api-gateway helm/iam helm/core-edu helm/content helm/msg helm/data-ana helm/ai

# 渲染模板(不实际部署)
helm template edu-platform ./helm/edu-platform
helm template api-gateway ./helm/api-gateway

环境差异

环境 values 文件 副本数 HPA TLS
dev values-dev.yaml 1 关闭 关闭
staging values-staging.yaml 2 2-5 开启
prod values-prod.yaml 3 3-20 开启

敏感配置

⚠️ 生产环境禁止在 values.yaml 中硬编码密钥

推荐方案:

  1. 使用 External Secrets Operator 对接 Vault / KMS / 云 KMS
  2. 通过 --set secret.data.<KEY>=<base64> 临时注入
  3. 通过 ArgoCD / Flux GitOps + Sealed Secrets

后续路线

  • 接入 External Secrets Operator
  • ArgoCD / Flux GitOps 部署
  • 各服务 chart 补充 configmap.yaml / hpa.yaml 模板(当前桩仅含 deployment/service
  • 服务级 values-dev/staging/prod 覆盖文件
  • CI/CD 集成helm chart 推送到 OCI registry