Load Balancers
Nstance supports automatic registration/de-registration of instances with cloud provider load balancers.
Configuration
Load balancers are defined in the load_balancers configuration section. Each entry is a logical registration target with an AWS NLB, Google Cloud NLB, or provider-neutral tunnel shape.
{
"load_balancers": {
"www": {
"provider": "aws",
"target_groups": [{
"arn": "arn:aws:elasticloadbalancing:region:account:targetgroup/www-443/456",
"listener_port": 443,
"target_port": 443,
"proxy_port": 8443
}]
},
"internal": {
"provider": "google",
"network_endpoint_groups": ["internal-us-central1-a"],
"frontends": [{"ip": "34.10.20.30", "port": 443}]
}
},
"groups": {
"web-servers": {
"template": "web",
"size": 3,
"load_balancers": ["www"]
},
"api-servers": {
"template": "api",
"size": 2,
"load_balancers": ["www", "internal"]
}
}
}Provider-Specific Fields:
- AWS:
target_groups(required) - Entries containarn,listener_port,target_port, andproxy_port. Current registration derives and registers the ARN list. - Google Cloud:
network_endpoint_groupsandfrontends(required) - NEG names plus forwarding-ruleipandportmetadata. - Tunnel:
listeners(required) - Entries containtarget_portandproxy_port; no infrastructure provider registration API is called.
For example, a Kubernetes deployment may define an ingress registration target for ports 80/443 and a controlplane registration target for port 6443. Those targets can sit behind separate provider load balancers or share one load balancer with different listeners; Nstance only needs the backend membership instance group handles.
Lifecycle Integration
Registration Flow:
- Instance created via provider API
- Agent registers and sends first health report to server
- Server registers instance with all configured load balancer groups for its group
- Status tracked in
lb_instancestable:pending→registered(orfailed) - Failed registrations retried on subsequent health reports
Deregistration Flow:
- Instance marked for deletion (unhealthy, expired, or scale-down)
- Deregister from load balancer groups (first, per explicit ordering)
- Drain coordination with Operator (if Kubernetes node)
- Terminate instance via provider API (once drained, if Kubernetes node)
Reconciliation & Cache Management:
- Automatic retries: Pending or failed registrations are retried on every health report
- Leader election validation: On leader election, all LB groups are validated and cache warmed from provider APIs by querying each load balancer’s current instance list
- Cache table:
lb_instancesis a reconciliation cache tracking registration state; it’s synced from provider APIs during validation - Eventual consistency: Ensures correct state even after Nstance Server leadership changes or crashes