In GritivaCore, a Scope is defined as a Linux network namespace (netns) combined with a cgroup v2 isolation unit. It is managed by the gritiva-agent on each virtual machine (VM). This document will clarify what a Scope is, why it is used, its capabilities, lifecycle commands, and its relationship with the Gritiva mesh.
A Scope in GritivaCore is not a project, tenant, container, or VM. Instead, it is a lightweight unit that allows multiple independent network stacks to run on a single host. Each VM has one agent that manages multiple Scopes. Each Scope operates within its own netns and cgroup, providing strong isolation and resource management.
Scopes provide several advantages over traditional VMs and containers. VMs require their own kernel and are resource-intensive, while containers share the host network and offer weaker isolation. Scopes deliver container-like density with VM-like isolation, allowing a single host to efficiently run many independent network stacks.
To operate Scopes, the gritiva-agent must have the following capabilities granted via the systemd unit:
CAP_NET_ADMIN
CAP_SYS_ADMIN
These capabilities are set using the AmbientCapabilities= directive and are not setuid.
Scopes are created and destroyed in the panel at https://gritiva.com (INFRA → Scopes → New scope), where you set the CPU and memory limits. The same operations are scriptable over the REST API:
BASH
# list your scopescurl -s https://api.gritiva.com/api/v1/scopes \ -H "X-API-Key: $GRITIVA_API_KEY"# destroy onecurl -s -X DELETE https://api.gritiva.com/api/v1/scopes/$SCOPE_ID \ -H "X-API-Key: $GRITIVA_API_KEY"
POST /api/v1/scopes creates a Scope and POST /api/v1/scopes/{id}/actions drives its lifecycle transitions; API keys are issued under SET. → API keys. A Scope reports a status of creating, starting, running, stopping, stopped, error or migrating, and a health of healthy, unhealthy, degraded or unknown.
To run something inside a Scope, use the panel's built-in terminal, or enter its netns on the VM with sudo ip netns exec my-app docker compose up -d. On the VM, sudo /opt/gritiva/gritiva-agent scope-status prints what the agent believes about every local Scope.
A Scope can join a Gritiva mesh (gmesh) from the panel's MESH section, by attaching the Scope to a mesh network; the control plane then pushes the resulting peer roster to every agent involved. The WireGuard gmesh interface operates within the Scope's netns, allowing secure communication between Scopes. GET /api/v1/mesh/networks and GET /api/v1/mesh/peers/all return the same state for scripts.
It is important to clarify that Scopes are not synonymous with VMs or containers. They are distinct entities designed for specific use cases in network isolation and resource management.
GritivaCore Scopes provide a powerful mechanism for managing network namespaces and resource isolation in a lightweight manner. Understanding their structure and capabilities is essential for effective use in virtualized environments.