Freestyle Docs

Freestyle / Docs

VM Placement

Keep replicas on separate host machines with anti-affinity rules.

Freestyle picks a host machine for every VM. Placement rules let you constrain that choice — most often to keep replicas of the same service off a single machine, so one host failing cannot take all of them down at once.

Spread VMs Across Machines

await freestyle.vms.create({
  metadata: { service: "postgres" },
  placement: {
    antiAffinity: [
      { topology: "node", selector: { matchLabels: { service: "postgres" } } },
    ],
  },
});

Anti-affinity rules keep a VM off any host machine (topology: "node") already running one of your VMs matched by the selector — a VM matches when its metadata contains every matchLabels entry. Give replicas the same metadata and the same rule, as above, and each lands on a different machine.

How Rules Are Enforced

Rules are fixed at creation, only see your own VMs, and are enforced again whenever Freestyle itself relocates a VM. They are hard constraints: creation fails with a 409 when no machine can satisfy every rule.

esc