自托管部署控制面

Luma Depoly

把域名、端口、入口和 region 写进 YAML。Luma 负责同步 Cloudflare DNS、 Traefik HTTPS 路由和 Swarm 服务;每台服务器只需要在本机加入集群。

DNS Cloudflare 同步 TLS Traefik ACME Nodes region 标签
$ curl -fsSL https://raw.githubusercontent.com/LiuTianjie/luma/main/scripts/install-luma.sh | sh
部署预览 status.example.com
01 Manifest status.yaml domain: status.example.com
exposure: cn-edge
port: 80
02 Control Luma Control 把一份 manifest 转成 DNS、证书、路由和服务更新
Cloudflare DNS status.example.com -> cn-edge
Traefik Edge Host 规则 + ACME 证书
Swarm Nodes status:80 副本 x2
$ 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
Domainstatus.example.com Exposurecn-edge Targetstatus:80
域名写在清单里 domain 就是服务访问地址
Cloudflare 管理 DNS 按 exposure 指到对应入口
Traefik 处理 HTTPS 每个 Host 都走自己的证书
私有镜像 registry token 不写进 YAML

先把这些东西备好。

01 域名

控制 API 和公开服务都要用真实域名,例如 luma.example.comstatus.example.com

02 Cloudflare DNS

DNS zone 放在 Cloudflare,并准备一个能读取 zone、修改 DNS 记录的 API token。

03 Linux Manager

先准备一台有 sudo 权限的 Linux 服务器。2c2g 可以试用,但业务服务要限制资源。

04 Tailscale 可选

单台公网 manager 不一定要 Tailscale。home 节点、私有 join 或 tailscale-relay 才需要。

每条命令会更新什么。

Manager 安装 CLI 01 / 06
在 manager 上安装 luma
Manager / Control CLI 已安装
Traefik Edge 未创建
CN Worker 未加入
Global Worker 未加入
Client 未登录
域名 还没有服务 deploy 时读取 manifest
DNS 等待中 deploy 时写入记录
证书 等待中 Traefik 按 Host 申请证书
路由与负载 等待中 Traefik 转发到 service:port
status.yaml
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
    读服务入口

    读取 domainportexposure,确定访问地址和目标端口。

  • 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