SparkD is a cell engine for databases. Run it on your laptop, home server, or VPS, then create isolated PostgreSQL cells over a normal TCP API.
PostgreSQL support is first. SparkD imports PostgreSQL into the base rootfs once, then clones that imported base for each cell.
- TCP HTTP API on port
8721by default /create,/list,/pause,/resume,/monitor,/delete,/health- JSON responses for every daemon endpoint
- PostgreSQL credentials and connection strings from
/create - Per-cell rootfs, PID/network namespace, IP, and forwarded host port
- JSON metadata in
/var/lib/sparkd/cells.json - RAM/CPU enforcement with cgroup v2
- Disk enforcement with a quota-sized ext4 rootfs image per cell
go build -o sparkd .SparkD needs root for chroot, namespaces, veth devices, bridge setup, cgroups, loop-mounted rootfs images, and iptables.
Build on a VPS:
ssh user@server-ip
git clone https://github.com/shellhaki/sparkd.git
cd sparkd
go build -o sparkd .
sudo ./sparkd daemonOne-command systemd install on a VPS:
curl -fsSL https://raw.githubusercontent.com/shellhaki/sparkd/main/scripts/install-systemd.sh | sudo shThe installer clones https://github.com/shellhaki/sparkd.git, builds SparkD, starts sparkd.service, and prints the useful systemctl and journalctl commands.
sudo ./sparkd daemonDefault server:
0.0.0.0:8721
Use a different address or port if 8721 is busy:
sudo SPARKD_ADDR=0.0.0.0:8877 ./sparkd daemonSet SPARKD_HOST if returned database connection strings should use a specific public IP or DNS name:
sudo SPARKD_HOST=db.example.com ./sparkd daemonOpen the daemon port on your VPS firewall/security group. For quick local-only testing, run with SPARKD_ADDR=127.0.0.1:8721.
Use the installer:
sudo sh scripts/install-systemd.shExample unit:
[Unit]
Description=SparkD database cell daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/sparkd daemon
Environment=SPARKD_ADDR=0.0.0.0:8721
Environment=SPARKD_HOST=server-ip-or-dns
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.targetInstall:
sudo cp sparkd /usr/local/bin/sparkd
sudo cp sparkd.service /etc/systemd/system/sparkd.service
sudo systemctl daemon-reload
sudo systemctl enable --now sparkdBase URL:
http://server-ip:8721
Health:
curl http://127.0.0.1:8721/healthCreate a Postgres cell:
curl -X POST http://127.0.0.1:8721/create \
-H 'content-type: application/json' \
-d '{"name":"app-db","dbtype":"pg","port":3001,"ram":"128mb","disk":"512mb"}'Response includes cell metadata, progress events, credentials, and the connection string:
{
"connection_string": "postgres://postgres:...@server-ip:3001/app_db?sslmode=disable"
}List cells:
curl http://127.0.0.1:8721/listMonitor one cell:
curl 'http://127.0.0.1:8721/monitor?name=app-db'Pause one cell:
curl -X POST http://127.0.0.1:8721/pause \
-H 'content-type: application/json' \
-d '{"name":"app-db"}'Resume one cell:
curl -X POST http://127.0.0.1:8721/resume \
-H 'content-type: application/json' \
-d '{"name":"app-db"}'Delete one cell:
curl -X POST http://127.0.0.1:8721/delete \
-H 'content-type: application/json' \
-d '{"name":"app-db"}'The daemon imports automatically on first /create, but you can warm it manually:
sudo ./sparkd importsudo ./main daemon
./manual-tests/create-pg.sh
./manual-tests/list.sh
./manual-tests/delete-pg.shFor a remote daemon:
SPARKD_URL=http://server-ip:8721 ./manual-tests/list.shClient examples live in examples:
Defaults:
- State directory:
/var/lib/sparkd - Base rootfs:
/var/lib/sparkd/base/rootfs - Cell directory:
/var/lib/sparkd/cells - Metadata store:
/var/lib/sparkd/cells.json
Override state for local experiments:
sudo SPARKD_STATE_DIR=/tmp/sparkd-state SPARKD_ADDR=127.0.0.1:8721 ./sparkd daemon