-
Notifications
You must be signed in to change notification settings - Fork 9
faq cse
liubao edited this page Apr 16, 2022
·
3 revisions
Spring Cloud Alibaba的Nacos有namespace等概念支持逻辑隔离, CSE也支持应用隔离和环境隔离,不同的应用和环境是无法相互发现的,配置也支持不同的下发维度。配置项:
server:
# 默认为空, 可以配置 production, testing, development等
env: production
spring:
application:
# 微服务名称
name: basic-provider
cloud:
servicecomb:
discovery:
# 应用名称。应用名称相同的微服务可以相互调用。 否则不能发现调用。 配置也可以定义应用生效,或者全局生效。
appName: basic-application
serviceName: ${spring.application.name}
Nacos通过namespace、data-id等概念指定一个微服务能够使用哪些配置,通过这些概念,用户可以管理一些微服务共用的配置,以及针对某一个微服务的独特配置。 CSE配置管理的概念和Nacos不同,CSE可以创建应用配置,这些应用配置默认下发到相同应用名称的所有微服务;微服务配置则下发到应用名称和微服务名称都相同的微服务;CSE还可以创建自定义配置,这些配置下发到哪个微服务,由微服务自己在配置文件确定:
spring:
cloud:
servicecomb:
config:
kie:
# 默认值是public
customLabel: public
# 默认值是空字符串
customLabelValue: default
当微服务配置了 customLabel 和 customLabelValue 后, 配置中心的配置项如果存在label key = customLabel 并且 label value = customLabelValue, 那么这个配置会下发到该微服务。
- 包含占位符的配置项
如果配置文件的配置项使用了占位符,并且占位符的值需要从配置中心获取, 那么这个配置项不能放到bootstrap.yaml文件, 需要放到应用配置文件,比如 application.yaml, 否则会报无法解析占位符的异常。
Spring Cloud Alibaba集成Sentinel以后, 可以通过实现一个 GlobalFilter, 集成sentinel的功能。 Spring Cloud Huawei也可以使用基于动态配置的流量特征治理 。 基本开发流程非常简单,只需要在路由Filter中使用该功能即可
spring:
main:
web-application-type: reactive
cloud:
gateway:
routes:
- id: basic-consumer
uri: lb://basic-consumer
filters:
## 使用基于动态配置的流量特征治理
- name: governance
predicates:
- Path=/**
- 使用动态配置的方式下发流控规则
## rate limiting configuration
servicecomb:
matchGroup:
allOperation: |
matches:
- apiPath:
prefix: "/"
rateLimiting:
allOperation: |
rate: 100
流控规则也可以统一放到配置文件,通过配置中心下发, 也可以通过CSE服务治理功能进行交互式创建。
- 微服务开发框架迁移概述
- Spring Cloud Gateway迁移CSE
- Zuul迁移CSE
-
Nacos+Spring Cloud迁移CSE
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
Eureka+Spring Cloud迁移CSE
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
HSF迁移Spring Cloud
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
Dubbo迁移Spring Cloud
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
- 常见问题
- 为migrator项目贡献代码