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 --config configs/controlplane/config.yamlThe manager binary takes a single flag, --config (path to the YAML config file). All runtime behavior — listen addresses, leader election, and the claimed GatewayClass — is set in that file, not through CLI flags.
Key Control Plane Config Fields
Section titled “Key Control Plane Config Fields”| Config field | Default | Description |
|---|---|---|
grpcAddr | :18080 | gRPC xDS server address |
adminAddr | :18081 | Admin API / HTTP address |
metricsAddr | :18082 | Prometheus metrics address |
healthProbeAddr | :18083 | Health and readiness probe address |
See the Control Plane Configuration reference for the full schema, including leader election and the GatewayClass name.
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 -p ntgw-app -- --config configs/dataplane/config.yamlThe ntgw-app binary also takes a single --config flag. The node identifier, control plane address, and admin/proxy listen addresses all come from the config file. The node ID can additionally be injected via the NANTIAN_GW_NODE_ID environment variable, which the Helm chart sets from the Pod name.
Key Data Plane Config Fields
Section titled “Key Data Plane Config Fields”| Config field | Default | Description |
|---|---|---|
nodeId | dp-local | Node identifier |
xds.serverAddress | http://127.0.0.1:18080 | Control plane gRPC address |
runtime.adminAddress | 0.0.0.0:19080 | Admin API and metrics address |
runtime.listenAddress | 0.0.0.0:8080 | HTTP proxy listen address |
See the Data Plane Configuration reference for the full schema.
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 -- --config configs/controlplane/config.yamlVS 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 -p ntgw-app -- --config configs/dataplane/config.yaml
# View logs for a specific module onlyRUST_LOG=ntgw_http=trace cargo run -p ntgw-app -- --config configs/dataplane/config.yamlCommon 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 connected data plane nodes from the control plane Admin APIcurl http://localhost:18081/v1/nodes | jq
# View node state (including xDS stream status) from the data plane Admin APIcurl http://localhost:19080/v1/node | 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