Migrate an existing API Gateway instance to Cloud-native API Gateway
You can migrate an original API Gateway instance to Cloud-native API Gateway to ensure service continuity during the transition.
1. Overview
Cloud-native API Gateway is the primary, actively developed gateway product. If you use the original API Gateway, you can migrate your services to Cloud-native API Gateway. The following diagram shows the service traffic architecture for both gateways. After you configure API metadata in Cloud-native API Gateway, you can gradually shift service traffic by changing your domain name resolution settings.
Conceptual differences between the two gateways
To align with the OpenAPI Specification (OAS) standard, the original API Gateway and Cloud-native API Gateway have an important conceptual difference. Understand this difference before you start the migration:
An API group in the original API Gateway corresponds to an API in Cloud-native API Gateway.
An API in the original API Gateway corresponds to an operation in Cloud-native API Gateway.
Scenarios where migration is not recommended
Migration is not recommended in the following scenarios:
Alibaba Cloud Marketplace users: Cloud-native API Gateway is not yet integrated with Alibaba Cloud Marketplace. Migration is not recommended for these users at this time.
2. Migration procedure
2.1. Purchase a cloud-native instance
When you purchase a Cloud-native API Gateway instance, note the following two points:
The instance type limits differ between the original API Gateway and Cloud-native API Gateway. Re-evaluate your service capacity based on the Cloud-native API Gateway instance specifications. For more information about capacity, see Capacity description.
When you create the instance, select the virtual private cloud (VPC) where your backend service resides. Otherwise, service access fails because the VPCs cannot communicate.
2.2. Configure API metadata
2.2.1. Configure domain names and certificates
After you create a Cloud-native API Gateway instance, configure the service domain name and its corresponding certificate on the instance. For more information, see the following documents:
Change domain protocol and certificate
Cloud-native API Gateway provides more flexible Secure Sockets Layer (SSL) encryption configuration. You can configure equivalent settings based on the TLS version and cipher suite in the HTTPS security policy of the original API Gateway group:
Log on to the original API Gateway console.
In the navigation pane on the left, click API Management > Group Management. Click the group name to go to the group details page and find the HTTPS security policy type.
For details about the corresponding TLS version and cipher suite, see HTTPS security policies.
Configure the equivalent settings in the cloud-native API Gateway. For more information, see Set a specific HTTPS cipher suite.
Note:
Cloud-native API Gateway does not have the concept of environments. Domain names can only be attached to instances. The environment attachment feature of the original API Gateway has no equivalent in Cloud-native API Gateway.
Cloud-native API Gateway does not currently support OCSP or ssl_client_s_dn pass-through. If you use these features, migration is not recommended at this time.
Cloud-native API Gateway does not currently support domain name parameters based on wildcard domain names. If you use domain name parameters, migration is not recommended at this time.
2.2.2. Import API definitions
Both the original API Gateway and Cloud-native API Gateway support the standard OAS protocol. You can export API definitions from the original API Gateway as an OAS-compliant file, and then import the file into Cloud-native API Gateway.
Export the API definitions of an entire group from the original API Gateway. For more information, see Export standard OAS definitions.
Log on to the API Gateway console.
In the navigation pane on the left, choose API Management > Group Management.
On the Group List page, select the target API group. In the Actions column, click Export API Definition.
In the Export API Definition dialog box, specify the data format for the export.
You must export the API definitions in the OAS 3.0 protocol. Do not select API Gateway extension definition. Export the online API definitions directly.
Import the API definition file that you exported from the original API Gateway into the cloud-native API Gateway.
Log on to the cloud-native API Gateway console. In the navigation pane on the left, choose APIs, and select a region in the top menu bar.
Click Create API. In the REST API section, click Import and upload the API definition file that you exported in the previous step.
Key points:
Cloud-native API Gateway requires the request/response transformation plugin to implement parameter mapping.
Cloud-native API Gateway does not currently have an anti-replay feature. If you require this feature, migration is not recommended at this time.
2.2.3. Configure backend services
Next, configure backend services on the instance. The backend services supported by the original API Gateway and Cloud-native API Gateway differ slightly:
Original API Gateway | Cloud-native API Gateway |
VPC authorization (HTTP/HTTPS) | Supported (Fixed address/DNS domain name) |
Internet address (HTTP/HTTPS) | Supported (Fixed address/DNS domain name, requires NAT) |
Function Compute | Support |
EventBridge | Not supported |
Nacos/Zookeeper | Supported |
Mock | Supported |
DataWorks | Supported, go to the DataWorks console to operate |
Dataphin/DMS | Not supported |
OSS | Not supported |
For common backend services such as ECS and CLB, create a fixed-address service in Cloud-native API Gateway:
Log on to the cloud-native API Gateway console.
In the navigation pane on the left, choose Instances, and select a region in the top menu bar.
On the Instances page, click the ID of the target gateway instance.
In the navigation pane on the left, choose Services, and click Create Service. In the Create Service panel, set Service Source to Fixed Address, configure the related parameters, and then click OK.
Note:
Cloud-native API Gateway communicates with backend services through your Elastic Network Interface (ENI). When you add addresses to a whitelist, use the CIDR block of the instance's vSwitch. To find the CIDR block, go to the instance details page, find the vSwitch connection, and click it to view the corresponding CIDR block.
If the backend service is on the Internet, the VPC used by the Cloud-native API Gateway instance must have an Internet NAT gateway. Test this thoroughly before migration.
If your backend services are deployed in multiple VPCs, you must use CEN or PrivateLink to establish network connectivity before you can migrate.
2.2.4. Publish APIs
After you complete the preceding configurations, publish the API to the purchased instance for testing. The publishing logic of Cloud-native API Gateway differs significantly from that of the original API Gateway.
Publishing in the original API Gateway:
An API group is bound to a specific instance. You cannot select the instance during publishing. The API is published to the instance of its group by default.
The backend service for the API is preconfigured. You do not need to specify it each time you publish.
The request domain name is configured on the group and cannot be modified during publishing.
You must specify an environment for each publication. You can only publish to one environment at a time.
You can only publish a single API from a group at a time.
Publishing in Cloud-native API Gateway:
When you publish an API, you must select the hosting instance. The published content takes effect only on the selected instance. An API can be published to multiple instances.
You must specify the backend service each time you publish. You can change the backend service during publishing.
You must select the request domain name each time you publish. If multiple domain names provide the service, you must select all of them during publishing.
There is no concept of environments. Instances are generally used to differentiate environments.
All operations under an API are published at once. You cannot publish a single operation.
2.2.5. Configure plugins
After an API is published to an instance, you can configure policies for the API or its operations. The policies supported by Cloud-native API Gateway and the plugins supported by the original API Gateway differ significantly. The following table lists the main differences.
Original API Gateway | Corresponding cloud-native API Gateway policy/plugin |
Third-party authorization plugin | External authentication plugin Notes on the Cloud-native API Gateway external authentication plugin:
|
JWT plugin | JWT plugin Notes on the Cloud-native API Gateway JWT authentication plugin:
|
BasicAuth plugin | Basic authentication |
Backend signing plugin | Not currently supported by Cloud-native API Gateway |
Throttling plugin - Basic throttling | Throttling policy
|
Throttling plugin - Parameter-based throttling | Key-based cluster throttling |
IP access control plugin | IP restriction |
Parameter access control plugin | Parameter access control |
Cross-domain resource access plugin | Cross-origin resource sharing |
Caching plugin | General response caching |
Backend routing plugin | Services in Cloud-native API Gateway natively support routing based on matching conditions and also support grayscale routing. |
Error code mapping plugin | Custom response plugin: |
Circuit breaker plugin | Circuit breaking policy: |
Log desensitization plugin | Not currently supported by Cloud-native API Gateway |
Request/Response rewriting plugin | Request/Response transformation |
For more information about plugins for the original API Gateway, see Plugin overview.
For more information about plugins for the cloud-native API Gateway, see Plugin marketplace.
2.2.6. Configure application authorization information
Application (APP) migration
The concept of an "application" in the original API Gateway is called a "consumer" in Cloud-native API Gateway. Their capabilities are equivalent, and you can smoothly migrate this feature. For more information about managing consumers in Cloud-native API Gateway, see Manage consumers.
Important:
The API key of a consumer in Cloud-native API Gateway is the same as the AppCode of an application in the original API Gateway. You can generate a custom API key to migrate the AppCode from the original application.
The AccessKey (AK) within the Hash-based Message Authentication Code (HMAC) of a consumer in Cloud-native API Gateway is the same as the AK of an application in the original API Gateway. You can generate a custom AK to migrate the AK from the original application.
Authorization relationship migration
Consumer authorization in Cloud-native API Gateway is based on operations, which is consistent with the original API Gateway. You can configure authorization relationships for specific API operations on the API operations page. You can also grant batch authorization for API operations to a consumer on the consumer page.
3. Function verification
After you configure all API metadata, begin functional verification. Because the official domain name is currently in production on the original API Gateway, you have two options for testing:
Configure a test domain name on Cloud-native API Gateway and create a CNAME record that maps the test domain name to the instance's endpoint for testing.
Modify the host configuration of your test machine to use the original production domain name for testing.
After you resolve the endpoint issue, perform system integration. Cloud-native API Gateway provides SDKs for download. You can download sample code for calling all operations under an API directly from the API details page.
4. Grayscale migration of production services
After thorough functional verification, you can gradually migrate your services from the original API Gateway to Cloud-native API Gateway. Use a grayscale plan throughout the migration process. Migrate slowly so that you can roll back all services to the original API Gateway at any time if you encounter problems. We recommend that you gradually migrate production services by changing the resolution weight of your production domain name. For more information, see Configure weights.
On the instance's Basic Information page, find the endpoint of the Cloud-native API Gateway instance.
Create a CNAME record that maps your production domain name to the endpoint of the Cloud-native API Gateway instance. Start with a weight of 1 and then gradually increase it.
You must control the initial weight of the new CNAME record. We strongly recommend that you keep the weight below 1% and monitor for at least 24 hours before you increase the traffic weight.
Service monitoring
You can view the operational status of your services in the Observation & Analysis module of the instance. For more information, see View gateway monitoring data. If there are no abnormalities during service monitoring, you can continue to gradually increase the traffic weight.
Rollback
If you find an abnormality during grayscale migration, immediately delete the CNAME record for the Cloud-native API Gateway endpoint from your production domain name. This rolls back your services. After you resolve the issue, you can resume the migration.