控制 API 和公开服务都要用真实域名,例如 luma.example.com 和 status.example.com。
自托管部署控制面
Luma Depoly
把域名、端口、入口和 region 写进 YAML。Luma 负责同步 Cloudflare DNS、 Traefik HTTPS 路由和 Swarm 服务;每台服务器只需要在本机加入集群。
curl -fsSL https://raw.githubusercontent.com/LiuTianjie/luma/main/scripts/install-luma.sh | sh
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 swarm status replicated x2
domain 就是服务访问地址
先把这些东西备好。
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
更新服务
更新 stack,把
status.example.com转发到status:80。 -
06
限制资源
业务服务和控制组件共用小型服务器时,用 Swarm resources 限制 CPU 和内存。
按服务器角色执行对应命令。
安装 CLI
先在 manager 上安装 luma。worker 和客户端后面按需安装同一个命令。
curl -fsSL https://raw.githubusercontent.com/LiuTianjie/luma/main/scripts/install-luma.sh | sh
~/.local/bin/luma preflight
初始化控制面
在第一台服务器上初始化 Swarm,并启动 Traefik、Portainer、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