Tutorials & Examples
This page contains step-by-step tutorials to help you get hands-on with Nexus GSLB.
Tutorial 1: Single-node quickstart Goal: run one gslbd instance locally and answer A/AAAA queries.
- Follow Getting Started to build and run with a minimal config.
- Verify health checks and DNS answers using
dig. - Explore Prometheus metrics at
http://localhost:9090/metrics.
Tutorial 2: Two nodes with state sync Goal: run two gslbd instances that share health via NATS. Prereqs: a NATS server with JetStream (can be a single node for a lab). Steps:
- Configure NATS (see StateSyncSetup.md) and obtain client TLS materials if using TLS.
- Prepare two configs with unique
node.id, samecluster.id, and the samestate.natssettings. - Start both nodes (different hosts or different containers/ports on one host).
- Observe
gslbd_state_active_memberson both; it should be 2. - Simulate a backend failure and watch quorum behavior depending on
state.healthPolicy.
Tutorial 3: Weighted Round-Robin with per-endpoint weights Goal: steer more traffic to a stronger backend using weights. Steps:
- Start from the Getting Started config and change the load balancer to WRR:
loadbalancer:
algorithm: "weighted-round-robin"
endpoints:
- 203.0.113.10
- 203.0.113.11
- 2001:db8::10
weights:
"203.0.113.10": 5
"203.0.113.11": 1
"2001:db8::10": 3
- Restart
gslbdand issue multipledigqueries; you should observe a higher share of answers for the higher-weight IPs. - Set a weight to
0to temporarily drain a backend without removing it.
Tutorial 4: Declarative configuration with GitOps Goal: distribute configuration to your nodes from a Git repository.
NATS JetStream config sync has been removed. Configuration is now distributed via GitOps self-restart: each node independently polls a Git repo, validates the config, writes it to its own config file, and gracefully restarts onto it. Data-plane objects (pools/members/services) are replicated by the rqlite datastore, not NATS. See the GitOps User Guide for the full walkthrough.
Tutorial 5: GitOps rollout Goal: manage configuration changes via a signed Git repo. Steps:
- Set up a Git repo with
clusters/<cluster>/gslbd.yaml(see GitOpsUserGuide.md). - Enable GitOps in
/etc/gslb/config.yamlwithrequireSignature: trueandallowedSigners. - Make a change (add/remove an endpoint), sign the commit, and push.
- Wait for the poll interval or restart
gslbdto reconcile immediately. - Verify changes were applied (DNS answers, health gauges) and check metrics
gslbd_gitops_last_apply_info{sha,signer}.
Tutorial 6: Secure HTTPS health checks Goal: enforce TLS verification for HTTP health checks. Steps:
- Configure backend with a valid certificate (public or internal CA) and known hostname.
- Set
health.http.tls: true,insecureSkipVerify: false, andhttp.hostto the certificate hostname. - Verify health becomes healthy; if not, use
curl -vk https://<ip>:<port>/healthz -H 'Host: your.host'to debug.
Tutorial 7: Real-user measurement (RUM) routing Goal: answer DNS queries with the member that is fastest for the actual user, measured from browsers. Prereqs: pro license; a small always-on URL on each member (e.g. a 204 handler). Steps:
- Set a
rumUrlon each member:gslbctl members update <id> --name web-01 --rum-url https://web-01.example.com/__rum. - Embed the beacon on your site:
<script src="https://<nexus-host>/rum.js" data-domain="app.example.com" async></script>. - Add the
rumstep to the service filter chain (e.g.["geo-ip", "rum"]). - Watch coverage grow with
gslbctl rum status; inspect per-query decisions withgslbctl trace <service-id> --client-ip <ip>. Full walkthrough (including a 10-minute lab with simulated measurements): RUMRouting.md.
Appendix: Example docker-compose for lab
version: "3"
services:
nats:
image: nats:2
command: ["-js", "-m", "8222"]
ports: ["4222:4222", "8222:8222"]
gslbd1:
image: registry.starstorm.dev/nexus-gslb/gslbd:local
depends_on: [nats]
volumes:
- ./config1.yaml:/etc/gslb/config.yaml:ro
ports:
- "5353:5353/udp"
- "9090:9090"
gslbd2:
image: registry.starstorm.dev/nexus-gslb/gslbd:local
depends_on: [nats]
volumes:
- ./config2.yaml:/etc/gslb/config.yaml:ro
ports:
- "5354:5353/udp"
- "9091:9090"