Quick start

This is the whole journey on one page: three servers in, one application out. Each step links to a full walkthrough when you want the detail.

You need sg installed, three Ubuntu 24.04 servers with root SSH, and a Tailscale auth key.

1. Make a project directory

Every spec for one estate lives in one directory. That's where the ledger goes too (.sg/state.db).

mkdir -p ~/estates/lab && cd ~/estates/lab

2. Harden three machines

Do this once per server. Use one spec file per machine.

sg machine init --name node-a --address 203.0.113.10 \
  --key-path ~/.ssh/id_ed25519 --deploy-public-key-path ~/.ssh/id_ed25519.pub \
  --distro ubuntu-24.04 --output node-a.yaml
sg machine init --config node-a.yaml      # validate and register
sg machine plan --config node-a.yaml      # read-only

export TS_AUTHKEY=tskey-auth-...          # your Tailscale auth key
sg machine create --config node-a.yaml    # answer y after reading the plan

Repeat for node-b and node-c. Full walkthrough →

3. Form a cluster

Find each machine's tailnet IPv4 address (tailscale status on your workstation lists them), then write cluster.yaml:

api_version: genesis/v1
cluster:
  name: lab
  members:
    - name: node-a
      core_address: "100.64.0.11:8444"
    - name: node-b
      core_address: "100.64.0.12:8444"
    - name: node-c
      core_address: "100.64.0.13:8444"
sg cluster create --config cluster.yaml

Full walkthrough →

4. Put your app in an image

An application runs whatever LXD image you name, so your code has to be in one. For this tour, build a tiny nginx image on the cluster:

ssh [email protected]                     # any cluster member
lxc launch ubuntu:24.04 build-hello
lxc exec build-hello -- cloud-init status --wait
lxc exec build-hello -- sh -ec '
  apt-get update -q
  DEBIAN_FRONTEND=noninteractive apt-get install -y -q nginx
  rm -f /etc/nginx/sites-enabled/default
  printf "server {\n listen 8080;\n default_type text/plain;\n location = /healthz { return 200 ok; }\n location / { return 200 hello; }\n}\n" > /etc/nginx/conf.d/hello.conf
  systemctl enable nginx'
lxc stop build-hello
lxc publish build-hello --alias hello-web-1
lxc delete build-hello
exit

More on building images →

5. Deploy an application

api_version: genesis/v1
application:
  name: hello
  cluster: lab
  groups:
    - name: web
      count: 2
      image: hello-web-1
      target: {web-0: node-a, web-1: node-b}
      size: {cpu: 1, memory: 1GiB}
      expose:
        - port: 8080/tcp
      health: [/usr/bin/curl, -fsS, http://127.0.0.1:8080/healthz]
  load_balancers:
    - name: edge
      kind: haproxy
      balances: [web]
      target: {edge-0: node-c}
      listen: 8088/tcp
      check: {type: http, path: /healthz, expect_status: 200}
sg application init --config application.yaml
sg application plan --config application.yaml
sg application deploy --config application.yaml
sg application status --config application.yaml
curl http://100.64.0.13:8088/              # node-c's tailnet address: hello

Full walkthrough →

6. Change it, then undo it

Preview a scale to three replicas, then do it. That deploy becomes generation 2. Rolling back redeploys generation 1's spec as generation 3.

sg application scale --config application.yaml web --count 3 \
  --target web-0=node-a --target web-1=node-b --target web-2=node-c --dry-run
sg application scale --config application.yaml web --count 3 \
  --target web-0=node-a --target web-1=node-b --target web-2=node-c
sg application rollback --config application.yaml

Scale, upgrade and roll back →