Skip to main content

Version: latest

Service Discovery

Service discovery in API7 Gateway replaces static node lists with dynamic endpoint resolution. Instead of manually updating IP addresses for your upstream services, you can configure the data plane to query a service registry and automatically discover backend nodes.

How service discovery works

When you use service discovery, you specify a Service Name and a Discovery Type in the upstream configuration instead of a static nodes array.

  1. Query Registry: The data plane (DP) periodically queries the configured service registry (e.g., Kubernetes API, Nacos server).
  2. Retrieve Endpoints: The registry returns a list of healthy IP addresses and ports for the requested service.
  3. Local Cache: The DP caches these endpoints in memory (in shared dictionaries like kubernetes or nacos) for high-performance routing.
  4. Update Nodes: The DP updates the upstream node list based on the retrieved endpoints.
  5. Load Balance: The gateway's load balancer distributes incoming requests across the discovered nodes.

Supported discovery types

API7 Gateway's Control Plane lets you connect services to the following service registries:

  • Kubernetes: Resolves endpoints for Kubernetes Services by querying the API server directly.
  • Nacos: Integrates with the Alibaba Nacos registry for dynamic service discovery.

Comparison: Static nodes vs. service discovery

FeatureStatic NodesService Discovery
ConfigurationManual (IP/Port)Automated (Service Name)
MaintenanceHigh (must update on node change)Low (automatic)
ScalabilityManual updates required on scalingInstant scaling support
EnvironmentBare metal, legacy appsKubernetes, microservices

Configuration fields

When configuring an upstream with service discovery, you will typically provide:

  • Service Name: The name of the service as registered in the registry (e.g., user-service.default.svc.cluster.local).
  • Discovery Type: The registry type (kubernetes or nacos).
  • Namespace Selector: For Kubernetes, filters which namespaces the gateway should monitor.
  • Default Weight: The weight assigned to discovered nodes if not provided by the registry.

Next steps

API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2026. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation