Implement end-to-end canary release for Spring Boot applications
The Java agent now supports end-to-end canary release for applications that use Kubernetes service discovery. Unlike Spring Cloud, the Spring Boot framework does not natively connect to third-party service registries. Instead, many Spring Boot applications deployed in Kubernetes clusters rely on Kubernetes Services for inter-application communication. This topic explains how to use MSE Microservices Governance to implement an end-to-end canary release for these applications.
Prerequisites
-
A Kubernetes cluster is available. For more information, see Create an ACK managed cluster and Create an ACK Serverless cluster.
-
Activate MSE Microservices Governance Enterprise Edition and create a microservice namespace.
-
The MSE Microservices Governance component ack-onepilot is installed (version 3.3.x or later is recommended).
-
Advanced governance capabilities are enabled for the Kubernetes cluster.
NoteIf you are using ack-onepilot version 4.x or later, a delay may occur. After you enable advanced governance capabilities, wait about 10 minutes or restart ack-onepilot before you deploy your applications. This delay is expected to be reduced in future releases.
Limitations
During the public preview, this feature is available only in the following regions: China (Beijing), China (Shanghai), China (Hangzhou), China (Shenzhen), China (Zhangjiakou), US (Silicon Valley), and Singapore.
Because this feature is in public preview, you must pin the Java agent version to 4.2.5-proxyless. For more information, see Specify the MSE agent version.
For information about the supported HTTP frameworks and version limits when a Spring Boot application calls other applications, see Frameworks supported by Microservices Governance.
Demo overview
This topic provides an example of deploying applications from the ACK console. The following diagram shows the architecture of the demo applications. The application call chain includes both Spring Cloud applications that use Nacos for service discovery and Spring Boot applications that use Kubernetes Services for service discovery.
-
Gateway: Based on Spring Cloud Gateway, this application is the traffic ingress and calls Application A by using Nacos-based service discovery.
-
A: A Spring Cloud application. Its nodes are registered with Nacos for service discovery. It calls Application B by using Kubernetes service discovery and calls Application D by using Nacos-based service discovery.
-
B: A Spring Boot application. It calls Application D by using Kubernetes service discovery.
-
D: A Spring Cloud application. Its nodes are registered with Nacos for service discovery.
Procedure
Step 1: Deploy base and canary applications
Log on to the ACK console.
In the left-side navigation pane, click Clusters. Then, click the name of the cluster that you want to manage.
In the left-side navigation pane, choose .
In the upper part of the page, select the namespace of the cluster, and click Create from YAML.
-
Use the following YAML to deploy the applications.
Step 2: Configure end-to-end canary release
Log on to the MSE console, and select a region in the top navigation bar.
In the left-side navigation pane, choose .
-
On the End-to-end Canary Release page, select
mse-springboot-demofrom the microservice namespace drop-down list. -
If no lane group exists in the selected microservice namespace, click Create Lane Groups and Lanes. If a lane group already exists, click + Create Lane Group.
-
In the Create Lane Group panel, set the following parameters and click OK.
Parameter
Example
Name of Lane Group
Enter a custom name for the lane group, such as mse-springboot-demo.
Entry Type
Select Java Service Gateway.
Lane Group Traffic Entry
Select spring-cloud-gateway.
Lane Group Application
Select spring-cloud-a, spring-boot-b, and spring-cloud-d.
-
At the bottom of the Full link Grayscale page, click Click to create the first shunt Lane if no lane exists in the microservice namespace. If a lane already exists, click Create swim lanes.
-
In the Create swim lanes panel, configure the lane settings and click OK.
Parameter
Description
Configure node tags
Add a tag to the canary application nodes to distinguish them from the base nodes.
Enter lane information
Lane name: Enter a descriptive name for the lane.
Lane tag: The destination tag for traffic routed to this lane. In this example, the tag is
gray.Confirm match: Verify that the number of application nodes with this tag is correct.
Lane status: Select Enabled.
Configure routing and canary rules
Set the rules for routing traffic to this lane.
-
Canary release mode: Select By Request Content.
-
Canary release conditions: Select All conditions must be met.
For this example, configure the conditions as follows:
-
Parameter Type:
Header. -
Parameter:
x-springboot-demo. -
Condition:
==. -
Value:
1.
-
-
Step 3: Verify the results
Log on to the ACK console.
In the left-side navigation pane, click Clusters. Then, click the name of the cluster that you want to manage.
-
On the Cluster Information page, choose Network > Services in the navigation pane on the left. Copy the external IP address of
spring-cloud-gateway-slband use it to perform the following checks.Base traffic routing
Send a request to the Spring Cloud Gateway with the path
/A/A/a. Observe that all traffic is routed to the base nodes.# Test command curl http://<external-ip-address>/A/A/a # Test result A:192.168.0.17:base -(java)- B:192.168.100.231:base - D:192.168.0.19:baseCanary traffic routing
Send a request to Spring Cloud Gateway with the route
/A/A/aand addx-springboot-demo=1to theHeader. All traffic is routed to the canary node, which indicates that the end-to-end canary release configuration is effective.# Test command curl -H "x-springboot-demo:1" http://<external-ip-address>/A/A/a # Test result A:192.168.100.234:gray -(java)- B:192.168.0.21:gray - D:192.168.0.14:grayTab 2 content