Communitygithub.com

uncloud

Uncloud クラスターの管理時に使用します — サービスのデプロイ、Caddy イングレスの設定、非クラスターデバイス用の静的プロキシルートの追加、ポートの公開、スケーリング、ログの確認、`uc` CLI を使用したマシンやボリュームの管理を行います。

uncloud とは?

このスキルは、Docker コンテナ、WireGuard メッシュネットワーキング、Caddy リバースプロキシを利用した分散型セルフホスティングプラットフォームである Uncloud クラスターを管理するための `uc` CLI の包括的なリファレンスを提供します。主なユースケースとしては、マシンのブートストラップや参加、Compose ファイルからのサービスデプロイ、HTTP/HTTPS/TCP/UDP ポートの公開、Caddy イングレスのカスタム設定、クラスタープロキシを介した外部 LAN デバイスのルーティング、ログやサービス状態の確認などが含まれます。このスキルは、Caddy の自動設定、サービス間 DNS、`x-caddy` や `x-machines` などの Compose ファイル拡張、イメージ管理、ボリューム管理、スケーリングなど、Uncloud の分散アーキテクチャを深く理解する上で不可欠です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/uncloud

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Uncloud クラスター管理

uc CLI のリファレンス — Docker コンテナ、WireGuard メッシュネットワーキング、Caddy リバースプロキシを使用した分散型セルフホスティングプラットフォーム。

有効化タイミング

Uncloud クラスターを操作する際にこのスキルを使用します。特に以下の場合:

  • uc machine でのマシンのブートストラップや参加
  • Compose ファイルからの uc deploy によるサービスのデプロイ
  • Uncloud 経由での HTTP、HTTPS、TCP、UDP ポートの公開
  • x-caddy、x-ports、または --caddyfile を使用した Caddy イングレスの設定
  • クラスタープロキシを介した外部 LAN デバイスのルーティング
  • ログ、サービス状態、ボリューム、DNS、マシン配置の確認

動作の仕組み

Uncloud は WireGuard メッシュで接続されたピアマシン上で Docker サービスを実行します。各マシンはクラスターの同等のメンバーであり、サービスはオーバーレイネットワーク上で通信し、Caddy はパブリックな HTTP/HTTPS トラフィックを終端するためにグローバルに実行されます。Compose ファイルでは、イングレス、配置、生成された Caddy 設定に Uncloud 拡張を使用でき、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 deploycompose.yaml からデプロイ
uc deploy --no-buildリビルドせずに既にプッシュされたイメージをデプロイ
uc deploy --recreateサービスを強制的に再作成
uc scale SERVICE Nレプリカ数を設定
uc service logs SERVICEログを表示
uc service exec SERVICEコンテナにシェル接続
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 [ホスト名:]コンテナポート[/プロトコル]
例意味
-p 8080/https自動 サービス名.クラスタードメイン ホスト名で HTTPS
-p app.example.com:8080/httpsカスタムホスト名で HTTPS
-p 8080/httpHTTP のみ、TLS なし

TCP/UDP(ホストバインド、Caddy をバイパス)

-p [ホストIP:]ホストポート:コンテナポート[/プロトコル]@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:ポート

2. 名前付きサービスとして登録(no-op コンテナ):

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

pause は最小限の no-op コンテナです — 何も行いませんが、Caddyfile をアタッチするためのサービスエントリを Uncloud に提供します。

3. 確認:

uc caddy config   # device.example.com ブロックが表示されるはずです

--caddyfile は、@host 以外の公開ポートと組み合わせることはできません。

DNS ヒント: ワイルドカードレコード(*.yourdomain.com → クラスターパブリック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   # すべてのマシンに 1 コンテナ

イメージタグテンプレート(compose.yaml 内)

image: myapp:{{gitdate "20060102"}}.{{gitsha 7}}
image: myapp:{{gitsha 7}}.${GITHUB_RUN_ID:-local}
関数出力
{{gitsha N}}コミット SHA の先頭 N 文字
{{gitdate "format"}}Git コミット日時(Go 形式)
{{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                        # シェルを開く
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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

関連スキル