Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mikronita/mikrom/llms.txt
Use this file to discover all available pages before exploring further.
mikrom-scheduler is the placement engine for the Mikrom platform. It maintains a live registry of available worker nodes, tracks their CPU and RAM capacity as reported by agent heartbeats, and makes binding placement decisions when mikrom-api submits a deployment request. Once a worker is selected, the scheduler instructs the mikrom-agent on that node to create the microVM. The scheduler is intentionally narrow in scope: it owns placement and worker state, not routing, DNS, or certificate management.
Responsibilities
Worker Registry
Tracks all available worker nodes and their current capacity. Workers are registered and refreshed via periodic NATS heartbeats from
mikrom-agent.Placement Decisions
Scores candidate workers based on reported CPU and RAM metrics and selects the best fit for each deployment request.
Agent Coordination
Issues VM creation and cleanup commands to
mikrom-agent on the selected worker node via NATS request-reply.Cluster State
Persists placement history and job lifecycle state in PostgreSQL. Runs background sweeps to clean up stale VMs and deployments.
How Placement Works
Deployment request arrives from mikrom-api
mikrom-api publishes a placement request to NATS. The request includes the workload’s resource requirements (CPU and RAM) and the OCI image reference produced by mikrom-builder.Scheduler evaluates worker capacity
The scheduler queries its in-memory worker registry, filtering out nodes that lack sufficient free CPU or RAM. Remaining candidates are scored by available headroom.
Worker selected
The highest-scoring worker is selected as the placement target. The decision is persisted to PostgreSQL before the command is issued.
Agent instructed to create the microVM
The scheduler sends a NATS request to the
mikrom-agent running on the selected worker node, providing the VM configuration. The agent boots the microVM and returns an acknowledgement.Worker Registry
Workers self-register whenmikrom-agent starts. The scheduler tracks each worker by its MIKROM_HOST_ID and updates capacity estimates from the metrics included in heartbeat messages.
Runtime Configuration
| Variable | Default | Description |
|---|---|---|
DATABASE_URL | required | PostgreSQL connection string for placement state |
NATS_URL | required | NATS server URL |
AGENT_REQUEST_TIMEOUT_SECS | 30 | Timeout for scheduler-to-agent NATS requests |
VM_CLEANUP_INTERVAL_SECS | 3600 | How often the VM cleanup sweep runs |
VM_CLEANUP_TTL_SECS | 3600 | Minimum age before a VM is eligible for cleanup |
BETA_DEPLOYMENT_CLEANUP_ENABLED | false | Enable the beta deployment cleanup sweep (off in production) |
BETA_DEPLOYMENT_CLEANUP_INTERVAL_SECS | 3600 | Interval for the beta deployment cleanup sweep |
Scope Boundaries
The scheduler is responsible for placement only. The following concerns are explicitly out of scope:| Concern | Owned by |
|---|---|
| Ingress routing and TLS | mikrom-router |
| Internal DNS resolution | mikrom-dns |
| WireGuard mesh configuration | mikrom-network |
| OCI image building | mikrom-builder |
| Auth and app lifecycle | mikrom-api |
Stack
- Rust 2024 — service runtime
- Tokio — async executor
- async-nats — NATS request-reply for placement and agent coordination
- SQLx + PostgreSQL — persistent placement state and worker registry snapshots
Dockerfile
The scheduler ships aDockerfile for containerized production deployments:
Local Development
Testing
- Integration tests use an ephemeral
TestDbhelper. They default topostgres://mikrom:mikrom_password@localhost:5432/mikrom_scheduler_testwhenTEST_DATABASE_URLis not set. - The ignored NATS and scheduler end-to-end integration suites are exercised by
make ci-external-tests.