-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Cloud Alibaba Best-practice Example with containerized deployment | 容器化部署最佳实践 设计 #2697
Comments
请问如何解决nacos服务发现 默认获取的IP是容器内部IP的问题? |
容器内部IP指的是?一般容易场景部署都是默认注册Pod IP地址,如果想注册固定的IP地址通过: |
比如我有两个微服务模块Order与User ,一个微服务网关Gateway,三个微服务分别用docker在三台服务器部署,此时nacos会默认将其内网IP注册到nacos注册中心中。此时Gateway从nacos获取的ip也是内网ip,其转发的ip也是该内网地址,此时gateway将无法正常请求这两个微服务模块。 |
从你的描述里面来看,Nacos Server和Gateway跟具体的微服务应用不是部署在同一个内网环境吗?这样使用确实有问题,但是其实一般的企业应用系统里面,考虑到安全和便捷性等诸多因素,网关和Nacos还是跟应用部署在同一套内网环境更合适一些。
从你的描述里面来看,Nacos Server和Gateway跟具体的微服务应用不是部署在同一个内网环境吗?这样使用确实有问题,但是其实一般的企业应用系统里面,考虑到安全和便捷性等诸多因素,网关和Nacos还是跟应用部署在同一套内网环境更合适一些。 |
对啊,你的 Gateway 和 后端的三个微服务不应该都是在同一个内网吗 ?如果自动获取的Pod IP地址不满足,你通过那个设置定制你想要获取到的IP也能满足了。 |
Chinese version
在 #2565 中,社区初步提出了 Spring Cloud Alibaba 容器化部署最佳实践的背景和需求
针对此 example 的相关的设计点如下
基本业务大纲
在本 demo 示例中,我们提供了两种业务场景
1)用户下单购买货物的场景,下单后
2)用户为商品进行点赞(模拟MQ的生产者消费者应用场景)返回商品点赞后的详细信息(点赞数等)
模块划分
为了便于理解和展示,demo 可以划分为以下的六个模块
数据库模型图
参照阿里巴巴编码规约,针对业务设计的 demo 数据库表如下
各个组件应用场景
Spring Cloud Gateway
微服务模块的网关
整合 Sentinel,通过指定断言路由和限流配置规则进行限流
通过监听 Nacos 配置的改变,实现服务网关路由配置动态刷新,每次路由信息变更,无需修改配置文件而后重启服务
Nacos
各个微服务的配置中心,服务注册中心
Seata
用于库存模块,账户模块,订单模块的分布式事务处理
只要库存不足/账户余额不足,回滚事务
Sentinel
用于点赞模块的服务熔断限流
同时整合 Nacos 配置中心,实现熔断限流规则动态配置
RocketMQ
用于进行点赞服务流量的削峰填谷
通过将大流量的点赞请求从生产者发送到 MQ ,消费者模块从 MQ 中拉取进行一定频率的消费,不是简单的直接服务熔断限流降级,实现 RocketMQ 针对大流量的削峰填谷能力
模块接口功能
前端客户端页面
order 订单模块
调用库存模块扣减库存,扣减账户余额,生成订单信息插入订单数据
只要库存不足/账户余额不足,回滚事务
storage 存储模块
扣减库存数量
account 账户模块
扣减账户余额
praise-provider 点赞生产模块
向 MQ 投递消息
praise-consumer 点赞消费模块
从 MQ 拉取消息进行消费
消费消息增加指定商品的点赞数
服务部署
针对微服务和中间件的部署,采取云原生方式进行部署,分别提供本机的 Docker-compose 以及 Kubernetes 进行容器化部署
针对每一个微服务编写对应的 DockerFile
欢迎社区针对容器化部署最佳实践的方案进行探讨,如果有更好的设计也欢迎提出。
任务列表
English version
In #2565, the community initially presents the background and requirements for the Spring Cloud Alibaba containerized deployment best practices
The relevant design points for this example are
Basic Business Outline
In this demo example, we provide two business scenarios
Module division
To facilitate understanding and presentation, the demo can be divided into the following six modules
Database model diagram
Referring to the Alibaba coding convention, the database table of the demo designed for business is as follows
Application scenarios for each component
Spring Cloud Gateway
Gateway for microservice modules
Integration with Sentinel to restrict flow by specifying assertion routes and flow restriction configuration rules
Dynamic refresh of the service gateway routing configuration by listening for changes in the Nacos configuration, eliminating the need to modify the configuration file and restart the service each time the routing information changes
Nacos
Configuration center for each microservice, service registry
Seata
Distributed transaction processing for Inventory, Account, and Order modules**
Roll back transactions whenever inventory is low/account balance is low
Sentinel
Service fusion limiting for the likes module
Also integrates with Nacos Configuration Center for dynamic configuration of fusion limit rules
RocketMQ
Used for peaks and valleys reduction of the like service traffic
RocketMQ is capable of peak and valley reduction for high traffic by sending high volume like requests from the producer to the MQ, and then the consumer module pulls from the MQ and consumes them with a certain frequency, instead of simply downgrading the service fuse limit.
Module interface functionality
Front-end client pages
Order module
Call inventory module to deduct inventory, deduct account balance, generate order information and insert order data
Roll back the transaction whenever the inventory is low/account balance is low
Storage module
Deduct inventory quantity
Account module
Deducts the account balance
Praise-provider praise production module
Deliver a message to the MQ
Praise-consumer module
Pull messages from MQ for consumption
The consumption message increases the number of likes for the specified product
Service Deployment
Deploy microservices and middleware in a cloud-native way, providing native Docker-compose and Kubernetes for containerized deployment respectively
Write the corresponding DockerFile for each microservice
The community is welcome to discuss the best practices for containerized deployment, and if you have a better design, please feel free to suggest it.
Task list
The text was updated successfully, but these errors were encountered: