Haotian Zhang
e5f7a75e09
|
3 years ago | |
---|---|---|
.. | ||
router-grayrelease-backend | 3 years ago | |
router-grayrelease-frontend | 3 years ago | |
router-grayrelease-gateway | 3 years ago | |
router-grayrelease-middle | 3 years ago | |
README-zh.md | 3 years ago | |
README.md | 3 years ago | |
pom.xml | 3 years ago |
README.md
Spring Cloud Polaris Gray Release Example
English | 简体中文
Project Explanation
This project shows how to use Spring Cloud Tencent route and transitive feature to do the full chain gray releasing.
Architecture
Incoming requests dispatched from Gateway service to 3 environments:
- gray1(match uid=1), env=green(green environment)
- gray2(match uid=2), env=purple(purple environment)
- baseline(stable environment, match all other requests), env=blue(blue environment)
How to access
Start Gateway service
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
-
start router-grayrelease-gateway application
- Launch by IDE:Start the main class
GrayReleaseGatewayApplication
. - Launch by Jar:Execute
mvn clean package
to compile with jar package, then usejava -jar router-grayrelease-gateway-${verion}.jar
to launch application.
- Launch by IDE:Start the main class
-
add the route rule
Send http request to polaris server to add the route rule, make requests dispatched to 3 environments.
POST /naming/v1/routings [{ "service": "gray-release-gateway", "namespace": "default", "outbounds": [ { "sources": [ { "service": "gray-release-gateway", "namespace": "default", "metadata": { "${http.header.uid}": { "type": "EXACT", "value": "2" } } }], "destinations": [ { "service": "*", "namespace": "*", "metadata": { "env": { "type": "EXACT", "value": "purple" } }, "priority": 0, "weight": 100, "isolate": false }] }, { "sources": [ { "service": "gray-release-gateway", "namespace": "default", "metadata": { "${http.header.uid}": { "type": "EXACT", "value": "1" } } }], "destinations": [ { "service": "*", "namespace": "*", "metadata": { "env": { "type": "EXACT", "value": "green" } }, "priority": 0, "weight": 100, "isolate": false }] }, { "sources": [ { "service": "gray-release-gateway", "namespace": "default", "metadata": { "*": { "type": "EXACT", "value": "*" } } }], "destinations": [ { "service": "*", "namespace": "*", "metadata": { "env": { "type": "EXACT", "value": "blue" } }, "priority": 0, "weight": 100, "isolate": false }] } ] }]
The route rule can be added by polaris console:
Start Front service
Start baseline environment (blue)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=blue
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-frontend application
- Launch by IDE:Start the main class
GrayReleaseFrontApplication
. - Launch by Jar:Execute
mvn clean package
to compile with jar package, then usejava -jar router-grayrelease-frontend-${verion}.jar
to launch application.
- Launch by IDE:Start the main class
Start gray1 environment (green)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=green
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-frontend application (same as previous instruction)
If port conflicted, you can specify another port by -Dserver.port
Start gray2 environment (purple)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=purple
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-frontend application (same as previous instruction)
Start effective
You can find the instances with different tags in polaris console.
Start Middle service
Start baseline environment (blue)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=blue
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-middle application
- Launch by IDE:Start the main class
GrayReleaseMiddleApplication
. - Launch by Jar:Execute
mvn clean package
to compile with jar package, then usejava -jar router-grayrelease-middle-${verion}.jar
to launch application.
- Launch by IDE:Start the main class
Start gray2 environment (purple)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=purple
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-middle application (same as previous instruction)
Start Back service
Start baseline environment (blue)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=blue
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-backend application
- Launch by IDE:Start the main class
GrayReleaseBackendApplication
. - Launch by Jar:Execute
mvn clean package
to compile with jar package, then usejava -jar router-grayrelease-backend-${verion}.jar
to launch application.
- Launch by IDE:Start the main class
Start gray1 environment (green)
-
add environment variables
- polaris server address: polaris_address=grpc://127.0.0.1:8091
- pushgateway address: prometheus_address=127.0.0.1:9091
- env tag:SCT_METADATA_CONTENT_env=green
- transitive tag:SCT_METADATA_CONTENT_TRANSITIVE=env
-
start router-grayrelease-backend application (same as previous instruction)
Test
Baseline routing
curl -H'uid:0' 127.0.0.1:59100/router/gray/route_rule
Got result
gray-release-gateway -> gray-release-front[blue] -> gray-release-middle[blue] -> gray-release-back[blue]
Green routing
curl -H'uid:1' 127.0.0.1:59100/router/gray/route_rule
Got result
gray-release-gateway -> gray-release-front[green] -> gray-release-middle[blue] -> gray-release-back[green]
Purple routing
curl -H'uid:2' 127.0.0.1:59100/router/gray/route_rule
Got result
gray-release-gateway -> gray-release-front[purple] -> gray-release-middle[purple] -> gray-release-back[blue]