Skip to main content

Version: 3.6.x

Manage Services in Multi-Environments Using Gateway Group

Gateway groups are a logical grouping of one or more gateway instances that share the same configuration and behave consistently when handling API requests. Users can name the gateway groups and add labels to them to differentiate and manage different environments and clusters.

API7 Enterprise supports two types of gateway group management: API7 Gateway and Ingress Controller. This helps enterprises achieve environment and cluster isolation, multi-region and multi-cluster management, as well as service-level objective management based on projects.

This guide will show you how to manage service across the Test, UAT, and Production environments using gateway groups.

Background

To ensure service stability, compliance, and data security, the service goes through multiple environments, including test, UAT, and production environments. Without this feature, developers should deploy three sets of API7 Enterprise and log in to the dashboard under different domains to develop, test, and deploy the same API. In the case of many business projects, this process will waste a lot of machine and management resources.

The gateway group feature of the API7 Enterprise provides developers with a unified entry point. It avoids switching between multiple dashboards, and enables simple and convenient deployment operations, thereby improving work efficiency and reducing operational errors.

Multi-Environment Service Publishing

Prerequisites

  1. Install API7 Enterprise.
  2. Prepare different domain names for the service in the three environments: test.acme.com, uat.acme.com, and prod.acme.com.
  3. Refer to adding a gateway group, and create three gateway groups: Test, UAT, and Production.

Create Service and Route in the Test Environment

note

Strict version control is not required in the test environment due to frequent changes. Only the final stable configuration will be synchronized to higher environments and marked as an official version. Only official versions can be rolled back and traced.

  1. Select Published Services under the Test gateway group from the side navigation bar and then click Add Service.
  2. Select Add Manually.
  3. In the dialog box, do the following:
    • In the Name field of Service Basics, enter httpbin.
    • In the Service Type field, choose HTTP(Layer 7 protocol).
    • In the Name field of Upstream Basics, enter default.
    • Click + Add Node.
    • In the dialog box, do the following:
      • In the Host field, enter test.api7.org.
      • In the Port field, enter 80.
      • Click Add.
    • In the Upstream Scheme field, choose HTTP.
    • (Optional) Click View More Connection Configuration.
    • (Optional) In the The host HTTP header passed to upstream field, choose Specified in the Upstream's Host.
    • In the Hosts field of Request URL, enter test.acme.com.
    • Turn on the Add First Route switch, then do the following:
      • In the Name field, enter get-headers.
      • In the Path field, enter headers.
      • In the Methods field, choose GET.
    • Click Add.
  4. A new service httpbin in the 'No Version' state is created.

Note: In this test case, the The host HTTP header passed to upstream parameter must be changed to Specified in the Upstream's Host to ensure a successful handshake with the demo upstream. Adjust accordingly per your use case.

  1. Simulate real user scenarios to perform functional testing, performance testing, and security testing.

Validate the Service

After testing, send a request to validate the httpbin service in the test gateway group.

curl "http://localhost:9080/headers" -v -H "Host: test.acme.com"

You will receive a 200 OK response.

Deploy Services to the UAT Environment

note

Version numbers serve as unique identifiers across all gateway groups. Using the synchronization process instead of manually copying configurations to critical environments provides a more convenient way to track versions, prevent accidental modifications, and ensure thorough testing before UAT and production.

  1. Select Published Services under the Test gateway group from the side navigation bar.
  2. Click ... button on the page header, then click Sync to Other Gateway Group.
  3. From the dialog box, do the following:
  • In the Gateway Group field, choose UAT.
  • In the Version field, enter 1.0.0.
  • Click Sync.
  1. After synchronization, you will be redirected to the published service httpbin 1.0.0 on the UAT gateway group.
  2. Select Routes from the side navigation bar.
  3. In the Request URL field, click the edit button.
  4. From the dialog box, do the following:
  • In the Hosts field, click Add, then enter uat.acme.com.
  • Click Save.
  1. Select Upstreams from the side navigation bar.
  2. Click Add Node.
  3. From the dialog box, do the following:
  • In the Host and Port fields, enter uat.api7.org as the host and 80 as the port.
  • In the Weight field, use the default value 100.
  • Click Add.
  1. (Optional) In the Connection Configuration module, click the Edit icon.
  2. (Optional) From the dialog box, do the following:
  • In the The host HTTP header passed to upstream field, choose Specified in the Upstream's Host.
  • Click Save.

Note: In this test case, the The host HTTP header passed to upstream parameter must be changed to Specified in the Upstream's Host to ensure a successful handshake with the demo upstream. Adjust accordingly per your use case.

  1. (Optional) In the UAT gateway group, configure the gateway group's security policies and compliance check functions, such as conducting log auditing.

Validate the Service

After testing, send a request to validate the httpbin service in the test gateway group.

curl "http://localhost:9080/headers" -v -H "Host: uat.acme.com"

You will receive a 200 OK response.

Deploy Services to the Production Environment

  1. Select Published Services under the UAT gateway group from the side navigation bar.
  2. Click ... besides the httpbin service, then click Sync to Other Gateway Group.
  3. From the dialog box, do the following:
  • In the Gateway Group field, choose Production.
  • In the Version field, enter 1.0.0.
  • Click Sync.
  1. After synchronization, you will be redirected to the published service httpbin 1.0.0 on the Production gateway group.
  2. Select Routes from the side navigation bar.
  3. In the Request URL field, click the edit button.
  4. From the dialog box, do the following:
  • In the Hosts field, click Add, then enter production.acme.com.
  • Click Save.
  1. Select Upstreams from the side navigation bar.
  2. Click Add Node.
  3. From the dialog box, do the following:
  • In the Host and Port fields, enter prod.api7.org as the host and 80 as the port.
  • In the Weight field, use the default value 100.
  • Click Add.
  1. (Optional) In the Connection Configuration module, click the Edit icon.
  2. (Optional) In the Edit Connection Configuration dialog box, do the following:
    • In the The host HTTP header passed to upstream field, choose Specified in the Upstream's Host.
    • Click Save.

Note: In this test case, the The host HTTP header passed to upstream parameter must be changed to Specified in the Upstream's Host to ensure a successful handshake with the demo upstream. Adjust accordingly per your use case.

  1. Regularly review and analyze the logs of the httpbin, perform log management, and identify potential issues for improvement.
  2. Develop a detailed rollback plan, including rollback steps, required time, and responsible personnel, and roll back the published services when necessary.

Validate the Service

After testing, send a request to validate the httpbin service in the test gateway group.

curl "http://localhost:9080/headers" -v -H "Host: production.acme.com"

You will receive a 200 OK response.

Conclusion

Test, UAT, and production environments are essential components of the software development lifecycle. By leveraging gateway groups of API7 Enterprise, you can achieve physical and logical isolation, enhancing security, controllability, and efficiency. Additionally, the ability to adjust route rules and manage service versions flexibly ensures smooth and agile version management of your applications.

Additional Resources


API7.ai Logo

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

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

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

Apache Software Foundation