plakar-edge is a small, daemonized executor that runs on a remote network and
executes tasks handed to it by a plakman
control plane. It lets backups, checks, syncs and the like run where the data
lives — inside a customer network, behind NAT — while scheduling, state and
reporting stay centralized in the control plane.
The daemon is intentionally tiny: it speaks HTTP to the control plane and spawns
the existing plaklet binary to do the actual work. It depends only on the Go
standard library and github.com/google/uuid.
plakman control plane remote network
┌────────────────────┐ ┌────────────────────────┐
│ scheduler │ │ plakar-edge │
│ └─ forward task ──┼──(edge polls)──────────┤ 1. POST /edge/enroll │
│ edge API │◄───────────────────────┤ 2. POST /edge/poll │
│ /edge/enroll │ │ 3. spawn plaklet ───┐│
│ /edge/poll │◄──(stream replies)──────┤ 4. POST .../reply ││
│ /edge/{id}/reply │ │ plaklet ◄──┘│
└────────────────────┘ └────────────────────────┘
- Enroll — on first boot the edge names the organization it is joining and
presents that organization's enrollment key, receiving its own bearer token,
which it persists under
-state-dir. - Poll — it long-polls
/edge/pollfor work. All traffic is edge-initiated, so the control plane never needs to reach into the remote network. - Run — for each work item it spawns
plaklet, feeding it the task on stdin. - Report — it streams
plaklet's replies (progress, state, success or failure) back to/edge/{work_id}/reply.
Connector secrets are resolved centrally by the control plane and travel with the work item, so the edge does not need secret-manager plugins.
make # or: go build -o plakar-edge .plakar-edge is a single self-contained binary. It embeds the
plaklet executor (pinned in go.mod)
and runs it as a subcommand — plakar-edge plaklet <args> — so there is no
separate plaklet binary to build or ship. Building the edge builds plaklet.
plakar-edge \
-control-plane https://plakman.example.com \
-organization <organization id from the control plane> \
-enroll <key from the control plane> \
-name edge-paris-1 \
-tags zone:paris-1 \
-state-dir /var/lib/plakar-edge \
-pkg /var/lib/plakar-edge/pkgsTo execute a task the daemon re-execs itself as plakar-edge plaklet …; no
external binary is needed.
The embedded plaklet needs a connector package (s3, sftp, …) for each source and
target it backs up. The edge is assumed to have no network access beyond the
control plane, so when a task names a connector the edge doesn't have, it fetches
that package for its own GOOS/GOARCH through the control plane — plakman
proxies it from the plugin feed. Packages are cached under <pkg>/integrations
and reused, so each is downloaded only once.
After the first successful enrollment the token is stored under -state-dir;
subsequent restarts resume with it and neither -enroll nor -organization is
required. An enrollment key belongs to one organization, but the edge names it
rather than letting the control plane look the key up: that lookup would put
the secret in a query and lose the constant-time comparison. If the
control plane is unreachable at first boot, enrollment retries with backoff until
it succeeds (a rejected enrollment key is fatal). Once enrolled, the poll loop
likewise retries through control-plane outages.
| Flag | Default | Meaning |
|---|---|---|
-control-plane |
(required) | Control plane API base URL |
-enroll |
Enrollment key; required only on first boot. Falls back to PLAKAR_EDGE_ENROLL_KEY |
|
-organization |
Id of the organization to enroll into; required only on first boot. Falls back to PLAKAR_EDGE_ORGANIZATION |
|
-pool-enroll |
Edge pool enrollment key: enroll into that pool, and its organization, instead of using -enroll/-organization. Cannot be combined with either. First boot only. Falls back to PLAKAR_EDGE_POOL_ENROLL_KEY |
|
-name |
hostname | Edge name registered with the control plane |
-state-dir |
/var/lib/plakar-edge |
Where the edge identity/token is persisted |
-pkg |
Plaklet package base dir (<pkg>/integrations, <pkg>/cache) |
|
-poll-hold |
30s |
Expected server-side long-poll hold |
-listen |
127.0.0.1:9877 |
Address for the supervision HTTP server (/health, /ready, /metrics); empty disables it |
-metrics |
true |
Expose node-exporter metrics at /metrics on the -listen address |
-tags |
Comma-separated list of tags self-reported to the control plane on every poll (e.g. env:prod,zone:eu-1), letting it target this edge by tag match. Tags in PLAKAR_EDGE_EXTRA_TAGS are added to these |
|
-scripts-dir |
Directory holding the pre/post-job hook scripts tasks may name. Empty (the default) refuses every hook script |
A task authored on the control plane may name two scripts in its advanced
settings: a pre-job script run before the job starts (quiesce a database,
mount a snapshot) and a post-job script run after it finishes, success or
failure (resume the database). The edge only ever runs scripts from
-scripts-dir: the operator who populates that directory decides what can
run, the task author only picks which by bare file name — paths are refused,
and with no -scripts-dir every hook is refused.
A pre-job script failure fails the work without running the job (or the
post-job script). A post-job script failure fails an otherwise successful job —
a database left frozen is not a success. Scripts receive PLAKAR_WORK_ID,
PLAKAR_OP and PLAKAR_HOOK (pre_job/post_job) in their environment.
Their output lands in the job's output log, next to plaklet's; on failure its
tail is also carried in the failure message.
Tasks that authenticate over SSH with a private key hand it to ssh-add, which
needs an agent. The edge runs its own ssh-agent for its lifetime and passes
its socket to plaklet as SSH_AUTH_SOCK, so ssh, ssh-add and ssh-agent
(OpenSSH client) must be installed on the edge host. Without ssh-agent the
edge still starts, logs a warning, and only those tasks fail.
The edge runs a small HTTP server on -listen for supervision and monitoring.
It binds to loopback by default; set -listen to 0.0.0.0:9877 (or empty to
disable) as your deployment requires.
| Endpoint | Purpose |
|---|---|
/health |
Liveness — 200 as long as the process is serving. Fail → restart the daemon. |
/ready |
Readiness — 200 only once the edge is enrolled and polling, 503 otherwise. Gates whether the edge is expected to pick up work. |
/metrics |
Node exporter — host metrics (CPU, memory, filesystem, network, load, …) via the upstream node_exporter collectors, plus the standard Go runtime/process collectors. Scrape it with Prometheus. |
/health and /ready return a small JSON body:
{ "status": "ok", "version": "v1.0.0", "uptime_seconds": 42.7 }A typical systemd/process supervisor uses /health to decide whether to
restart the unit; a Prometheus deployment scrapes /metrics; and an
orchestrator that fans work out to edges can consult /ready.
Note: the node-exporter collectors are the upstream ones. Most are richest on Linux; on other platforms unsupported collectors simply report a per-collector
node_scrape_collector_success 0and are skipped, without failing the scrape.
protocol.go holds the JSON contracts the edge exchanges with the control
plane and with plaklet. These are duplicated from plakman on purpose, to
keep this repository free of any plakman-internal dependency; the file documents
the plakman source of truth to keep in sync with.
The edge sends EdgeProtocolVersion (an integer) at enrollment. It is bumped
only when the wire structs (WorkItem / Reply / Configuration / the plaklet
ExecPayload/ExecReply) change, so the edge and the control plane can release
independently. The control plane records it; if it does not support that
version, the edge still enrolls (so it stays visible) but is not dispatched
work until upgraded — the enroll response's supported flag signals this, and
the daemon logs a warning. A separate edge_version build string is reported
for observability only and is not used for gating.