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.
Prerequisites
- Install API7 Enterprise.
- Prepare different domain names for the service in the three environments:
test.acme.com
,uat.acme.com
, andprod.acme.com
. - Refer to adding a gateway group, and create three gateway groups:
Test
,UAT
, andProduction
.
Create Service and Route in the Test Environment
- Select Published Services under the
Test
gateway group from the side navigation bar and then click Add Service. - Select Add Manually.
- 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.
- In the Host field, enter
- In the Name field, enter
- In the Hosts field, click + Add.
- Enter
test.acme.com
.
- Enter
- Turn on the Add First Route button.
- 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.
- In the Name field, enter
- Go to the Upstreams page.
- (Optional) In the Connection Configuration module, click the Edit icon.
- (Optional) In the Edit Connection Configuration dialog box, do the following:
- In the Pass Host field, choose
Use Node Host
. - Click Save.
- In the Pass Host field, choose
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.
- 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
- Select Published Services under the
Test
gateway group from the side navigation bar. - Click ... besides the
httpbin
service, then click Sync to Other Gateway Group. - In the Select Gateway Group to Sync field, choose
UAT
gateway group, and then click Next. - 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 and80
as the port. - In the Weight field, use the default value
100
. - Click Save.
- In the Host and Port fields, enter
- Confirm the service information and then click Sync. The
httpbin
service is synchronized to theUAT
gateway group.
- In the Version field, enter
- (Optional) In the Connection Configuration module, click the Edit icon.
- (Optional) In the Edit Connection Configuration dialog box, do the following:
- In the Pass Host field, choose
Use Node Host
. - Click Save.
- In the Pass Host field, choose
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.
- 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
- Select Published Services under the
UAT
gateway group from the side navigation bar. - Click ... besides the
httpbin
service, then click Sync to Other Gateway Group. - In the Select Gateway Group to Sync field, choose
Production
gateway group, and then click Next. - 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 and80
as the port. - In the Weight field, use the default value
100
. - Click Save.
- In the Host and Port fields, enter
- Confirm the service information and then click Sync. The
httpbin
service is synchronized to theProduction
gateway group.
- In the Request URL field, enter
- (Optional) In the Connection Configuration module, click the Edit icon.
- (Optional) In the Edit Connection Configuration dialog box, do the following:
- In the Pass Host field, choose
Use Node Host
. - Click Save.
- In the Pass Host field, choose
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.
- Regularly review and analyze the logs of the
httpbin
, perform log management, and identify potential issues for improvement. - 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.