deploy(custom-workload): discernlen 工作负载内置 Hatchet 并更新实际环境配置
Build Discernlen images / images (push) Successful in 1m36s
Build Discernlen images / images (push) Successful in 1m36s
- discernlen.yaml 新增 hatchet-lite 单实例(Deployment/Service/ConfigMap), 配置 HATCHET_CLIENT_* 指向集群内服务,补齐探针与资源限制 - 新增 hatchet-secret.example.yaml:Hatchet 数据库连接、cookie secrets 与 三组 encryption keyset 的生成与填写说明 - runtime-secret.example.yaml 补充 client token 生成/写回流程 - README 更新为 Hatchet 内置部署模型:keyset 生成、token 签发、 Dashboard 端口转发与运维注意事项 - 镜像切换至 git.agentwithu.com 实际仓库,OIDC/S3/域名更新为实际环境
This commit is contained in:
@@ -69,6 +69,7 @@ python3 scripts/test-helm.py
|
||||
|
||||
- [Docker Compose](compose.yaml)
|
||||
- [Kubernetes 清单](deploy/k8s/)与[部署指南](docs/maintainers/deploy/kubernetes.md)
|
||||
- [孔明自定义工作负载](deploy/kongming-custom-workload/README.md)(含 Hatchet)
|
||||
- [Helm 与多集群](deploy/helm/README.md)
|
||||
- [Gitea 镜像构建](.gitea/workflows/build-images.yaml),配置见[镜像发布](docs/maintainers/deploy/kubernetes.md#镜像发布)
|
||||
- [Gitea CLI 发布](.gitea/workflows/build-cli.yaml),推送 `v*` tag 后二进制附件发布在该 tag 的 Release,流程说明见[CI 流程](.gitea/workflows/README.md#四cli-发布流程)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# discernlen on 孔明自定义工作负载
|
||||
|
||||
将 discernlen 的四个应用组件(api / worker / bff / web)作为一个**孔明自定义工作负载**部署,入口使用 Istio `VirtualService`。
|
||||
将 discernlen 的四个应用组件(api / worker / bff / web)以及 Hatchet(hatchet-lite)作为一个**孔明自定义工作负载**部署,入口使用 Istio `VirtualService`。
|
||||
|
||||
依赖的 PostgreSQL、S3/MinIO、Hatchet、OIDC 均使用外部服务,不包含在本目录中。这与 discernlen 官方 `deploy/k8s`、`deploy/helm` 的部署模型一致。
|
||||
PostgreSQL、S3/MinIO、OIDC 仍使用外部服务;Hatchet 作为工作负载内的单实例部署,依赖外部 PostgreSQL 中的 `hatchet` 数据库。
|
||||
|
||||
| 文件 | 用途 |
|
||||
| --- | --- |
|
||||
| `discernlen.yaml` | 主 Manifest:2 个 ConfigMap、4 个 Deployment、3 个 Service、1 个 VirtualService |
|
||||
| `runtime-secret.example.yaml` | 数据库 / S3 / Hatchet / OIDC 凭据 Secret,**在平台外单独创建** |
|
||||
| `discernlen.yaml` | 主 Manifest:3 个 ConfigMap、5 个 Deployment、4 个 Service、1 个 VirtualService |
|
||||
| `runtime-secret.example.yaml` | 数据库 / S3 / Hatchet client token / OIDC 凭据 Secret,**在平台外单独创建** |
|
||||
| `hatchet-secret.example.yaml` | Hatchet 数据库连接、cookie secrets、encryption keysets,**在平台外单独创建** |
|
||||
| `registry-secret.example.yaml` | 私有镜像仓库拉取凭据,公开镜像可忽略 |
|
||||
|
||||
## 1. 前置条件
|
||||
@@ -17,18 +18,18 @@
|
||||
- `ExposeConfig.istio.enabled = true`
|
||||
- `ExposeConfig.istio.gateway` 与 `discernlen.yaml` 中 `spec.gateways` 一致
|
||||
- `VirtualService` 的 host 落在网关允许的域名内
|
||||
3. 已用同一次构建产出的镜像(四个组件必须使用同一个 `sha-<commit>` 标签):
|
||||
3. 已用同一次构建产出的镜像(四个应用组件必须使用同一个 `sha-<commit>` 标签):
|
||||
- `discernlen-api`
|
||||
- `discernlen-worker`
|
||||
- `discernlen-bff`
|
||||
- `discernlen-web`
|
||||
4. 外部依赖可用:
|
||||
- PostgreSQL:已创建 `discernlen` 数据库和用户
|
||||
4. Hatchet 镜像 `ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5` 可从集群拉取;若集群不能访问 ghcr.io,请先同步到内部仓库并替换 `discernlen-hatchet` Deployment 的镜像地址。
|
||||
5. 外部依赖可用:
|
||||
- PostgreSQL:已创建 `discernlen` 数据库和用户,以及 Hatchet 专用的 `hatchet` 数据库(可以是同一个 PostgreSQL 实例)
|
||||
- S3 / MinIO:已创建 bucket(默认 `discernlen`)
|
||||
- Hatchet:可访问 gRPC 与 API,且已准备 client token
|
||||
- OIDC(如使用):已登记回调地址 `https://<host>/api/v1/auth/callback`
|
||||
|
||||
资源请求合计约 **450m CPU / 736Mi 内存**;limits 合计约 **4 CPU / 5.75Gi 内存**。按项目配额调整 `resources`。
|
||||
资源请求合计约 **650m CPU / 1.25Gi 内存**;limits 合计约 **7 CPU / 7.75Gi 内存**。按项目配额调整 `resources`。
|
||||
|
||||
## 2. 替换占位符
|
||||
|
||||
@@ -36,24 +37,81 @@
|
||||
|
||||
| 占位符 | 位置 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `registry.example.com/discernlen/discernlen-*:sha-REPLACE_WITH_FULL_COMMIT_SHA` | 4 个 Deployment | 镜像仓库与同一个提交 SHA |
|
||||
| `registry.example.com/discernlen/discernlen-*:sha-REPLACE_WITH_FULL_COMMIT_SHA` | 4 个应用 Deployment | 镜像仓库与同一个提交 SHA |
|
||||
| `ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5` | `discernlen-hatchet` Deployment | Hatchet 镜像;版本与 `versions.lock.yaml` 保持一致 |
|
||||
| `discernlen.kongming.cn` | `OIDC_REDIRECT_URL`、`VirtualService.spec.hosts` | 实际 Istio 域名,两处必须一致 |
|
||||
| `istio-system/global-gateway` | `VirtualService.spec.gateways` | 必须与集群 `ExposeConfig.istio.gateway` 完全一致 |
|
||||
| `https://s3.example.com` / `discernlen` | ConfigMap `discernlen-env` | S3 endpoint 与 bucket |
|
||||
| `hatchet-grpc.example.com:443` / `https://hatchet.example.com` | ConfigMap `discernlen-env` | Hatchet gRPC 与 API 地址 |
|
||||
| `tls` | `HATCHET_CLIENT_TLS_STRATEGY` | 集群内明文用 `none`,TLS 用 `tls` |
|
||||
| `https://auth.example.com/...` / `discernlen` | ConfigMap `discernlen-env` | OIDC issuer 与 client ID |
|
||||
| `oidc` | `AUTH_MODE` | 生产用 `oidc`;仅本地演示可用 `dev` |
|
||||
| `local` | `POOL_ID` / `DEFAULT_POOL_ID` | 与 discernlen 执行池 ID 一致;每个集群应使用独立 ID |
|
||||
|
||||
在 `runtime-secret.example.yaml` 中替换数据库、S3、Hatchet、OIDC 凭据。
|
||||
在 `runtime-secret.example.yaml` 中替换数据库、S3、Hatchet client token、OIDC 凭据;在 `hatchet-secret.example.yaml` 中替换 Hatchet 数据库连接与密钥。
|
||||
|
||||
## 3. 创建 Secret
|
||||
|
||||
项目命名空间就是孔明项目 ID。下面的 `<project-id>` 需要替换为实际值。
|
||||
|
||||
### 3.1 生成 Hatchet keyset 与 cookie secrets
|
||||
|
||||
三个 `SERVER_ENCRYPTION_*` keyset 由同一条 `hatchet-admin keyset create-local-keys` 命令一次性生成,不需要数据库。任选一种方式执行:
|
||||
|
||||
**方式 A:本机 Docker**
|
||||
|
||||
```bash
|
||||
# 运行时凭据
|
||||
docker run --rm --entrypoint /hatchet-admin \
|
||||
ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5 keyset create-local-keys
|
||||
```
|
||||
|
||||
**方式 B:集群内临时 Pod(本机没有 Docker 时)**
|
||||
|
||||
```bash
|
||||
kubectl -n <project-id> run hatchet-keyset --rm -i --restart=Never \
|
||||
--image=ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5 \
|
||||
--command -- /hatchet-admin keyset create-local-keys
|
||||
```
|
||||
|
||||
输出与字段对应关系:
|
||||
|
||||
| 命令输出 | 填入字段 |
|
||||
| --- | --- |
|
||||
| `Master Key Bytes` | `SERVER_ENCRYPTION_MASTER_KEYSET` |
|
||||
| `Private EC256 Keyset` | `SERVER_ENCRYPTION_JWT_PRIVATE_KEYSET` |
|
||||
| `Public EC256 Keyset` | `SERVER_ENCRYPTION_JWT_PUBLIC_KEYSET` |
|
||||
| `Insecure Public Handle EC256 Keyset` | 不需要 |
|
||||
|
||||
另外生成 cookie secrets:
|
||||
|
||||
```bash
|
||||
printf '%s %s\n' "$(openssl rand -hex 16)" "$(openssl rand -hex 16)"
|
||||
```
|
||||
|
||||
把结果填入 `hatchet-secret.example.yaml`。keyset 是单行 base64,示例中使用 `|-` 去掉块标量末尾换行;生成后不要再次重新生成,否则已签发的 client token 会失效。
|
||||
|
||||
如果希望直接打印可粘贴的 YAML 片段,可以执行:
|
||||
|
||||
```bash
|
||||
OUT=$(docker run --rm --entrypoint /hatchet-admin \
|
||||
ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5 keyset create-local-keys)
|
||||
|
||||
for pair in \
|
||||
"MASTER_KEYSET|Master Key Bytes" \
|
||||
"JWT_PRIVATE_KEYSET|Private EC256 Keyset" \
|
||||
"JWT_PUBLIC_KEYSET|Public EC256 Keyset"; do
|
||||
field=${pair%%|*}
|
||||
label=${pair#*|}
|
||||
value=$(printf '%s\n' "$OUT" | sed -n "/^${label}:\$/{n;p;}")
|
||||
printf 'SERVER_ENCRYPTION_%s: |-\n %s\n' "$field" "$value"
|
||||
done
|
||||
```
|
||||
|
||||
### 3.2 创建 Secret
|
||||
|
||||
```bash
|
||||
# Hatchet 服务端凭据与加密密钥
|
||||
kubectl apply -f hatchet-secret.example.yaml
|
||||
|
||||
# 运行时凭据(HATCHET_CLIENT_TOKEN 首次先填 CHANGE_ME)
|
||||
kubectl apply -f runtime-secret.example.yaml
|
||||
|
||||
# 私有镜像仓库(推荐用命令生成,避免手写 base64)
|
||||
@@ -63,10 +121,32 @@ kubectl -n <project-id> create secret docker-registry discernlen-registry \
|
||||
--docker-password='<password>'
|
||||
```
|
||||
|
||||
这两个 Secret 不属于自定义工作负载,停止或删除工作负载时不会被清理。若镜像可匿名拉取,删除 `discernlen.yaml` 中四个 Deployment 的 `imagePullSecrets` 字段。
|
||||
这三个 Secret 不属于自定义工作负载,停止或删除工作负载时不会被清理。若镜像仓库需要认证,为五个 Deployment 添加 `imagePullSecrets: [{name: discernlen-registry}]`;镜像可匿名拉取时忽略该 Secret。
|
||||
|
||||
> 不要把 Secret 文档追加到主 Manifest。主 Manifest 会被平台版本化保存,凭据会进入工作负载历史与快照;孔明的交付/镜像热更新接口也会拒绝包含 Secret 数据的 Manifest。
|
||||
|
||||
### 3.3 首次部署后生成 Hatchet client token
|
||||
|
||||
`discernlen-runtime` 中的 `HATCHET_CLIENT_TOKEN` 必须由运行中的 Hatchet 签发。首次提交工作负载后,api / worker 会因为 token 无效而重启,这是预期行为。
|
||||
|
||||
```bash
|
||||
export NS='<project-id>'
|
||||
|
||||
# 等待 Hatchet 完成迁移、seed 并通过就绪检查
|
||||
kubectl -n "$NS" rollout status deploy/discernlen-hatchet --timeout=10m
|
||||
|
||||
# 生成长期有效的 token(默认 90 天,这里改为 10 年)
|
||||
TOKEN=$(kubectl -n "$NS" exec deploy/discernlen-hatchet -- \
|
||||
./hatchet-admin token create --config /config --name discernlen --expiresIn 87600h | tail -n 1)
|
||||
|
||||
# 写回 runtime Secret 并滚动重启 API / Worker
|
||||
kubectl -n "$NS" patch secret discernlen-runtime --type merge \
|
||||
-p "{\"stringData\":{\"HATCHET_CLIENT_TOKEN\":\"$TOKEN\"}}"
|
||||
kubectl -n "$NS" rollout restart deploy/discernlen-api deploy/discernlen-worker
|
||||
```
|
||||
|
||||
token 由 `discernlen-hatchet` Secret 中的 keyset 签名,并保存在 Hatchet 数据库中。只要 keyset 不变,Pod 重建、工作负载停止/启动都不需要重新签发。
|
||||
|
||||
## 4. 提交自定义工作负载
|
||||
|
||||
### 方式 A:平台页面
|
||||
@@ -108,6 +188,7 @@ jq -n --rawfile manifest discernlen.yaml '{
|
||||
|
||||
```bash
|
||||
kubectl -n <project-id> get deploy,svc,pod,virtualservice
|
||||
kubectl -n <project-id> rollout status deploy/discernlen-hatchet
|
||||
kubectl -n <project-id> rollout status deploy/discernlen-api
|
||||
kubectl -n <project-id> rollout status deploy/discernlen-worker
|
||||
kubectl -n <project-id> rollout status deploy/discernlen-bff
|
||||
@@ -117,16 +198,28 @@ curl -I https://discernlen.kongming.cn/
|
||||
curl -s https://discernlen.kongming.cn/api/v1/auth/config
|
||||
```
|
||||
|
||||
Hatchet 自身未通过 Istio 暴露,需要查看 Dashboard 时使用端口转发:
|
||||
|
||||
```bash
|
||||
kubectl -n <project-id> port-forward svc/discernlen-hatchet 8888:8888
|
||||
# http://localhost:8888
|
||||
```
|
||||
|
||||
默认 Dashboard 管理员由 Hatchet quickstart seed:`admin@example.com` / `Admin123!!`。生产环境请在首次启动前通过 `discernlen-hatchet` Secret 的 `ADMIN_EMAIL` / `ADMIN_PASSWORD` 覆盖。
|
||||
|
||||
平台详情页的“访问地址”应显示 `https://discernlen.kongming.cn`(由 VirtualService host 收集)。
|
||||
|
||||
## 6. 运维注意事项
|
||||
|
||||
- **一个工作负载管理全部组件**:启停、删除、权限、历史都以整体为单位。停止会删除四个 Deployment 等工作负载资源,但保留 Service、ConfigMap、VirtualService(入口会暂时返回 5xx);再次启动会重新应用 Manifest。删除工作负载会清理 Manifest 中的全部资源,但不会删除单独创建的 `discernlen-runtime` / `discernlen-registry` Secret。
|
||||
- **配置变更需要重启 Pod**:`discernlen-env`、`discernlen-nginx`、`discernlen-runtime` 修改后,Pod 不会自动滚动。请在平台重启工作负载或删除对应 Pod。`discernlen-nginx` 使用 `subPath` 挂载,修改后必须重启 web Pod。
|
||||
- **一个工作负载管理全部组件**:启停、删除、权限、历史都以整体为单位。停止会删除五个 Deployment 等工作负载资源,但保留 Service、ConfigMap、VirtualService(入口会暂时返回 5xx);再次启动会重新应用 Manifest。删除工作负载会清理 Manifest 中的全部资源,但不会删除单独创建的 `discernlen-runtime` / `discernlen-hatchet` / `discernlen-registry` Secret。
|
||||
- **配置变更需要重启 Pod**:`discernlen-env`、`discernlen-hatchet-env`、`discernlen-nginx`、`discernlen-runtime`、`discernlen-hatchet` 修改后,Pod 不会自动滚动。请在平台重启工作负载或删除对应 Pod。`discernlen-nginx` 使用 `subPath` 挂载,修改后必须重启 web Pod。
|
||||
- **Hatchet 是单实例**:`discernlen-hatchet` 固定 `replicas: 1`,升级策略为 `Recreate`。`/config` 使用 `emptyDir`,每次启动都会重新生成 `server.yaml`;真正的持久状态在外部 PostgreSQL 的 `hatchet` 数据库中。
|
||||
- **不要修改 Hatchet keyset**:`discernlen-hatchet` 中的 `SERVER_ENCRYPTION_*` 必须保持稳定。修改后已签发的 `HATCHET_CLIENT_TOKEN` 全部失效,需要重新执行 3.3 生成 token 并重启 api / worker。
|
||||
- **Hatchet token 有效期**:`hatchet-admin token create` 默认 90 天。建议用 `--expiresIn 87600h`,或在到期前重新签发并更新 Secret。
|
||||
- **worker 临时目录**:`/work` 默认是 20Gi `emptyDir`。数据量大时,在孔明存储页创建 PVC,然后按 Manifest 中注释挂载;自定义工作负载 Manifest **不能直接声明 PVC**,只能引用已创建且当前用户有权限的 PVC。
|
||||
- **入口超时**:VirtualService 显式设置 `timeout: 0s`,避免 Istio 默认 15s 超时截断 SSE / 长时间请求。nginx 也配置了 `proxy_read_timeout 24h`。
|
||||
- **mTLS**:若命名空间启用严格 mTLS 或需要 Istio 指标,在四个 Deployment 的 Pod template 增加注解 `sidecar.istio.io/inject: "true"`。
|
||||
- **mTLS**:若命名空间启用严格 mTLS 或需要 Istio 指标,在五个 Deployment 的 Pod template 增加注解 `sidecar.istio.io/inject: "true"`。
|
||||
- **OIDC 回调**:`OIDC_REDIRECT_URL` 必须与浏览器实际访问的 host 完全一致,否则登录回调失败。
|
||||
- **数据库迁移**:API 首次启动执行 schema 迁移;升级镜像不会自动回滚 schema。
|
||||
- **数据库迁移**:API 与 Hatchet 启动时都会执行各自的 schema 迁移;升级镜像不会自动回滚 schema。Hatchet 使用独立的 `hatchet` 数据库,不要与 `discernlen` 库混用。
|
||||
- **Secret 与 Manifest**:运行时 Secret 不放入主 Manifest,避免凭据进入版本历史。若必须放入,请评估项目内可见范围。
|
||||
- **全栈依赖**:如需把 PostgreSQL / MinIO / Hatchet 也部署到孔明,建议拆成独立的自定义工作负载,通过同命名空间 Service DNS 访问,并先用孔明存储页创建所需 PVC。
|
||||
- **其余依赖**:如还需把 PostgreSQL / MinIO 也部署到孔明,建议拆成独立的自定义工作负载,通过同命名空间 Service DNS 访问,并先用孔明存储页创建所需 PVC。
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
# discernlen 在孔明平台“自定义工作负载”中的部署清单。
|
||||
#
|
||||
# 使用方式:
|
||||
# 1. 先按 README.md 替换占位符,并创建 discernlen-runtime / discernlen-registry Secret。
|
||||
# 1. 先按 README.md 替换占位符,并创建 discernlen-runtime / discernlen-hatchet /
|
||||
# discernlen-registry Secret。
|
||||
# 2. 在孔明平台选择项目与集群,创建自定义工作负载,将本文件内容粘贴到 YAML Manifest。
|
||||
# 3. Hatchet 就绪后生成 client token,写入 discernlen-runtime 并重启 api / worker。
|
||||
#
|
||||
# 说明:
|
||||
# - 不要在本文件里写 namespace。平台会把所有命名空间级资源的 namespace 重写为项目 ID。
|
||||
# - 平台会自动注入 kongming.io/* 管理 Label,本文件中的 Label 只用于同工作负载内的选择器。
|
||||
# - 不建议在本文件中放 Secret;凭据请通过 runtime-secret.example.yaml 单独创建。
|
||||
# - 本清单不包含 PostgreSQL / MinIO / Hatchet,使用外部服务(与官方 k8s/Helm 部署一致)。
|
||||
# - 不建议在本文件中放 Secret;凭据请通过 runtime-secret.example.yaml /
|
||||
# hatchet-secret.example.yaml 单独创建。
|
||||
# - 本清单包含 Hatchet(hatchet-lite),但不包含 PostgreSQL / MinIO;数据库和对象存储
|
||||
# 使用外部服务。Hatchet 的数据库连接与加密密钥由 discernlen-hatchet Secret 提供。
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 非敏感运行配置
|
||||
@@ -22,22 +26,23 @@ metadata:
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
data:
|
||||
LISTEN_ADDR: ":8080"
|
||||
S3_ENDPOINT: "https://s3.example.com"
|
||||
S3_BUCKET: "discernlen"
|
||||
HATCHET_CLIENT_HOST_PORT: "hatchet-grpc.example.com:443"
|
||||
HATCHET_CLIENT_SERVER_URL: "https://hatchet.example.com"
|
||||
HATCHET_CLIENT_TLS_STRATEGY: "tls"
|
||||
S3_ENDPOINT: "http://internal.s3-tw-tp.ufileos.com"
|
||||
S3_BUCKET: "discern"
|
||||
HATCHET_CLIENT_HOST_PORT: "discernlen-hatchet:7077"
|
||||
HATCHET_CLIENT_SERVER_URL: "http://discernlen-hatchet:8888"
|
||||
HATCHET_CLIENT_TLS_STRATEGY: "none"
|
||||
HATCHET_CLIENT_LOG_LEVEL: "warn"
|
||||
AUTH_MODE: "oidc"
|
||||
OIDC_ISSUER: "https://auth.example.com/application/o/discernlen/"
|
||||
OIDC_CLIENT_ID: "discernlen"
|
||||
OIDC_REDIRECT_URL: "https://discernlen.kongming.cn/api/v1/auth/callback"
|
||||
OIDC_ISSUER: "https://auth.agentwithu.com/application/o/discernlen/"
|
||||
OIDC_CLIENT_ID: "UaVO1GmTIzMUlqOLANFnhTxscJnyjUATsIDwZArg"
|
||||
OIDC_REDIRECT_URL: "https://discernlen.agentwithu.com/api/v1/auth/callback"
|
||||
DEMO_TARGET_URL: ""
|
||||
DEMO_TOKENIZER: "/app/presets/demo/tokenizer.json"
|
||||
POOL_ID: "local"
|
||||
DEFAULT_POOL_ID: "local"
|
||||
ADAPTER_DIR: "/app/adapters"
|
||||
WORK_DIR: "/work"
|
||||
TZ: "Asia/Shanghai"
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Web 入口的 nginx 配置
|
||||
@@ -110,7 +115,7 @@ spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: api
|
||||
image: registry.example.com/discernlen/discernlen-api:sha-REPLACE_WITH_FULL_COMMIT_SHA
|
||||
image: git.agentwithu.com/discernlen/discernlen-api:sha-3f2e2cff8ebc21a077435cb4857c420e7bdba931
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
@@ -166,7 +171,7 @@ spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: worker
|
||||
image: registry.example.com/discernlen/discernlen-worker:sha-REPLACE_WITH_FULL_COMMIT_SHA
|
||||
image: git.agentwithu.com/discernlen/discernlen-worker:sha-3f2e2cff8ebc21a077435cb4857c420e7bdba931
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
@@ -179,7 +184,7 @@ spec:
|
||||
memory: 512Mi
|
||||
ephemeral-storage: 1Gi
|
||||
limits:
|
||||
cpu: "2"
|
||||
cpu: "4"
|
||||
memory: 4Gi
|
||||
ephemeral-storage: 20Gi
|
||||
volumeMounts:
|
||||
@@ -224,7 +229,7 @@ spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: bff
|
||||
image: registry.example.com/discernlen/discernlen-bff:sha-REPLACE_WITH_FULL_COMMIT_SHA
|
||||
image: git.agentwithu.com/discernlen/discernlen-bff:sha-3f2e2cff8ebc21a077435cb4857c420e7bdba931
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: API_URL
|
||||
@@ -280,7 +285,7 @@ spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: web
|
||||
image: registry.example.com/discernlen/discernlen-web:sha-REPLACE_WITH_FULL_COMMIT_SHA
|
||||
image: git.agentwithu.com/discernlen/discernlen-web:sha-3f2e2cff8ebc21a077435cb4857c420e7bdba931
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
@@ -313,6 +318,109 @@ spec:
|
||||
name: discernlen-nginx
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Hatchet
|
||||
#
|
||||
# 使用 hatchet-lite 单实例:HTTP API / Dashboard 8888,gRPC 7077。
|
||||
# 依赖外部 PostgreSQL 中的 hatchet 数据库;DATABASE_URL、cookie secrets 与三组
|
||||
# encryption keyset 由单独创建的 discernlen-hatchet Secret 注入。
|
||||
#
|
||||
# /config 使用 emptyDir。Hatchet 每次启动都会重新生成 server.yaml,但只要 Secret
|
||||
# 中的 keyset 不变,已签发的 client token 在 Pod 重建后仍然有效。
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: discernlen-hatchet-env
|
||||
labels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
app.kubernetes.io/component: hatchet
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
data:
|
||||
SERVER_URL: "http://discernlen-hatchet:8888"
|
||||
SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
|
||||
SERVER_GRPC_PORT: "7077"
|
||||
SERVER_GRPC_INSECURE: "t"
|
||||
SERVER_GRPC_BROADCAST_ADDRESS: "discernlen-hatchet:7077"
|
||||
SERVER_INTERNAL_CLIENT_INTERNAL_GRPC_BROADCAST_ADDRESS: "127.0.0.1:7077"
|
||||
SERVER_AUTH_SET_EMAIL_VERIFIED: "t"
|
||||
# Dashboard 仅通过 port-forward 访问,允许 localhost 上的非 Secure cookie。
|
||||
# 若后续通过 HTTPS 暴露 Dashboard,请删除 SERVER_AUTH_COOKIE_INSECURE 并配置域名。
|
||||
SERVER_AUTH_COOKIE_DOMAIN: "localhost"
|
||||
SERVER_AUTH_COOKIE_INSECURE: "t"
|
||||
TZ: "Asia/Shanghai"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: discernlen-hatchet
|
||||
labels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
app.kubernetes.io/component: hatchet
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
spec:
|
||||
replicas: 1
|
||||
# Hatchet Lite 是单实例组件,升级时避免新旧 Pod 同时写同一个数据库。
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
app.kubernetes.io/component: hatchet
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: hatchet
|
||||
image: ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: discernlen-hatchet-env
|
||||
- secretRef:
|
||||
name: discernlen-hatchet
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8888
|
||||
- name: grpc
|
||||
containerPort: 7077
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /api/ready
|
||||
port: http
|
||||
periodSeconds: 5
|
||||
failureThreshold: 60
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/ready
|
||||
port: http
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/live
|
||||
port: http
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 5
|
||||
resources:
|
||||
requests:
|
||||
cpu: 200m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 2Gi
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
volumes:
|
||||
- name: config
|
||||
emptyDir: {}
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# 内部 Service
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
@@ -363,6 +471,25 @@ spec:
|
||||
port: 80
|
||||
targetPort: http
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: discernlen-hatchet
|
||||
labels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
ports:
|
||||
- name: http
|
||||
port: 8888
|
||||
targetPort: http
|
||||
- name: grpc
|
||||
port: 7077
|
||||
targetPort: grpc
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Istio 入口
|
||||
#
|
||||
@@ -384,7 +511,7 @@ spec:
|
||||
gateways:
|
||||
- istio-system/global-gateway
|
||||
hosts:
|
||||
- discernlen.kongming.cn
|
||||
- discernlen.agentwithu.com
|
||||
http:
|
||||
- name: discernlen-web
|
||||
match:
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# Hatchet 服务端凭据与加密密钥。
|
||||
#
|
||||
# 该 Secret 不在 discernlen.yaml 中,避免密钥进入自定义工作负载的 Manifest
|
||||
# 版本历史和快照。请先在项目命名空间创建它,再创建/更新自定义工作负载。
|
||||
#
|
||||
# 项目命名空间即孔明项目 ID,例如 project-id-placeholder 需替换为实际值。
|
||||
#
|
||||
# 生成 keyset(任选一种环境,不需要数据库):
|
||||
#
|
||||
# 方式 A:本机 Docker
|
||||
# docker run --rm --entrypoint /hatchet-admin \
|
||||
# ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5 keyset create-local-keys
|
||||
#
|
||||
# 方式 B:集群内临时 Pod(无需本机 Docker)
|
||||
# kubectl -n <project-id> run hatchet-keyset --rm -i --restart=Never \
|
||||
# --image=ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.110.5 \
|
||||
# --command -- /hatchet-admin keyset create-local-keys
|
||||
#
|
||||
# 输出到字段的对应关系:
|
||||
# Master Key Bytes -> SERVER_ENCRYPTION_MASTER_KEYSET
|
||||
# Private EC256 Keyset -> SERVER_ENCRYPTION_JWT_PRIVATE_KEYSET
|
||||
# Public EC256 Keyset -> SERVER_ENCRYPTION_JWT_PUBLIC_KEYSET
|
||||
# Insecure Public Handle EC256 Keyset -> 不需要
|
||||
#
|
||||
# 生成 cookie secrets(两个随机值,空格分隔):
|
||||
# printf '%s %s\n' "$(openssl rand -hex 16)" "$(openssl rand -hex 16)"
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: discernlen-hatchet
|
||||
namespace: project-id-placeholder
|
||||
labels:
|
||||
app.kubernetes.io/name: discernlen-hatchet
|
||||
app.kubernetes.io/part-of: discernlen
|
||||
type: Opaque
|
||||
stringData:
|
||||
# Hatchet 专用数据库。需提前在 PostgreSQL 中创建(deploy/init-db.sql 中为 hatchet)。
|
||||
# 该用户需要能在库中建表/执行迁移;也可以复用 discernlen 用户。
|
||||
DATABASE_URL: "postgres://hatchet:CHANGE_ME@postgres.example.com:5432/hatchet?sslmode=require"
|
||||
|
||||
# 两个随机 cookie secret,空格分隔。
|
||||
SERVER_AUTH_COOKIE_SECRETS: "CHANGE_ME_HASH CHANGE_ME_BLOCK"
|
||||
|
||||
# 可选:首次启动时 seed 的 Dashboard 管理员。仅在用户不存在时生效。
|
||||
# 不设置时使用 Hatchet 默认的 admin@example.com / Admin123!!。
|
||||
# ADMIN_EMAIL: "admin@example.com"
|
||||
# ADMIN_PASSWORD: "CHANGE_ME"
|
||||
|
||||
# 三组 encryption keyset。必须保持稳定:修改后已签发的 client token 会全部失效。
|
||||
# 每个值是一行 base64(无换行),使用 |- 就是为了去掉块标量末尾的换行。
|
||||
SERVER_ENCRYPTION_MASTER_KEYSET: |-
|
||||
CHANGE_ME_MASTER_KEYSET
|
||||
SERVER_ENCRYPTION_JWT_PRIVATE_KEYSET: |-
|
||||
CHANGE_ME_JWT_PRIVATE_KEYSET
|
||||
SERVER_ENCRYPTION_JWT_PUBLIC_KEYSET: |-
|
||||
CHANGE_ME_JWT_PUBLIC_KEYSET
|
||||
@@ -23,7 +23,11 @@ stringData:
|
||||
S3_ACCESS_KEY: "CHANGE_ME"
|
||||
S3_SECRET_KEY: "CHANGE_ME"
|
||||
|
||||
# Hatchet token。与 ConfigMap 中的 HATCHET_CLIENT_HOST_PORT / SERVER_URL 配套。
|
||||
# Hatchet client token。先部署 Hatchet,再用下面的命令生成并填入:
|
||||
# kubectl -n <project-id> exec deploy/discernlen-hatchet -- \
|
||||
# ./hatchet-admin token create --config /config --name discernlen --expiresIn 87600h
|
||||
# 与 ConfigMap 中的 HATCHET_CLIENT_HOST_PORT / SERVER_URL 配套。
|
||||
# token 由 discernlen-hatchet Secret 中的 keyset 签名,修改 keyset 后需重新生成。
|
||||
HATCHET_CLIENT_TOKEN: "CHANGE_ME"
|
||||
|
||||
# 仅 confidential OIDC client 需要;public PKCE client 删除这一行。
|
||||
|
||||
Reference in New Issue
Block a user