Skip to main content

Version: 3.2.15.2

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: API 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. Below is an interactive demo that provides a hands-on introduction.

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

  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 Add Service dialog box, do the following:
    • In the Name field, enter httpbin.
    • Click + Add Node.
    • In the Add Node dialog box, do the following:
      • In the Host field, enter test.api7.org.
      • In the Port field, enter 80.
      • Click Add.
  4. In the Hosts field, click + Add.
    • Enter test.acme.com.
  5. Turn on the Add First Route button.
  6. In the First Route dialog box, do the following:
    • In the Name field, enter get-headers.
    • In the Path field, enter headers.
    • In the Methods field, choose GET.
    • Click Add. A new service httpbin in the 'No Version' state is created.
  7. Go to the Upstreams page.
  8. (Optional) In the Connection Configuration module, click the Edit icon.
  9. (Optional) In the Edit Connection Configuration dialog box, do the following:
    • In the Pass Host field, choose Use Node Host.
    • Click Save.

Note: The steps 8 and 9 are optional. The pass_host parameter must be changed to use nodes to ensure a successful handshake with the 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

  1. Select Published Services under the Test gateway group from the side navigation bar.
  2. Click ... besides the httpbin service, then click Sync to Other Gateway Group.
  3. In the Select Gateway Group to Sync field, choose UAT gateway group, and then click Next.
  4. In the Sync Service httpbin to Gateway Group UAT dialog box, do the following:
    • In the Version field, enter 1.0.0.
    • In the Request URL field, enter uat.acme.com.
    • In the Upstream Configuration module, click Edit.
    • In 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 Save.
    • Confirm the service information and then click Sync. The httpbin service is synchronized to the UAT gateway group.
  5. (Optional) In the Connection Configuration module, click the Edit icon.
  6. (Optional) In the Edit Connection Configuration dialog box, do the following:
    • In the Pass Host field, choose Use Node Host.
    • Click Save.

Note: The steps 8 and 9 are optional. The pass_host parameter must be changed to use nodes to ensure a successful handshake with the upstream. Adjust accordingly per your use case.

  1. 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. In the Select Gateway Group to Sync field, choose Production gateway group, and then click Next.
  4. In the Sync Service httpbin to Gateway Group Production dialog box, do the following:
    • In the Request URL field, enter production.acme.com.
    • In the Upstream Configuration module, click Edit.
    • In the Edit Node 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 Save.
    • Confirm the service information and then click Sync. The httpbin service is synchronized to the Production gateway group.
  5. (Optional) In the Connection Configuration module, click the Edit icon.
  6. (Optional) In the Edit Connection Configuration dialog box, do the following:
    • In the Pass Host field, choose Use Node Host.
    • Click Save.

Note: The steps 8 and 9 are optional. The pass_host parameter must be changed to use nodes to ensure a successful handshake with the 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.


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 Ltd. 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation