diff --git a/spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service/pom.xml b/spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service/pom.xml index 5e02ccb43..5cc334597 100644 --- a/spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service/pom.xml +++ b/spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service/pom.xml @@ -23,6 +23,10 @@ com.tencent.cloud spring-cloud-starter-tencent-polaris-ratelimit + + + + com.tencent.cloud diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/pom.xml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/pom.xml new file mode 100644 index 000000000..5ef821730 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/pom.xml @@ -0,0 +1,23 @@ + + + + spring-cloud-tencent-examples + com.tencent.cloud + ${revision} + ../pom.xml + + 4.0.0 + + polaris-router-grayrelease-example + pom + Spring Cloud Tencent Polaris Router GrayRelease Example + Example of Spring Cloud Tencent Polaris Router GrayRelease + + router-grayrelease-gateway + router-grayrelease-frontend + router-grayrelease-middle + router-grayrelease-backend + + \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/pom.xml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/pom.xml new file mode 100644 index 000000000..aed0b436d --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/pom.xml @@ -0,0 +1,74 @@ + + + + polaris-router-grayrelease-example + com.tencent.cloud + ${revision} + ../pom.xml + + 4.0.0 + + router-grayrelease-backend + + + + spring-cloud-starter-tencent-polaris-discovery + com.tencent.cloud + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-router + + + + com.tencent.cloud + spring-cloud-starter-tencent-metadata-transfer + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.0 + + + attach-sources + + jar + + + + + + + \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/docker/Dockerfile b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/docker/Dockerfile new file mode 100644 index 000000000..482d43ee9 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/docker/Dockerfile @@ -0,0 +1,15 @@ +############################################################ +# Dockerfile to build polaris-java quickstart example provider + +# 1. You need to build the binary from the source code, +# use `mvn clean install` to build the binary. +# 2. You need to copy the quickstart-example-provider-*.jar to this directory +# 3. Replace the ${VERSION} to the real version of the project + +############################################################ + +FROM java:8 + +ADD router-grayrelease-backend-1.5.0-Hoxton.SR9-SNAPSHOT.jar /root/app.jar + +ENTRYPOINT ["java","-jar","/root/app.jar"] \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/BackController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/BackController.java new file mode 100644 index 000000000..b86033603 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/BackController.java @@ -0,0 +1,48 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.polaris.router.grayrelease.back; + +import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@RestController +@RequestMapping("/router/gray") +public class BackController { + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private Environment environment; + + /** + * Get information of callee. + * @return information of callee + */ + @GetMapping("/rest") + public String rest() { + String env = System.getenv("SCT_METADATA_CONTENT_env"); + String appName = environment.getProperty("spring.application.name"); + return appName + "[" + env + "]"; + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/GrayReleaseBackendApplication.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/GrayReleaseBackendApplication.java new file mode 100644 index 000000000..dad89003d --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/back/GrayReleaseBackendApplication.java @@ -0,0 +1,38 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.polaris.router.grayrelease.back; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +public class GrayReleaseBackendApplication { + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + return new RestTemplate(); + } + + public static void main(String[] args) { + SpringApplication.run(GrayReleaseBackendApplication.class, args); + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..fe8933908 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/bootstrap.yml @@ -0,0 +1,17 @@ +server: + session-timeout: 1800 + port: 59002 +spring: + application: + name: gray-release-back + cloud: + polaris: + address: ${polaris_address} + namespace: default + enabled: true + discovery: + service-list-refresh-interval: 1000 +logging: + level: + org.springframework.cloud.gateway: info + com.tencent.cloud.polaris: debug diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/polaris.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/polaris.yml new file mode 100644 index 000000000..7b7363b0a --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-backend/src/main/resources/polaris.yml @@ -0,0 +1,6 @@ +global: + statReporter: + enable: true + plugin: + prometheus: + pushgatewayAddress: ${prometheus_address} \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/pom.xml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/pom.xml new file mode 100644 index 000000000..da461ad5b --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/pom.xml @@ -0,0 +1,74 @@ + + + + polaris-router-grayrelease-example + com.tencent.cloud + ${revision} + ../pom.xml + + 4.0.0 + + router-grayrelease-frontend + + + + spring-cloud-starter-tencent-polaris-discovery + com.tencent.cloud + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-router + + + + com.tencent.cloud + spring-cloud-starter-tencent-metadata-transfer + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.0 + + + attach-sources + + jar + + + + + + + \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/docker/Dockerfile b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/docker/Dockerfile new file mode 100644 index 000000000..7aec6aad2 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/docker/Dockerfile @@ -0,0 +1,15 @@ +############################################################ +# Dockerfile to build polaris-java quickstart example provider + +# 1. You need to build the binary from the source code, +# use `mvn clean install` to build the binary. +# 2. You need to copy the quickstart-example-provider-*.jar to this directory +# 3. Replace the ${VERSION} to the real version of the project + +############################################################ + +FROM java:8 + +ADD router-grayrelease-frontend-1.5.0-Hoxton.SR9-SNAPSHOT.jar /root/app.jar + +ENTRYPOINT ["java","-jar","/root/app.jar"] \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java new file mode 100644 index 000000000..5d1e1e386 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java @@ -0,0 +1,51 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package com.tencent.cloud.polaris.router.grayrelease.front; + +import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@RestController +@RequestMapping("/router/gray") +public class FrontController { + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private Environment environment; + + /** + * Get information of callee. + * @return information of callee + */ + @GetMapping("/rest") + public String rest() { + String env = System.getenv("SCT_METADATA_CONTENT_env"); + String appName = environment.getProperty("spring.application.name"); + String curName = appName + "[" + env + "]"; + String resp = restTemplate.getForObject("http://gray-release-middle/router/gray/rest", String.class); + return curName + " -> " + resp; + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/GrayReleaseFrontApplication.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/GrayReleaseFrontApplication.java new file mode 100644 index 000000000..153ad58dd --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/GrayReleaseFrontApplication.java @@ -0,0 +1,40 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.polaris.router.grayrelease.front; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +@EnableDiscoveryClient +public class GrayReleaseFrontApplication { + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + return new RestTemplate(); + } + + public static void main(String[] args) { + SpringApplication.run(GrayReleaseFrontApplication.class, args); + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..a8aa693b9 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/bootstrap.yml @@ -0,0 +1,17 @@ +server: + session-timeout: 1800 + port: 59000 +spring: + application: + name: gray-release-front + cloud: + polaris: + address: ${polaris_address} + namespace: default + enabled: true + discovery: + service-list-refresh-interval: 1000 +logging: + level: + org.springframework.cloud.gateway: info + com.tencent.cloud.polaris: debug diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/polaris.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/polaris.yml new file mode 100644 index 000000000..7b7363b0a --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/resources/polaris.yml @@ -0,0 +1,6 @@ +global: + statReporter: + enable: true + plugin: + prometheus: + pushgatewayAddress: ${prometheus_address} \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/pom.xml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/pom.xml new file mode 100644 index 000000000..e4ebfa8cf --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/pom.xml @@ -0,0 +1,80 @@ + + + + polaris-router-grayrelease-example + com.tencent.cloud + ${revision} + ../pom.xml + + 4.0.0 + + router-grayrelease-gateway + + + + spring-cloud-starter-tencent-polaris-discovery + com.tencent.cloud + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-router + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + com.tencent.cloud + spring-cloud-starter-tencent-metadata-transfer + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + com.spotify + docker-maven-plugin + 1.2.2 + + + + build + push + + + + + ${docker.image.prefix}/${project.artifactId} + src/main/docker + + + ${project.build.directory} + ${project.build.finalName}.jar + + + + + + + \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/docker/Dockerfile b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/docker/Dockerfile new file mode 100644 index 000000000..315baa834 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/docker/Dockerfile @@ -0,0 +1,15 @@ +############################################################ +# Dockerfile to build polaris-java quickstart example provider + +# 1. You need to build the binary from the source code, +# use `mvn clean install` to build the binary. +# 2. You need to copy the quickstart-example-provider-*.jar to this directory +# 3. Replace the ${VERSION} to the real version of the project + +############################################################ + +FROM java:8 + +ADD router-grayrelease-gateway-1.5.0-Hoxton.SR9-SNAPSHOT.jar /root/app.jar + +ENTRYPOINT ["java","-jar","/root/app.jar"] \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GatewayController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GatewayController.java new file mode 100644 index 000000000..57e3b9b4f --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GatewayController.java @@ -0,0 +1,53 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package com.tencent.cloud.polaris.router.grayrelease.gateway; + +import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@RestController +@RequestMapping("/router/gray") +public class GatewayController { + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private MetadataLocalProperties localProperties; + + @Autowired + private Environment environment; + + /** + * Get information of callee. + * @return information of callee + */ + @GetMapping("/entry") + public String rest() { + String appName = environment.getProperty("spring.application.name"); + String resp = restTemplate.getForObject("http://gray-release-front/router/gray/rest", String.class); + return appName + " -> " + resp; + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GrayReleaseGatewayApplication.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GrayReleaseGatewayApplication.java new file mode 100644 index 000000000..de3062970 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/java/com/tencent/cloud/polaris/router/grayrelease/gateway/GrayReleaseGatewayApplication.java @@ -0,0 +1,40 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.polaris.router.grayrelease.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +@EnableDiscoveryClient +public class GrayReleaseGatewayApplication { + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + return new RestTemplate(); + } + + public static void main(String[] args) { + SpringApplication.run(GrayReleaseGatewayApplication.class, args); + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..53f31c795 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,17 @@ +server: + session-timeout: 1800 + port: 59100 +spring: + application: + name: gray-release-gateway + cloud: + polaris: + address: ${polaris_address} + namespace: default + enabled: true + discovery: + service-list-refresh-interval: 1000 +logging: + level: + org.springframework.cloud.gateway: info + com.tencent.cloud.polaris: debug diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/polaris.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/polaris.yml new file mode 100644 index 000000000..7b7363b0a --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-gateway/src/main/resources/polaris.yml @@ -0,0 +1,6 @@ +global: + statReporter: + enable: true + plugin: + prometheus: + pushgatewayAddress: ${prometheus_address} \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/pom.xml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/pom.xml new file mode 100644 index 000000000..fa7586adb --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/pom.xml @@ -0,0 +1,74 @@ + + + + polaris-router-grayrelease-example + com.tencent.cloud + ${revision} + ../pom.xml + + 4.0.0 + + router-grayrelease-middle + + + + spring-cloud-starter-tencent-polaris-discovery + com.tencent.cloud + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-router + + + + com.tencent.cloud + spring-cloud-starter-tencent-metadata-transfer + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.0 + + + attach-sources + + jar + + + + + + + \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/docker/Dockerfile b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/docker/Dockerfile new file mode 100644 index 000000000..33d9b4606 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/docker/Dockerfile @@ -0,0 +1,15 @@ +############################################################ +# Dockerfile to build polaris-java quickstart example provider + +# 1. You need to build the binary from the source code, +# use `mvn clean install` to build the binary. +# 2. You need to copy the quickstart-example-provider-*.jar to this directory +# 3. Replace the ${VERSION} to the real version of the project + +############################################################ + +FROM java:8 + +ADD router-grayrelease-middle-1.5.0-Hoxton.SR9-SNAPSHOT.jar /root/app.jar + +ENTRYPOINT ["java","-jar","/root/app.jar"] \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/GrayReleaseMiddleApplication.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/GrayReleaseMiddleApplication.java new file mode 100644 index 000000000..ba68f0f92 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/GrayReleaseMiddleApplication.java @@ -0,0 +1,40 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.polaris.router.grayrelease.middle; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +@EnableDiscoveryClient +public class GrayReleaseMiddleApplication { + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + return new RestTemplate(); + } + + public static void main(String[] args) { + SpringApplication.run(GrayReleaseMiddleApplication.class, args); + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java new file mode 100644 index 000000000..a47d00f9d --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java @@ -0,0 +1,51 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + + +package com.tencent.cloud.polaris.router.grayrelease.middle; + +import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@RestController +@RequestMapping("/router/gray") +public class MiddleController { + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private Environment environment; + + /** + * Get information of callee. + * @return information of callee + */ + @GetMapping("/rest") + public String rest() { + String env = System.getenv("SCT_METADATA_CONTENT_env"); + String appName = environment.getProperty("spring.application.name"); + String curName = appName + "[" + env + "]"; + String resp = restTemplate.getForObject("http://gray-release-back/router/gray/rest", String.class); + return curName + " -> " + resp; + } +} diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..a54049bc9 --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/bootstrap.yml @@ -0,0 +1,17 @@ +server: + session-timeout: 1800 + port: 59001 +spring: + application: + name: gray-release-middle + cloud: + polaris: + address: ${polaris_address} + namespace: default + enabled: true + discovery: + service-list-refresh-interval: 1000 +logging: + level: + org.springframework.cloud.gateway: info + com.tencent.cloud.polaris: debug diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/polaris.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/polaris.yml new file mode 100644 index 000000000..7b7363b0a --- /dev/null +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/resources/polaris.yml @@ -0,0 +1,6 @@ +global: + statReporter: + enable: true + plugin: + prometheus: + pushgatewayAddress: ${prometheus_address} \ No newline at end of file diff --git a/spring-cloud-tencent-examples/pom.xml b/spring-cloud-tencent-examples/pom.xml index 2897d6211..a4c6c9bda 100644 --- a/spring-cloud-tencent-examples/pom.xml +++ b/spring-cloud-tencent-examples/pom.xml @@ -23,6 +23,7 @@ polaris-config-example polaris-router-example metadata-transfer-example + polaris-router-grayrelease-example