How abshkbh/arrakis works
Project Type & Purpose
• This is a full-stack system focused on virtualization security and sandbox management.
• The primary functionalities include spawning/stopping VMs, managing network and port forwarding, and snapshot/restore capabilities.
• External interfaces include a REST API (exposed by the “arrakis-restserver”), a CLI client (under cmd/client and related subcommands), and a Python SDK (py-arrakis) for programmatic access.
• Additional support is extended for MCP-based clients, which use the MCP server integration.
File Structure
• The top-level directories like “cmd”, “pkg”, “api”, “initramfs”, “resources”, and “setup” indicate a split between command-line tools, backend logic, microVM orchestration and VM initialization scripts.
• The “cmd” directory houses multiple executables (restserver, client, guestinit, vsockclient/server, etc.), evidencing separate entry points that manage various aspects of the VM lifecycle.
• The “pkg” directory includes modular internal components such as “server” functionality with submodules for CID/IP/port allocation, which help build the overall orchestration engine.
• The “api” folder holds API definitions (YAML files) that document the REST interface, reinforcing the centrality of the REST API to the design.
• The “initramfs” and “resources” folders detail scripts and Dockerfiles for customizing the guest VM’s root filesystem and boot process, thus emphasizing customization and security via containerization.
Review of README Insights
• The README elaborates on core features including running each sandbox in a MicroVM powered by cloud-hypervisor, container-based rootfs customization, and secure port forwarding for VNC/GUI access.
a. Main Components:
• External Clients: CLI client, Python SDK (py-arrakis), MCP clients.
• REST API Server: The “arrakis-restserver” that exposes endpoints for starting/stopping, listing, snapshotting, and restoring VMs.
• VM Manager Core: Internal services (grouped under pkg/server and pkg/cmdserver) responsible for:
– VM lifecycle management (creation, destruction, snapshot/restore)
– Resource allocation (IP, port, and CID allocation modules)
• Virtualization Layer: Cloud-hypervisor integration handling the actual MicroVM instantiation.
• Guest VMs/Sandboxes: Each VM runs its own Ubuntu OS with pre-installed code execution services, VNC server, and snapshot/restore capability.
• Networking and Port Forwarding: Components managing Linux tap devices, bridges, and port forwarding to expose guest services (e.g., VNC ports).
• Customization/Initialization: Scripts and configuration (Dockerfile, initramfs scripts) for building and initializing the guest VM environment.
b. Relationships & Interactions:
• External clients interact with the REST API server (using HTTP calls) to send commands such as “start sandbox”, “list VMs”, “snapshot”, “restore”, etc.
• The REST API server translates these calls into actions processed by the internal VM Manager Core, which in turn interacts with lower-level modules (IP/port allocators, command servers).
• The VM Manager makes calls to the virtualization layer (cloud-hypervisor) to actually spin up a MicroVM and configure its resources.
• Networking modules handle tasks like configuring tap devices and managing port forwarding (for example, forwarding a host port to a guest VNC server).
• The CLI client and Python SDK serve as thin layers on top of the REST API, providing user-friendly credentials.
c. Architectural Patterns:
• Layered (or tiered) design: Separation of external interfaces (API/CLI/SDK) from internal management logic (VM Manager, resource allocators) and the low-level virtualization layer.
• Modular design: Each subcomponent (like IP allocator, port allocator, snapshot/restore service) is decoupled for ease of customization and potential reuse.
• Security by isolation: Every sandbox is run in its own secure MicroVM ensuring that untrusted code execution is safely contained.
d. Relevant Technologies:
• Golang for the REST API server and CLI commands.
• cloud-hypervisor as the backend Virtual Machine Manager.
• Docker (via provided Dockerfile in resources/scripts/rootfs) and initramfs scripts for constructing the guest environment.
• Linux networking (tap devices, bridges) and overlayfs for filesystem isolation.
• Python (through the py-arrakis SDK) as an important client-side technology.