Lux Docs
Lux Skills Reference

Lux Operator - Kubernetes Operator for Lux Network

Documentation for Lux Operator - Kubernetes Operator for Lux Network

Overview

Lux Operator is a Kubernetes operator written in Rust that manages Lux Network deployments on K8s. It handles 6 custom resource types: LuxNetwork, LuxChain, LuxIndexer, LuxExplorer, LuxGateway, and LuxMPC. Each CRD has a dedicated reconciliation controller.

Quick reference

ItemValue
Repogithub.com/luxfi/operator
Branchmain
Cratelux-operator v0.3.12
LanguageRust (edition 2021)
Binarylux-operator
Imageghcr.io/luxfi/operator:v0.3.12
Namespacelux-system
Health port8081 (/healthz, /readyz)
Metrics port8080 (/metrics)
K8s API grouplux.network/v1alpha1
LicenseBSD-3-Clause

Architecture

lux-operator
├── src/
│   ├── main.rs         # CLI args, health/metrics servers, controller dispatch
│   ├── crd.rs          # Custom Resource Definitions (6 CRDs)
│   ├── controller.rs   # Reconciliation controllers (6 controllers)
│   └── error.rs        # Error types
├── k8s/
│   ├── crds/           # CRD YAML manifests
│   ├── rbac/           # RBAC (ServiceAccount, ClusterRole, etc.)
│   ├── networks/       # Network configuration manifests
│   ├── mpc/            # MPC service manifests
│   ├── deployment.yaml # Operator deployment
│   ├── service.yaml    # Operator service
│   ├── namespace.yaml  # lux-system namespace
│   ├── kms-secrets.yaml # KMS secret sync
│   ├── deploy.sh       # Deployment script
│   ├── deploy-subgraphs.sh # Subgraph deployment
│   ├── indexers-*.yaml # Indexer configs (mainnet/testnet/devnet)
│   ├── explorer-*.yaml # Explorer configs (mainnet/testnet/devnet)
│   └── gateway-*.yaml  # Gateway configs (mainnet/testnet/devnet)
└── Dockerfile          # Multi-stage Rust build (rust:1.88 → debian:bookworm-slim)

Custom Resource Definitions

CRDKindShortnamePurpose
luxnetwork-crd.yamlLuxNetworkluxnetDeploy validator network clusters
luxchain-crd.yamlLuxChain-Manage individual chain instances
luxindexer-crd.yamlLuxIndexer-Deploy blockchain indexers
luxexplorer-crd.yamlLuxExplorer-Deploy block explorers
luxgateway-crd.yamlLuxGateway-Deploy API gateways
luxmpc-crd.yamlLuxMPC-Deploy MPC key management nodes

LuxNetwork CRD (Primary)

apiVersion: lux.network/v1alpha1
kind: LuxNetwork
metadata:
  name: mainnet
spec:
  networkId: 1        # 1=mainnet, 2=testnet, 3=devnet
  validators: 15      # Number of validator nodes
  image:
    repository: ghcr.io/luxfi/node
    tag: latest
  resources:
    requests:
      cpu: "4"
      memory: "8Gi"
    limits:
      cpu: "8"
      memory: "16Gi"

Status fields: phase, readyValidators, totalValidators.

Controllers

6 reconciliation controllers run concurrently via tokio::select!:

ControllerFunctionManages
run_network_controllerValidator clustersStatefulSets, Services, ConfigMaps
run_chain_controllerChain instancesChain-specific deployments
run_indexer_controllerBlockchain indexersIndexer pods per network
run_explorer_controllerBlock explorersBlockscout deployments
run_gateway_controllerAPI gatewaysGateway routing
run_mpc_controllerMPC nodesKey management pods

Key Dependencies

kube = "0.87"          # Kubernetes client (runtime, derive, ws)
k8s-openapi = "0.20"   # K8s API types (v1.28)
tokio = "1.35"          # Async runtime
axum = "0.7"            # HTTP server (health + metrics)
clap = "4.4"            # CLI argument parsing
tracing = "0.1"         # Structured logging
reqwest = "0.11"        # HTTP client (rustls-tls)
schemars = "0.8"        # JSON Schema generation for CRDs

CLI Arguments

lux-operator \
  --namespace ""          # Watch namespace (empty = all)
  --log-level info        # trace|debug|info|warn|error
  --metrics-port 8080     # Prometheus metrics endpoint
  --health-port 8081      # Health check endpoint
  --leader-election       # Enable leader election
  --mpc-endpoint URL      # Optional MPC service endpoint

Deployment

# Apply CRDs
kubectl apply -f k8s/crds/

# Apply RBAC
kubectl apply -f k8s/rbac/

# Deploy operator
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml

K8s deployment spec: 1 replica, 100m-1 CPU, 128Mi-512Mi memory, liveness/readiness probes on :8081/healthz.

Build

# Local
cargo build --release

# Docker
docker build --platform linux/amd64 -t ghcr.io/luxfi/operator:v0.3.12 .

Environment Manifests

Pre-configured manifests for mainnet/testnet/devnet:

  • k8s/indexers-\{mainnet,testnet,devnet\}.yaml
  • k8s/explorer-\{mainnet,testnet,devnet\}.yaml
  • k8s/gateway-\{mainnet,testnet,devnet\}.yaml
  • k8s/exchange-backend-mainnet.yaml
  • k8s/explorer-microservices-mainnet.yaml
  • lux/lux-node.md -- Node binary managed by operator
  • lux/lux-deploy.md -- Network automation and DevOps
  • lux/lux-universe.md -- Production K8s infrastructure
  • lux/lux-monitoring.md -- Prometheus/Grafana for operator metrics

On this page