You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-cloud-tencent/spring-cloud-tencent-examples/polaris-router-grayrelease-...
Haotian Zhang f4af69270c
fix:fix gray release examples bug. (#1068)
1 year ago
..
router-grayrelease-backend docs:update Polaris test environment ip. (#1012) 2 years ago
router-grayrelease-frontend fix:fix gray release examples bug. (#1068) 1 year ago
router-grayrelease-gateway docs:update Polaris test environment ip. (#1012) 2 years ago
router-grayrelease-middle fix:fix gray release examples bug. (#1068) 1 year ago
README-zh.md feat:merge features from 1.5.x-Hoxton.SR9. (#250) 3 years ago
README.md Maybe remove Chinese characters (#607) 2 years ago
pom.xml fix:add spring-cloud-starter-bootstrap dependency for example (#521) 2 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

  1. add environment variables

    • polaris server address: polaris_address=grpc://127.0.0.1:8091
    • pushgateway address: prometheus_address=127.0.0.1:9091
  2. 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 use java -jar router-grayrelease-gateway-${verion}.jar to launch application.
  3. 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)

  1. 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
  2. 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 use java -jar router-grayrelease-frontend-${verion}.jar to launch application.

Start gray1 environment (green)

  1. 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
  2. start router-grayrelease-frontend application (same as previous instruction)

    If port conflicted, you can specify another port by -Dserver.port

Start gray2 environment (purple)

  1. 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
  2. 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)

  1. 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
  2. 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 use java -jar router-grayrelease-middle-${verion}.jar to launch application.

Start gray2 environment (purple)

  1. 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
  2. start router-grayrelease-middle application (same as previous instruction)

Start Back service

Start baseline environment (blue)

  1. 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
  2. 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 use java -jar router-grayrelease-backend-${verion}.jar to launch application.

Start gray1 environment (green)

  1. 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
  2. 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]