Compose
Compose stack
Describe a database and three load-balanced web VMs in one YAML file, then deploy the whole thing with one command.
The stack
One file defines a VXLAN network, a database VM, and three web VMs behind a virtual IP. The web VMs wait for the database to report healthy, spread across hosts, and never share a host with it.
name: "web-app"
networks:
frontend:
type: "vxlan"
vni: 1000
subnet: "10.0.100.0/24"
host-isolation: true
vms:
base-vm:
image: "ubuntu"
cpu: 2
memory: "4G"
replicas: 0 # a template other VMs extend
db:
extends: "base-vm"
cpu: 4
memory: "8G"
disks:
root: "20G"
data:
size: "100G"
network:
- name: "frontend"
placement:
anti-affinity: ["web"]
restart:
condition: "on-failure"
web:
extends: "base-vm"
replicas: 3
network:
- name: "frontend"
placement:
anti-affinity: ["db"]
spread: true
max-per-node: 1
depends-on:
db:
condition: vm_healthy
loadbalancer:
vip: "10.0.100.50/24"
ports:
- listen: 80
target: 80
healthcheck:
type: "http"
target: "http://localhost:80/"
interval: "10s"
retries: 3
action: "restart"
Deploy and manage
lv compose up # deploy litevirt-compose.yaml
lv compose up -f mystack.yaml # deploy a specific file
lv compose diff # preview what would change
lv compose ps # list the stack's VMs
lv compose down # tear the stack down
After editing the file, lv compose diff shows what would change and lv compose up applies it. The Compose guide
covers every key, including update strategy, backups, and PCI devices.