Development Setup
Nantian Gateway’s control plane is written in Go, the data plane in Rust, and the admin console in Next.js. This page walks you through setting up a local development environment from scratch, covering build, run, and debug workflows.
Prerequisites
Section titled “Prerequisites”Required Tools
Section titled “Required Tools”| Tool | Version | Purpose |
|---|---|---|
| Go | ≥ 1.26 | Control plane compilation |
| Rust | ≥ 1.85 | Data plane compilation |
| Docker | ≥ 24.0 | Local cluster and containerized execution |
| kubectl | ≥ 1.28 | Kubernetes cluster operations |
| Helm | ≥ 3.12 | Chart packaging and deployment |
| protoc | ≥ 3.21 | Protobuf compilation |
| Node.js | ≥ 18 | Admin console and documentation site |
Recommended Tools
Section titled “Recommended Tools”| Tool | Purpose |
|---|---|
| Kind | Local Kubernetes cluster |
| just | Command runner (useful for CI and task automation) |
| golangci-lint | Go code linting |
| cargo-watch | Rust hot-reload development |
Quick Environment Verification
Section titled “Quick Environment Verification”# Verify Gogo version# Expected: go version go1.26.x ...
# Verify Rustrustc --version# Expected: rustc 1.88.x ...
# Verify Dockerdocker version
# Verify kubectlkubectl version --client
# Verify Helmhelm version
# Verify protocprotoc --version
# Verify Node.jsnode --versionClone the Repository
Section titled “Clone the Repository”# Fork the main repo, then clone your forkgit clone https://github.com/<your-username>/gateway.gitcd gateway
# Add the main repo as upstreamgit remote add upstream https://github.com/nantian-gw/gateway.gitSet Up a Local Kubernetes Cluster
Section titled “Set Up a Local Kubernetes Cluster”For development, we recommend using Kind to create a local cluster:
# Create a Kind clusterkind create cluster --name nantian-dev
# Verify cluster statuskubectl cluster-infokubectl get nodesInstall Gateway API CRDs
Section titled “Install Gateway API CRDs”# Install Gateway API v1.5.1 CRDskubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yamlBuild and Run the Control Plane
Section titled “Build and Run the Control Plane”The control plane is written in Go, with its entry point at gateway/cmd/manager/main.go.
# Enter the control plane directorycd gateway
# Install dependenciesgo mod download
# Build the control planego build -o bin/manager ./cmd/manager
# Run the control plane locally (install Nantian Gateway CRDs first)kubectl apply -f deploy/crds/./bin/manager \ --metrics-bind-address=:8080 \ --health-probe-bind-address=:8081 \ --xds-bind-address=:9090 \ --leader-elect=falseControl Plane CLI Flags
Section titled “Control Plane CLI Flags”| Flag | Default | Description |
|---|---|---|
--metrics-bind-address | :8080 | Prometheus metrics port |
--health-probe-bind-address | :8081 | Health check and admin API port |
--xds-bind-address | :9090 | gRPC xDS server port |
--leader-elect | true | Enable leader election |
--leader-elect-namespace | Current namespace | Namespace for leader election |
--gateway-class-name | nantian-gw | GatewayClass name to claim |
Build and Run the Data Plane
Section titled “Build and Run the Data Plane”The data plane is written in Rust, located in the dataplane/ directory.
# Enter the data plane directorycd dataplane
# Build the data plane (debug mode)cargo build
# Build the data plane (release mode, optimized)cargo build --release
# Run the data planecargo run -- \ --node-id dataplane-dev-0 \ --controlplane-addr http://localhost:9090 \ --cluster kind \ --admin-bind-address 0.0.0.0:8082 \ --metrics-bind-address 0.0.0.0:9091Data Plane CLI Flags
Section titled “Data Plane CLI Flags”| Flag | Default | Description |
|---|---|---|
--node-id | Auto-generated | Node identifier |
--controlplane-addr | http://localhost:9090 | Control plane gRPC address |
--cluster | kind | Cluster name |
--admin-bind-address | 0.0.0.0:8082 | Admin API address |
--metrics-bind-address | 0.0.0.0:9091 | Prometheus metrics port |
Compile Protobuf
Section titled “Compile Protobuf”After modifying .proto files in the proto/ directory, regenerate the Go and Rust code:
# Generate Go codecd protobuf generate
# Generate Rust code (from the dataplane directory)cd ../dataplane# Code generation is integrated into the dataplane's build.rscargo buildRun the Admin Console
Section titled “Run the Admin Console”The admin console is a Next.js web application:
cd dashboard
# Install dependenciesnpm install
# Run in development modenpm run dev
# Open http://localhost:3000 in your browserRun the Documentation Site
Section titled “Run the Documentation Site”The documentation site uses Astro + Starlight:
cd website
# Install dependenciesnpm install
# Run in development modenpm run dev
# Open http://localhost:4321 in your browserOne-Click Startup with Docker Compose
Section titled “One-Click Startup with Docker Compose”The project provides a docker-compose.yml for quickly launching a complete development environment:
docker compose up -dThis starts:
- A control plane instance
- A data plane instance
- The admin console
Debugging Tips
Section titled “Debugging Tips”Go Control Plane Debugging
Section titled “Go Control Plane Debugging”Use Delve to debug Go code:
# Install Delvego install github.com/go-delve/delve/cmd/dlv@latest
# Run the control plane in debug modedlv debug ./cmd/manager -- \ --leader-elect=false \ --xds-bind-address=:9090VS Code users can install the Go extension and configure debug targets in .vscode/launch.json.
Rust Data Plane Debugging
Section titled “Rust Data Plane Debugging”The Rust data plane supports the RUST_LOG environment variable to control log levels:
# Enable verbose loggingRUST_LOG=debug cargo run -- --node-id dataplane-dev-0
# View logs for a specific module onlyRUST_LOG=nantian_dataplane::proxy=trace cargo run -- --node-id dataplane-dev-0Common log levels: error, warn, info, debug, trace.
Inspecting xDS Communication
Section titled “Inspecting xDS Communication”During development, you can inspect the xDS communication between the control plane and data plane to verify that configuration is being transmitted correctly:
# View xDS client status from the control plane Admin APIcurl http://localhost:8081/api/v1/clients | jq
# View xDS connection status from the data plane Admin APIcurl http://localhost:8082/api/v1/xds/status | jqNext Steps
Section titled “Next Steps”- See Testing Guide to learn how to run tests
- See Architecture Overview to understand the system design
- See Contributing Overview to understand the contribution workflow