Follow Me with CSE Series Part 4: Configuring Microservices Based on HUAWEI CLOUD

This chapter mainly describes the release of microservices to Huawei public cloud. The basic principle of cloud configuration is that you only need to configure microservice.yaml properly and add additional dependencies to pom to use related functions.

One-click configuration

The public cloud version provides a one-click simplified configuration method, allowing applications developed based on the open source version to quickly switch to cloud applications, and directly use the grayscale publishing, service governance and other functions provided by the public cloud.

  • Add dependencies (pom.xml)
<dependency> 
  <groupId>com.huawei.paas.cse</groupId>  
  <artifactId>cse-solution-service-engine</artifactId> 
</dependency>

Developers only need to configure dependencies on cse-solution-service-engine to complete all configurations of the public cloud. This dependency mainly does the following things for developers:

  • components that import dependencies

  • Added default configuration items. The default configuration includes processing chain, load balancing strategy, etc.

You can view the imported components and added configuration items by viewing the pom content and the microservice.yaml file in the jar package. In the following chapters, the components added to the cloud and their functions are explained in detail, so that developers can have a deeper understanding of various technical details.

Connect to Service Center

Function description

The service center realizes registration and discovery. To view the microservice catalog in FusionStage/ServiceStage, all microservices need to be connected to the service center.

Configuration reference

  • Add dependencies (pom.xml)

If the connection service center uses https protocol/AK/SK authentication, this jar dependency is required. If it is the http protocol and does not include token verification, there is no need to introduce it.

<dependency> 
  <groupId>com.huawei.paas.cse</groupId>  
  <artifactId>foundation-auth</artifactId> 
</dependency>
  • Configuration item (microservice.yaml)
cse:
 service:
  registry:
   address: https://cse.cn-north-1.myhwclouds.com:443    #根据实际地址配置服务中心地址

This configuration item configures the address of the service center. For address, you can find the corresponding service center address in the public cloud "Tools and Cases" directory, modify the protocol (http/https), host name (may use domain name) and port number.

Connection configuration center

Function description

The configuration center implements configuration distribution, and the connection configuration center is the front desk for functions such as management and grayscale publishing.

Configuration reference

  • Add dependencies (pom.xml)

If the connection configuration center uses https protocol/AK/SK authentication, this jar dependency is required. If it is the http protocol and does not include token verification, there is no need to introduce it.

<dependency> 
  <groupId>com.huawei.paas.cse</groupId>  
  <artifactId>foundation-auth</artifactId> 
</dependency>

This jar is required to connect to the configuration center

<dependency> 
  <groupId>com.huawei.paas.cse</groupId>  
  <artifactId>foundation-config-cc</artifactId> 
</dependency>
  • Enable configuration (microservice.yaml)
cse:
 config:
  client:
   serverUri: https://cse.cn-north-1.myhwclouds.com:443

该配置项配置了配置中心的地址。其中,address可以在公有云“工具和案例”目录下查到对应的配置中心地址,修改协议(http/https)、主机名(可能使用域名)和端口号。

使用服务治理

功能描述

服务治理主要涉及“隔离”、“熔断”、“容错”、“限流”、“负载均衡”等。

配置参考

配置项(microservice.yaml)

需要增加下面治理相关的handler,才能在从配置中心实时获取治理数据。

cse:
 handler:
  chain:
   Provider:
    default: bizkeeper-provider,qps-flowcontrol-provider
   Consumer:
    default: bizkeeper-consumer,loadbalance,qps-flowcontrol-consumer

使用故障注入

功能描述

故障注入主要提供了延时、错误两种类型故障。

配置参考

配置项(microservice.yaml)

需要增加下面治理相关的handler。

cse:
 handler:
  chain:
   Consumer:
    default: loadbalance,fault-injection-consumer

使用灰度发布

功能描述

该功能对应于微服务目录灰度发布功能。管理员可以通过下发规则,对服务进行灰度发布管理。

配置参考

  • 增加依赖关系(pom.xml)

引入必要的jar包。

<dependency> 
  <groupId>com.huawei.paas.cse</groupId>  
  <artifactId>cse-handler-cloud-extension</artifactId>
</dependency>
  • 在Consumer端配置负载均衡(microservice.yaml)

在负载均衡模块启用了灰度发布的filter。

cse:
 loadbalance:
  serverListFilters: darklaunch
  serverListFilter:
    darklaunch:
      className: com.huawei.paas.darklaunch.DarklaunchServerListFilter

使用调用链

功能描述

华为云提供了业务无侵入的埋点功能APM。只需要通过华为云部署容器应用,并选择启用调用链监控功能,即可使用调用链服务。

微服务运行数据上报

功能描述

微服务可以将自己的运行数据上报给Dashboard服务,在公有云上查看仪表盘数据、分布式事务数据等。该章节是描述如何启用微服务数据上报功能。

配置参考

  • 增加依赖关系(pom.xml)

引入必要的jar包。

<dependency>
  <groupId>com.huawei.paas.cse</groupId>
  <artifactId>cse-handler-cloud-extension</artifactId>
</dependency>
  • 配置handler

仪表盘数据依赖于两个handler,一个bizkeeper-provider(客户端为bizkeeper-consumer),一个perf-stats,所以对应的pom依赖需要先引入。

cse:  
  handler:
    chain:
      Provider:
        default: bizkeeper-provider,perf-stats,tracing-provider,sla-provider
      Consumer:
        default: bizkeeper-consumer,loadbalance,perf-stats,tracing-consumer,sla-consumer
  • 配置上报monitor地址

TenantLB_ADDRESS为共有云租户管理面接入地址,默认是100.125.1.34。

cse:
  service:
    registry:
      address: https://${TenantLB_ADDRESS}:30100
  monitor:
    client:
      serverUri: https://${TenantLB_ADDRESS}:30109

分布式事务: TCC

功能描述

主要实现基于TCC协议的分布式服务间的最终一致性方案,保障一般场景下的应用一致性需求,并可以在FusionStage/ServiceStage分布式事务界面查看事务详细信息。

配置参考

  • 增加依赖关系(pom.xml)

引入必要的jar包

<dependency>
  <groupId>com.huawei.paas.cse</groupId>
  <artifactId>cse-handler-tcc</artifactId>
</dependency>
  • 配置项参考

需要增加下面事务相关的handler,才能在从配置中心实时获取治理数据。

cse:
 handler:
  chain:
   Provider:
    default: tcc-client,bizkeeper-provider
   Consumer:
    default: tcc-server,bizkeeper-consumer,loadbalance

华为云微服务引擎 CSE ,截止到2018630 限时免费

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325828921&siteId=291194637