Communitygithub.com

Uncloud 集群管理

用于管理 Uncloud 集群 — 部署服务、配置 Caddy 入口、为非集群设备添加静态代理路由、发布端口、扩缩容、检查日志以及使用 `uc` CLI 管理机器和卷。

Uncloud 集群管理 是什么?

该技能提供了使用 `uc` CLI 管理 Uncloud 集群的完整参考。Uncloud 是一个去中心化的自托管平台,基于 Docker 容器、WireGuard 网格网络和 Caddy 反向代理构建。它支持引导和加入机器、从 Compose 文件部署服务、通过 Uncloud 发布 HTTP/HTTPS/TCP/UDP 端口、配置 Caddy 入口、将外部 LAN 设备路由到集群代理,以及检查日志、服务状态、卷、DNS 和机器放置。该技能涵盖了核心概念,如没有中央控制平面、Caddy 作为全局服务运行、自动生成 Caddyfile 以及覆盖网络。此外,还提供了 Compose 文件的扩展功能,包括 `x-ports`(发布带域名的端口)、`x-caddy`(自定义 Caddy 配置)和 `x-machines`(放置约束),以及用于将外部设备暴露到集群的 Caddyfile 片段支持。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/uncloud

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Uncloud 集群管理 是做什么的?

uc CLI 的参考文档 — 一个使用 Docker 容器、WireGuard 网格网络和 Caddy 反向代理的去中心化自托管平台。

何时激活

在使用 Uncloud 集群时使用此技能,特别是当:

  • 使用 uc machine 引导或加入机器
  • 使用 uc deploy 从 Compose 文件部署服务
  • 通过 Uncloud 发布 HTTP、HTTPS、TCP 或 UDP 端口
  • 使用 x-caddy、x-ports 或 --caddyfile 配置 Caddy 入口
  • 通过集群代理路由外部 LAN 设备
  • 检查日志、服务状态、卷、DNS 或机器放置

工作原理

Uncloud 在通过 WireGuard 网格连接的机器上运行 Docker 服务。每台机器都是平等的集群成员;服务在覆盖网络上通信,Caddy 全局运行以终止公共 HTTP/HTTPS 流量。Compose 文件可以使用 Uncloud 扩展来实现入口、放置和生成的 Caddy 配置,而 uc CLI 则负责镜像分发、调度、扩缩容、日志和集群状态。

示例

uc machine init user@host --name machine-1
uc service run --name web -p app.example.com:8080/https nginx:latest
uc deploy

核心概念

  • 无中央控制平面 — 所有机器都是通过 WireGuard 连接的平等对等节点
  • Caddy 作为全局服务在每台机器上运行;自动从 Let's Encrypt 获取 TLS 证书
  • 覆盖网络 — 服务默认通过 10.210.0.0/16 通信;网格内提供 DNS
  • Caddyfile 是自动生成的 — 永远不要直接编辑它;使用 x-caddy / --caddyfile

CLI 快速参考

机器

命令目的
uc machine init user@host引导第一台机器 / 新集群
uc machine add user@host将机器加入现有集群
uc machine ls列出机器
uc machine update NAME --public-ip IP更新入口的公共 IP
uc machine rm NAME移除机器

关键 init 标志:--name、--network 10.210.0.0/16、--no-caddy、--no-dns、--public-ip auto|IP|none

服务

命令目的
uc service ls / uc ls列出服务
uc service run IMAGE运行单个容器服务
uc deploy从 compose.yaml 部署
uc deploy --no-build部署已推送的镜像而不重新构建
uc deploy --recreate强制重新创建服务
uc scale SERVICE N设置副本数量
uc service logs SERVICE查看日志
uc service exec SERVICE进入容器 shell
uc service inspect SERVICE详细信息
uc service rm SERVICE移除服务(保留命名卷)
uc ps集群中的所有容器

镜像

uc image push myapp:latest                    # 将本地镜像推送到所有机器
uc image push myapp:latest -m machine1,machine2  # 推送到特定机器
uc images                                     # 列出集群中的镜像

卷

uc volume ls                  # 所有卷
uc volume ls -m machine1      # 特定机器上的卷
uc volume create NAME -m MACHINE
uc volume rm NAME

Caddy

uc caddy config    # 显示当前生成的 Caddyfile(只读)
uc caddy deploy    # 在集群中部署/升级 Caddy

DNS 和上下文

uc dns show        # 显示保留的 *.uncld.dev 域名
uc dns reserve     # 保留新域名
uc ctx ls          # 列出集群上下文
uc ctx use prod    # 切换上下文

端口发布

HTTP/HTTPS(通过 Caddy 反向代理)

-p [hostname:]container_port[/protocol]
示例含义
-p 8080/httpsHTTPS,自动生成 service-name.cluster-domain 主机名
-p app.example.com:8080/httpsHTTPS,自定义主机名
-p 8080/http仅 HTTP,无 TLS

