This guide covers the declarative YAML-based approach to managing devnets.
Devnet Builder supports Kubernetes-style YAML resource definitions for declarative devnet management. This allows you to:
- Define devnet configurations as code
- Version control your devnet setups
- Apply configurations idempotently
- Preview changes before applying
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: my-devnet
namespace: default # Optional: namespace for isolation (default: "default")
labels:
team: core
environment: development
spec:
network: stable
validators: 4
mode: dockerapiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: my-devnet
namespace: default # Optional: namespace for isolation (default: "default")
labels:
team: core
environment: development
annotations:
description: "Development network for testing"
spec:
# Network configuration (required)
network: stable # Required: network plugin (stable, osmosis, geth, etc.)
# Network options (optional)
networkType: mainnet # Optional: mainnet, testnet (default: mainnet)
networkVersion: v1.0.0 # Optional: specific SDK/binary version
# Node configuration
validators: 4 # Number of validator nodes (min: 1, default: 1)
fullNodes: 0 # Number of full nodes (default: 0)
accounts: 10 # Number of accounts to create (default: 0)
# Execution mode
mode: docker # docker or local (default: docker)
# Resource limits (optional, Docker mode only)
resources:
cpu: "2"
memory: "4Gi"
storage: "10Gi"
# Per-node overrides (optional)
nodes:
- index: 0
role: validator
resources:
cpu: "4"
memory: "8Gi"
# Daemon configuration (optional)
daemon:
autoStart: true
idleTimeout: "30m"
logs:
bufferSize: "10000"
retention: "24h"Apply a devnet configuration from a YAML file.
# Apply configuration
devnet-builder apply -f devnet.yaml
# Preview changes without applying (dry-run)
devnet-builder apply -f devnet.yaml --dry-run
# Force recreation (destroy + create)
devnet-builder apply -f devnet.yaml --force
# Apply all YAML files in a directory
devnet-builder apply -f ./devnets/
# Output as JSON
devnet-builder apply -f devnet.yaml --dry-run -o jsonFlags:
-f, --file: Path to YAML file or directory (required)--dry-run: Preview changes without applying--force: Force recreation of existing devnet-o, --output: Output format (text, json)
# devnet.yaml
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: test-devnet
spec:
network: stable
validators: 4
mode: dockerdevnet-builder apply -f devnet.yaml# devnets/dev.yaml
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: dev-network
labels:
environment: development
spec:
network: stable
validators: 2
mode: docker
---
# devnets/staging.yaml
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: staging-network
labels:
environment: staging
spec:
network: stable
validators: 4
mode: docker
resources:
cpu: "4"
memory: "8Gi"# Apply all environments
devnet-builder apply -f ./devnets/apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: prod-like
namespace: staging
labels:
team: infra
environment: staging
annotations:
description: "Production-like environment for integration testing"
spec:
network: stable
networkType: mainnet
networkVersion: v1.2.0
validators: 4 # Max 4 validators supported
fullNodes: 3
accounts: 100
mode: docker
resources:
cpu: "4"
memory: "8Gi"
storage: "50Gi"
nodes:
- index: 0
role: validator
resources:
cpu: "8"
memory: "16Gi"
daemon:
autoStart: true
idleTimeout: "1h"
logs:
bufferSize: "50000"
retention: "72h"You can define multiple devnets in a single file using YAML document separators:
# multi-devnet.yaml
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: network-a
spec:
network: stable
validators: 2
---
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: network-b
spec:
network: stable
validators: 4Create a YAML file defining your devnet:
cat > devnet.yaml << 'EOF'
apiVersion: devnet.lagos/v1
kind: Devnet
metadata:
name: my-devnet
spec:
network: stable
validators: 4
mode: docker
EOFUse dry-run to see what will be created:
devnet-builder apply -f devnet.yaml --dry-runOutput:
Devnet: my-devnet (dry-run)
Plan: 1 to create, 0 to update, 0 to destroy
+ devnet/my-devnet
network: stable
networkVersion:
mode: docker
validators: 4
+ node/my-devnet-0 (validator)
+ node/my-devnet-1 (validator)
+ node/my-devnet-2 (validator)
+ node/my-devnet-3 (validator)
Run without --dry-run to apply.
Apply the configuration:
devnet-builder apply -f devnet.yamlApply the updated configuration:
devnet-builder apply -f devnet.yamlThe YAML loader validates configurations and reports errors:
$ devnet-builder apply -f invalid.yaml
Error: validation failed:
- metadata.name is required
- spec.network is required
- spec.validators must be at least 1
- spec.mode must be 'docker' or 'local'
- spec.networkType must be 'mainnet' or 'testnet'| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string | Yes | - | Unique name for the devnet |
namespace |
string | No | default |
Namespace for resource isolation |
labels |
map[string]string | No | - | Key-value pairs for organization |
annotations |
map[string]string | No | - | Arbitrary metadata |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
network |
string | Yes | - | Network plugin name (stable, osmosis, geth, etc.) |
networkType |
string | No | mainnet |
Network source: mainnet or testnet |
networkVersion |
string | No | (plugin default) | Specific SDK/binary version |
mode |
string | No | docker |
Execution mode: docker or local |
validators |
int | No | 1 |
Number of validator nodes (min: 1) |
fullNodes |
int | No | 0 |
Number of full nodes |
accounts |
int | No | 0 |
Number of funded accounts to create |
| Field | Type | Description |
|---|---|---|
cpu |
string | CPU limit (e.g., "2", "4") |
memory |
string | Memory limit (e.g., "4Gi", "8Gi") |
storage |
string | Storage limit (e.g., "10Gi") |
| Field | Type | Description |
|---|---|---|
index |
int | Node index (0-based) |
role |
string | Node role: validator or fullnode |
resources |
Resources | Per-node resource overrides |
| Field | Type | Description |
|---|---|---|
autoStart |
bool | Auto-start nodes on daemon launch |
idleTimeout |
string | Idle timeout duration (e.g., "30m") |
logs.bufferSize |
string | Log buffer size |
logs.retention |
string | Log retention period (e.g., "24h") |
- Version Control: Store YAML files in git alongside your application code
- Use Labels: Add labels for filtering and organization
- Dry Run First: Always preview changes with
--dry-runbefore applying - Environment Separation: Use separate files or directories for different environments
- Resource Limits: Specify resource limits for production-like environments
- Namespaces: Use namespaces to isolate devnets for different projects or teams