Skip to main content

Version: 3.2.16.7

Use Service Discovery for Upstream

Instead of configuring the upstream directly, service discovery mechanisms like Consul, Eureka, Nacos, or Kubernetes Service Discovery can be used to dynamically detect upstream nodes.

info

Once published, a service cannot directly switch between configured upstream nodes and service discovery. Instead, you have to configure this through a canary deployment.

Prerequisites

  1. Install API7 Enterprise.
  2. Have at least one gateway instance in your gateway group.

Kubernetes

Add Service Registry Connection

  1. Select Service Registries of your gateway group from the side navigation bar, then click Add Service Registry Connection.
  2. From the dialog box, do the following:
  • In the Name field, enter Registry for Test.
  • In the Discovery Type field, choose Kubernetes.
  • Fill in the API Server Address and Token Value field.
  • Click Add.
  1. Wait to make sure the status of the service registry is Healthy.

Configure Upstream

  1. Select Published Services under your gateway group from the side navigation bar and then click Add Service.

  2. Select Add Manually.

  3. From the Add Service dialog box, do the following:

    • In the Name field, enter httpbin.
    • In the Service Type field, choose HTTP (Layer 7 Proxy).
    • In the Upstream Scheme field, choose HTTP.
    • In the How to find the upstream field, choose Use Service Discovery.
    • In the Service Registry field, choose Registry for Test, then choose the Namespace and Service Name.
  4. Click Add. This will create a new service in the 'No Version' state.

Below is an interactive demo that provides a hands-on introduction to connecting Kubernetes service discovery. You will gain a better understanding of how to use it in API7 Gateway by clicking and following the steps.

Nacos

Add Service Registry Connection

  1. Select Service Registries of your gateway group from the side navigation bar, then click Add Service Registry Connection.
  2. From the dialog box, do the following:
  • In the Name field, enter Registry for Test.
  • In the Discovery Type field, choose Nacos.
  • In the Hosts field, fill in the host address and port.
  • In the How to Get Token field, choose a way to get the token and configure related parameters.
  • Click Add.
  1. Wait to make sure the status of the service registry is Healthy.

Configure Upstream

  1. Select Published Services under your gateway group from the side navigation bar and then click Add Service.

  2. Select Add Manually.

  3. From the Add Service dialog box, do the following:

    • In the Name field, enter httpbin.
    • In the Service Type field, choose HTTP (Layer 7 Proxy).
    • In the Upstream Scheme field, choose HTTP.
    • In the How to find the upstream field, choose Use Service Discovery.
    • In the Service Registry field, choose Registry for Test, then choose the Namespace, Group, and Service Name.
  4. Click Add. This will create a new service in the 'No Version' state.

Below is an interactive demo that provides a hands-on introduction to connecting Nacos service discovery. You will gain a better understanding of how to use it in API7 Gateway by clicking and following the steps.

Additional Resource


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

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

Apache Software Foundation