eust-w 13ceca5c8f
Some checks failed
CI / Format, types and tests (pull_request) Has been cancelled
CI / PostgreSQL migrations and integration tests (pull_request) Has been cancelled
🔀 Merge review/overhaul into feat/wiki-copilot-diagnostics
Brings the branch up to the current base (executor settings, project
skills, Chinese run messages, cloud IDE removal, wish attachments) and
resolves the ten conflicted files, keeping both sides:

- wish-refiner: the tenant's executor settings pick the models first,
  then the Copilot model setting; the tenant credential still goes
  before the operator's login
- worker providers: executor settings apply, and a run with its own
  credential still gets an empty home
- main.ts: Copilot screenshot uploads and wish attachments each keep
  their own body limit
- contracts, http, web types: default budget and skill auto-activation,
  Copilot and attachment entity kinds, ./text and ./attachments exports
- globals.css: Copilot styles and attachment styles, one after the other
- tests: the canceled-release reason is Chinese; the refiner's default
  models have no [1m] suffix, as this branch names them

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 00:39:05 +08:00
..
2026-11-04 12:43:02 +08:00
2026-11-04 12:43:02 +08:00
2026-11-04 12:43:02 +08:00

Kubernetes 基线

base/ 是可审阅的防护基线,不是完整的生产安装,也没有在任何集群上应用过。先用 kubectl kustomize infra/k8s/base 渲染并审阅,不要直接应用到当前的任意上下文。

文件 内容
namespaces.yaml 控制面命名空间 wishforge-control 与示例租户命名空间 wishforge-tenant-example,都强制 restricted Pod Security
runtime-class.yaml wishforge-kata(kata-qemu,调度到 wishforge.io/kata-ready=true 的节点),即 provisioner WF_KATA_RUNTIME_CLASS 的默认值。只创建 RuntimeClass 不会安装 Kata
provisioner-rbac.yaml provisioner 的 ServiceAccount 与它在租户命名空间中的 Role,正好覆盖它创建、读取、调整与清理的对象
network-policy.yaml 两个命名空间默认拒绝全部出入流量;控制面 Pod 允许 DNS;沙箱 Pod 可以访问 API、Temporal 与平台 Git
quota.yaml 示例租户的 ResourceQuota 与 LimitRange

provisioner 在租户命名空间中创建的对象

Kubernetes 后端的说明见 apps/provisioner/README.md。

  • 每个运行代次:executor 与 verifier 各一个 Kata Job、PVC、保存运行令牌的 Secret 和 ServiceAccount(不挂载令牌、没有任何绑定),外加一条 NetworkPolicy。这条策略只允许 DNS,以及控制面命名空间中 wishforge.io/component 为 api、temporal、git-storage 的 Pod。模型调用经 API 的模型代理完成。
  • 释放运行:删除 Job,Pod 全部结束后删除 Secret、ServiceAccount 与 NetworkPolicy。PVC 保留用于排查,保留期过后由控制面请求 provisioner 按 wishforge.io/run 标签删除(默认一周,见 operations.md)。在此之前它们占用配额,配额要留出余量。

每次运行的出站端口取自 WF_CONTROL_PLANE_URL(未写端口时为 443)、TEMPORAL_ADDRESS 与 WF_GIT_SERVICE_PORT。NetworkPolicy 按 Pod 端口匹配,所以这三个 Service 的端口必须与容器端口一致。

安装前

  • 显式选择集群。准备带 kata-qemu 的 Kata 节点池并打上 wishforge.io/kata-ready=true,按实测调整 RuntimeClass 的 overhead。CNI 必须执行 NetworkPolicy。

  • 每个租户一个命名空间:复制示例的 wishforge.io/tenant 标签、配额、默认拒绝策略与 provisioner 绑定,并配置为该租户 provisioner 的 WF_KUBE_NAMESPACE。把 Pod Security 版本从 latest 固定为集群支持的次版本。

  • 给控制面 Pod 打上 wishforge.io/component 标签:api、temporal、git-storage。

  • 为其余流量编写环境相关的策略:

    • 入口;Web 到 API;
    • API 到 PostgreSQL、OIDC、对象存储、Vault、provisioner 与模型供应商;
    • worker 到 API 与 Temporal;
    • provisioner 到 Kubernetes API。
  • 把 provisioner 的 WF_KUBE_CONTEXT 绑定到 provisioner ServiceAccount 的短期投射令牌。

  • 准入策略需要限制以下几项,RBAC 无法限制受信任控制器所创建 Job 的字段:

    • 只允许经批准的镜像 digest 与 wishforge-kata;
    • 只允许非 root、只读根文件系统的容器,禁止特权容器、宿主机卷与宿主机命名空间;
    • 只允许挂载本运行的 Secret。
  • 依赖安装需要访问包仓库,verifier 构建镜像需要访问远程构建器。两者都由运维提供:

    • 出站代理带 wishforge.io/component: egress-proxy 标签,负责 URL/IP 策略、防 DNS 重绑定与屏蔽元数据地址;
    • 构建器带 wishforge.io/component: image-builder 标签,是 Docker 兼容的守护进程,使用 TLS。

    配置 provisioner 的 WF_RUN_INSTALL_PROXY_URL 与 WF_VERIFIER_DOCKER_HOST 后,每次运行的策略会放行到它们的连接;sandbox-to-control 负责接收一侧。代理与构建器自己访问外网与镜像仓库的策略需要另外编写。NetworkPolicy 也不能替代 API 的租户授权。

  • 生产依赖:

    • 托管或高可用的 PostgreSQL,以及备份与 PITR;
    • 启用 mTLS 的 Temporal;
    • TLS 的 OIDC;
    • 私有对象存储;
    • 签名镜像;
    • 外部密钥管理。
  • 不要把 Compose 的开发密码带进生产。

部署目标

Runner 在客户的目标环境中运行,使用自己的 WF_KUBE_CONTEXT 与 WF_KUBE_NAMESPACE 做蓝绿部署,不使用本基线中的任何身份。它在应用命名空间中需要以下权限,不需要创建命名空间、修改 RBAC 或 NetworkPolicy:

资源 权限
deployments get、list、watch、create、patch
services get、create、patch
secrets get、create

其中 secrets 用于不可变的应用密钥。

集群验收

  • 用 kubectl auth can-i 核对每个身份的权限。
  • 证明工作负载确实在 Kata 虚拟机中运行。
  • 验证跨租户访问与网络被拒绝、Secret 访问被拒绝。
  • 做资源耗尽测试。
  • 确认准入策略会拒绝未批准的 digest。
  • 演练运行、Runner 的部署与回滚。

这些都尚未完成。