Files
geo/deploy/k3s
root 9c58fe2312 feat(server): add production-safe platform-template seed job
A fresh production environment only ran migrations, so the four built-in
platform templates were never inserted unless someone manually ran
dev-seed (which also writes broad demo data). Extract the platform
template upsert into a reusable repository.EnsurePlatformTemplates and
add a standalone cmd/seed-platform-templates that calls it. Bake the
binary into the migrate image and chain it after migrate up in both
docker-compose and the k3s migration job (mounting app config so the
binary can dial the right database).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 16:01:55 +08:00
..

geo-rankly k3s deployment

这套清单用于把当前 Docker Compose 拓扑搬到单节点或小集群 k3s 中。默认包含:

  • infra: postgres, monitoring-postgres, rabbitmq, redis, qdrant, minio
  • jobs: migrate, minio-init
  • apps: tenant-api, worker-generate, kol-assist-worker, scheduler, ops-api, frontend, ops-web
  • ingress: geo-rankly.local -> frontend, ops.geo-rankly.local -> ops-web

1. 准备镜像

在线环境建议推到镜像仓库后修改 kustomization.yaml 里的 images

kubectl kustomize deploy/k3s

离线或内网 k3s 可以先用现有打包脚本生成镜像包,再导入到 k3s containerd

bash deploy/scripts/package.sh latest linux/amd64
tar xzf geo-rankly-deploy-*-amd64.tar.gz
cd geo-rankly-deploy-*-amd64
sudo k3s ctr images import images.tar

如果你的服务器是 ARM,把第二个参数换成 linux/arm64

2. 修改密钥

上线前先改 deploy/k3s/secrets.yaml

  • JWT_SECRET
  • OPS_JWT_SECRET
  • OPS_DEFAULT_ADMIN_PASSWORD
  • LLM_API_KEY
  • SILICONFLOW_API_KEY
  • SCHEDULER_INTERNAL_METRICS_TOKEN
  • POSTGRES_PASSWORD / RABBITMQ_DEFAULT_PASS / MINIO_ROOT_*
  • config.local.yaml 里对应的数据库、RabbitMQ、MinIO、JWT、LLM 配置

注意:ops-api 目前从 deploy/k3s/config/ops-config.yaml 读取数据库连接信息;如果改了 Postgres 密码,也同步改这个文件。

3. 部署

kubectl apply -k deploy/k3s
kubectl -n geo-rankly get pods -w

查看一次性任务:

kubectl -n geo-rankly logs job/migrate
kubectl -n geo-rankly logs job/minio-init

如果是升级后需要重新跑迁移:

kubectl -n geo-rankly delete job migrate --ignore-not-found
kubectl apply -k deploy/k3s

4. 访问

k3s 默认 Traefik 会接管 Ingress。先把域名指到 k3s 节点 IP:

<node-ip> geo-rankly.local
<node-ip> ops.geo-rankly.local

然后访问:

  • tenant admin: http://geo-rankly.local
  • ops admin: http://ops.geo-rankly.local

不改 hosts 时可用端口转发:

kubectl -n geo-rankly port-forward svc/frontend 8088:80
kubectl -n geo-rankly port-forward svc/ops-web 8089:80
kubectl -n geo-rankly port-forward svc/rabbitmq 15672:15672
kubectl -n geo-rankly port-forward svc/minio 9001:9001

5. 常用排查

kubectl -n geo-rankly get all
kubectl -n geo-rankly describe pod <pod-name>
kubectl -n geo-rankly logs deploy/tenant-api -f
kubectl -n geo-rankly logs deploy/scheduler -f
kubectl -n geo-rankly logs deploy/worker-generate -f
kubectl -n geo-rankly logs deploy/ops-api -f

如果应用 Pod 先于 migrate 启动失败,通常会自动重启;等 migrate 完成后再看 kubectl -n geo-rankly get pods 即可。