控制 API 和公开服务都要用真实域名,例如 luma.example.com 和 status.example.com。
自托管部署控制面
luma 轻量多服务器管理控制面
把域名、端口、入口和 region 写进 YAML。Luma 负责同步 Cloudflare DNS、 Traefik HTTPS 路由和 Nomad job;每台服务器只需要在本机加入集群。
curl -fsSL https://raw.githubusercontent.com/LiuTianjie/luma/main/scripts/install-luma.sh | sh
Install the skill from https://github.com/LiuTianjie/luma/tree/main/skills/luma-deployment-yaml
或在终端手动安装 (Manual Install)
mkdir -p ~/.codex/skills && git clone --depth 1 https://github.com/LiuTianjie/luma.git /tmp/luma-repo && cp -R /tmp/luma-repo/skills/luma-deployment-yaml ~/.codex/skills/ && rm -rf /tmp/luma-repo
domain: status.example.com
exposure: cn-edge
port: 80
$ luma deploy status.yaml
ok dns status.example.com -> cn-edge
ok tls acme certificate requested
ok route Host(status.example.com) -> status:80
ok nomad status allocations x2
domain 就是服务访问地址
compose.yml 配合 Luma 旁车,轻松编排多服务
先把这些东西备好。
DNS zone 放在 Cloudflare,并准备一个能读取 zone、修改 DNS 记录的 API token。
先准备一台有 sudo 权限的 Linux 服务器。2c2g 可以试用,但业务服务要限制资源。
单台公网 manager 不一定要 Tailscale。home 节点、私有 join 或 tailscale-relay 才需要。
每条命令会更新什么。
name: status
image: traefik/whoami:latest
region: cn
domain: status.example.com
port: 80
exposure: cn-edge
replicas: 2
resources:
limits:
cpus: "0.50"
memory: 512M
Luma 读取 manifest,并更新部署链路。
-
01
读服务入口
读取
domain、port和exposure,确定访问地址和目标端口。 -
02
写 DNS 记录
在 Cloudflare 写入 DNS 记录,让域名指向选中的入口节点。
-
03
建 HTTPS 路由
Traefik 读取 Host 规则,申请证书并创建 HTTPS 路由。
-
04
按需拉取私有镜像
私有 GHCR 或自建 registry 会使用已保存的仓库凭证,不需要把 token 写进 manifest。
-
05
更新服务
更新 Nomad job,把
status.example.com转发到status:80。 -
06
保留版本历史
Nomad 保存 job 版本,控制台和
luma rollback都能回退运行中的 job。 -
07
限制资源
业务服务和控制组件共用小型服务器时,用 Nomad resources 限制 CPU 和内存。
多服务 Compose 与持久化存储卷
-
01
标准的 docker-compose.yml 编排
无侵入设计。继续使用原本的 Compose 文件描述服务依赖与容器网络,方便本地开发测试。
-
02
Luma 旁车文件 (luma.compose.yml)
将 Luma 特有的部署选项(如 Region、域名入口、存储挂载)隔离在旁车中,实现平滑集成。
-
03
声明式共享存储类 (StorageClass)
在控制面注册
cn-nfs存储。Luma 自动按 Region 与网络拓扑动态解析端点并配置挂载。 -
04
数据防丢保护与平滑迁移
严格的安全检查。变更存储位置时自动拦截并要求明确声明
adopted(已迁入)或initialize: empty(空挂载)。
name: app-stack
compose: docker-compose.yml
region: cn
volumes:
pg-data:
storageClass: cn-nfs
path: postgres/pg-data
services:
app:
exposure: cn-edge
domain: app.example.com
port: 3000
version: '3.8'
services:
app:
image: company/app:latest
volumes:
- pg-data:/var/lib/pg/data
postgres:
image: postgres:15
volumes:
- pg-data:/var/lib/postgresql/data
volumes:
pg-data: {}
按服务器角色执行对应命令。
安装 CLI
先在 manager 上安装 luma。worker 和客户端后面按需安装同一个命令。
curl -fsSL https://raw.githubusercontent.com/LiuTianjie/luma/main/scripts/install-luma.sh | sh
~/.local/bin/luma preflight
初始化控制面
在第一台服务器上初始化 Nomad server,并以 Nomad job 启动 Traefik、Luma Control 和 egress gateway。
luma bootstrap manager --domain luma.example.com
加入工作节点
每台服务器自己执行 join,并写入 region 标签。调度主要看 region。
luma node join https://luma.example.com --token <join-token> --region global --name global-sg-1
保存私有 registry 凭证
镜像仓库是私有的,就先保存一次 registry 凭证。
luma login https://luma.example.com --token <deploy-token>
printf '%s' "$GHCR_TOKEN" | luma registry login ghcr.io --username <user> --password-stdin
从客户端部署服务
客户端登录后提交 manifest。Luma 会打印 DNS、证书、路由和 stack 更新进度。
luma login https://luma.example.com --token <deploy-token>
luma deploy status.yaml
官方文档与指南
查阅详细的规则设计、架构原理以及各角色的使用指南。