Grayscale routing (canary release)
Grayscale releases are a common requirement for enterprise application operations and maintenance (O&M). Spring Cloud SOFA provides a grayscale routing feature that enables canary releases during application publishing. This feature supports both the SOFA registry and the open source Nacos registry.
Configure grayscale routing
If your application is connected to the SOFA Application Management service, you can use the grayscale feature directly when you publish the application.
If your application is not connected to the SOFA Application Management service and you want to use the SOFA grayscale routing feature, follow these steps:
During application publishing, you can inject an environment variable into the application's runtime environment to mark it for the grayscale release.
The environment variable is named
CAFE_ENV_APP_REVISION. You can set this variable to a custom value, such as the application version number. This variable must clearly identify the grayscale nodes.In the SOFA microservice console, go to the grayscale routing feature. Select the application for the grayscale release. Create or modify a grayscale rule, and then enter the grayscale mark and traffic percentage.
The grayscale mark is the value of
CAFE_ENV_APP_REVISION. Configure the traffic percentage as needed.To perform a grayscale release for specific requests or to implement A/B testing, you can specify a service path for precise filtering. You can also filter requests based on information, such as request headers, cookies, and request parameters.
You can adjust the grayscale routing percentage to switch traffic to the new version.
Disable grayscale routing
To disable grayscale routing, find the corresponding grayscale rule in the console where you enabled it (either the SOFA microservice console or the SOFA Application Management service) and then delete or disable the rule.
To completely disable the SOFA grayscale routing feature for an application, set spring.cloud.sofa.router.gray.enabled to false in the application.properties file.
spring.cloud.sofa.router.gray.enabled=false