Machine examples

Each example is a complete machine.yaml that passes sg machine init --config. Fields you leave out take their defaults, so the short ones are just as valid as the long one init writes. Swap in your own address and key paths.

The minimal spec

Four fields. Everything else is a default: Ubuntu 24.04, root SSH, a deploy user, Tailscale with TS_AUTHKEY, the firewall guard, LXD 5.21/stable on tailnet:8444 and a 150GiB ZFS pool.

api_version: genesis/v1
machine:
  name: node-a
  address: 203.0.113.10
  ssh:
    key_path: ~/.ssh/id_ed25519
bootstrap:
  deploy_user:
    key_path: ~/.ssh/id_ed25519.pub

You can even drop bootstrap.deploy_user.key_path: it defaults to the SSH key path plus .pub. Writing it out is clearer, and sg checks it's really a public key before contacting the host.

A small VPS

The ZFS pool is a sparse file on the root disk, and the ARC is ZFS's memory cache. On an 80 GB, 4 GB RAM box, shrink both and make the task-vm profile fit:

api_version: genesis/v1
machine:
  name: tiny-1
  address: 203.0.113.21
  ssh:
    key_path: ~/.ssh/id_ed25519
bootstrap:
  deploy_user:
    key_path: ~/.ssh/id_ed25519.pub
lxd:
  storage:
    pool_file_size: 40GiB
    arc_max: 1GiB
  profiles:
    - name: default
    - name: task-vm
      cpu: 1
      memory: 1GiB

Sizes are written NGiB or NMiB. The pool only ever grows: sg never shrinks or recreates it.

Reach the LXD UI from your tailnet

By default the guard lets nobody reach the LXD API. Open it to every device on your tailnet:

api_version: genesis/v1
machine:
  name: node-a
  address: 203.0.113.10
  ssh:
    key_path: ~/.ssh/id_ed25519
bootstrap:
  deploy_user:
    key_path: ~/.ssh/id_ed25519.pub
  firewall:
    lxd_api_allow_all_tailnet: true

Then browse to https://<node-a's tailnet IP>:8444 from your workstation. You still need an LXD client certificate or trust token to log in; the firewall only decides who can knock.

Only let your workstation in

Tighter than the last one: name individual tailnet IPv4 addresses. No CIDRs, and every entry must be inside 100.64.0.0/10.

api_version: genesis/v1
machine:
  name: node-a
  address: 203.0.113.10
  ssh:
    key_path: ~/.ssh/id_ed25519
bootstrap:
  deploy_user:
    key_path: ~/.ssh/id_ed25519.pub
  firewall:
    lxd_api_allow_from:
      - 100.101.102.103

lxd_api_allow_from and lxd_api_allow_all_tailnet: true can't be used together.

Your own packages, user name and subnet

api_version: genesis/v1
machine:
  name: build-1
  address: 203.0.113.30
  distro: ubuntu-22.04
  ssh:
    key_path: ~/.ssh/id_ed25519
bootstrap:
  packages:
    - fail2ban
    - unattended-upgrades
    - htop
    - jq
  deploy_user:
    name: ops
    key_path: ~/.ssh/ops_ed25519.pub
  tailscale:
    auth_key_env: TS_AUTHKEY_LAB
lxd:
  network:
    subnet: 10.81.0.1/24

Things to know:

  • packages replaces the default list. Keep fail2ban in it: SSH hardening checks its sshd jail.
  • auth_key_env is the name of a variable. Export it before planning: export TS_AUTHKEY_LAB=tskey-auth-.... Handy when different estates join different tailnets.
  • An explicit subnet must avoid 172.16.0.0/12 and 100.64.0.0/10. If it clashes with a bridge already on the host, sg refuses rather than renumbering. Leave it out and sg picks a free one once, before planning.

Three machines for a cluster

A cluster needs three or more machines in the same directory, on the same LXD channel. Write one file each; only the name and address change:

for pair in node-a:203.0.113.11 node-b:203.0.113.12 node-c:203.0.113.13; do
  name="${pair%%:*}"; address="${pair#*:}"
  sg machine init --name "$name" --address "$address" \
    --key-path ~/.ssh/id_ed25519 --deploy-public-key-path ~/.ssh/id_ed25519.pub \
    --distro ubuntu-24.04 --output "$name.yaml"
done

Then register, plan and create each one, and form the cluster.