TCP/UDP(主机绑定,绕过 Caddy)

-p [host_ip:]host_port:container_port[/protocol]@host
示例含义
-p 5432:5432@host所有接口上的 TCP 5432
-p 127.0.0.1:5432:5432@host仅本地回环的 TCP 5432
-p 53:5353/udp@hostUDP

Compose 文件扩展

Uncloud 在 Docker Compose 基础上增加了以下扩展:

x-ports — 使用域名发布端口

services:
  app:
    image: app:latest
    x-ports:
      - example.com:8000/https
      - www.example.com:8000/https
      - api.example.com:9000/https

x-caddy — 为服务自定义 Caddy 配置

services:
  app:
    image: app:latest
    x-caddy: |
      example.com {
        redir https://www.example.com{uri} permanent
      }
      www.example.com {
        reverse_proxy {{upstreams 8000}} {
          import common_proxy
        }
        basic_auth /admin/* {
          admin $2a$14$...
        }
      }

x-caddy 内可用的模板函数:

  • {{upstreams [service] [port]}} — 健康容器的 IP
  • {{.Name}} — 服务名称
  • {{.Upstreams}} — 所有服务到 IP 的映射

x-machines — 放置约束

services:
  db:
    image: postgres:18
    x-machines: db-machine          # 单一机器名称
  app:
    image: app:latest
    x-machines:
      - machine-1
      - machine-2

完整的多服务示例

services:
  api:
    build: ./api
    x-ports:
      - api.example.com:3000/https
    environment:
      DATABASE_URL: postgres://db:5432/mydb

  web:
    build: ./web
    x-ports:
      - example.com:8000/https
      - www.example.com:8000/https
    environment:
      API_URL: http://api:3000

  db:
    image: postgres:18
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - db-data:/var/lib/postgresql/data
    x-machines: db-machine

volumes:
  db-data:

路由到外部(非集群)设备

要通过 Caddy 将外部设备(例如 BMC、NAS、路由器 UI)暴露到集群,而无需运行真正的容器:

1. 创建 Caddyfile 片段(例如 ~/device.caddyfile):

https://device.example.com {
    reverse_proxy https://192.168.1.x {
        transport http {
            tls_insecure_skip_verify   # 自签名 BMC 证书需要
        }
    }
    log
}

对于明文上游:reverse_proxy http://192.168.1.x:port

2. 注册为带有无操作容器的命名服务:

uc service run \
  --name device-bmc \
  --caddyfile ~/device.caddyfile \
  registry.k8s.io/pause:3.9

pause 是一个最小的无操作容器——它什么也不做,但为 Uncloud 提供了一个服务条目来附加 Caddyfile。

3. 验证:

uc caddy config   # 应该出现 device.example.com 块

--caddyfile 不能与非 @host 发布的端口结合使用。

DNS 提示: 通配符记录(*.yourdomain.com → cluster-public-ip)意味着任何新的子域名立即可用——每个服务都不需要修改 DNS。


服务 DNS(内部)

集群内的服务通过名称相互解析:

DNS 名称解析为
service-name任何健康的容器
service-name.internal同上
rr.service-name.internal轮询
nearest.service-name.internal优先本地机器

扩缩容和全局服务

uc scale web 5    # 5 个副本(分布在机器上)
uc scale web 1    # 缩容
services:
  caddy:
    deploy:
      mode: global   # 每台机器上一个容器

镜像标签模板(在 compose.yaml 中)

image: myapp:{{gitdate "20060102"}}.{{gitsha 7}}
image: myapp:{{gitsha 7}}.${GITHUB_RUN_ID:-local}
函数输出
{{gitsha N}}提交 SHA 的前 N 个字符
{{gitdate "format"}}以 Go 格式显示的 Git 提交日期
{{date "format"}}当前日期

常见工作流

从源码部署:

uc deploy                          # 构建 + 推送 + 部署
uc build --push && uc deploy --no-build   # 分步执行

检查服务:

uc inspect web
uc logs -f web
uc logs --since 1h web
uc exec web                        # 打开 shell
uc exec web /bin/sh -c "env"       # 运行特定命令

零停机部署 自动完成;Uncloud 会在终止旧容器之前等待健康检查通过。

强制重新创建:

uc deploy --recreate

常见错误

错误修复
直接编辑 Caddyfile在 compose 中使用 x-caddy 或在 uc service run 中使用 --caddyfile
代理带有自签名证书的 HTTPS 上游添加 transport http { tls_insecure_skip_verify }
uc caddy config 未显示用户定义的块Caddy 管理接口不可达 — 检查 uc inspect caddy 和 uc logs caddy
容器无法到达外部 LAN IP验证 Caddy 容器的主机是否可以路由到目标网络
uc service rm 后卷丢失命名卷会保留;只有匿名卷会被自动移除

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能