doc: add Helm installation docs for integrated example

pull/2828/head
黄sir 2 years ago
parent 44547a9af6
commit 932594d136

@ -1,2 +1,117 @@
# Spring Cloud Alibaba Containerized Deployment Best Practices | Docker-Compose Container Edition
Under Construction.....
# Spring Cloud Alibaba Containerized Deployment Best Practices | Kubernetes Helm-Chart Edition
## Preparation
This is the Spring Cloud Alibaba Best Practices Kubernetes deployment version, which requires you to prepare the following environment
- Kubernetes (we recommend using Docker Desktop's built-in integrated Kubernetes environment for this experience)
- Helm
If you don't have the above environment, please go to the official documentation to build the environment
- [Helm Installation](https://helm.sh/zh/docs/intro/install/)
- [Kubernetes Docker Desktop Quick Install](https://docs.docker.com/desktop/kubernetes/)
## Start testing
Go to the `spring-cloud-alibaba-examples/integrated-example` directory and execute the following command to complete the Helm installation
```shell
helm package helm-chart
helm install integrated-example integrated-example-1.0.0.tgz
```
With the above command we were able to deploy the best practice project via Helm with one click based on the Helm Chart documentation provided by the project
You can check the deployment status of each container resource through the `kubectl` command provided by Kubernetes, and wait patiently for **all containers to finish starting** to experience the usage scenarios and capabilities of each component on the corresponding page
If you want to stop the experience, enter the following command
```shell
helm uninstall integrated-example
```
### Distributed transaction capabilities
#### Scenario Description
For the distributed transaction capability, we provide a scenario **where a user places an order to purchase goods** and after placing the order.
- First request the inventory module and deduct the inventory
- Deduct the account balance
- Generate order information to return a response
##### start test
Start `integrated_storage`,`integrated_account`,`integrated_order` microservices respectively.
Visit `http://127.0.0.1:30080/order` to experience the corresponding scenario.
By clicking the order button directly to submit the form, we simulate the client sending a request to the gateway to create an order.
- The user's userId is admin
- The item number of the user's order is 1
- The number of items purchased in this order is 1
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112011327.png)
In this demo example, the unit price of each item is 2 for demonstration purposes.
And in the previous preparation, **initialize business database table** we created a new user userId = admin with a balance of $3, and a new item numbered 1 with 100 units in stock.
So by doing the above, we will create an order, deduct the number of items in stock corresponding to item number 1 (100-1=99), and deduct the balance of the admin user (3-2=1).
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008111903019.png)
If the same interface is requested again, again the inventory is deducted first (99-1=98), but an exception is thrown because the admin user's balance is insufficient and is caught by Seata, which performs a two-stage commit of the distributed transaction and rolls back the transaction.
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008111924467.png)
You can see that the database still has 99 records in stock because of the rollback.
### Fused flow limiting, peak shaving capability
#### Scenario Description
For service fusion limiting and peak and valley cutting in the context of high traffic, we provide a scenario** where users make likes for products**. In this scenario, we provide two ways to deal with high traffic.
- Sentinel binds specified gateway routes on the gateway side for fusion degradation of services.
- RocketMQ performs traffic clipping, where the producer sends messages to RocketMQ under high traffic requests, while the consumer pulls and consumes through a configurable consumption rate, reducing the pressure of high traffic direct requests to the database to increase the number of likes requests.
#### startup test
Start the `integrated_provider` and `integrated_consumer` modules separately.
- Sentinel service meltdown degradation
Visit `http://127.0.0.1:30080/sentinel` to experience the corresponding scenario.
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112154213.png)
The Gateway routing point service has a flow limit rule of 5, while 10 concurrent requests are simulated on the front end by asynchronous processing.
Therefore, we can see that Sentinel performs a service fusion on the Gateway side to return the fallback to the client for the extra traffic, while the number of likes in the database is updated (+5).
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112036924.png)
- RocketMQ is performing peak and valley reduction
Visit `http://127.0.0.1:30080/rocketmq` to experience the corresponding scenario.
Since we previously configured the consumption rate and interval of the `integrated-consumer` consumer module in Nacos, we simulate 1000 requests for likes at the click of a button, and the `integrated_provider`
will deliver 1000 requests to the Broker, and the consumer module will consume them according to the configured consumption rate, and update the database with the product data of the likes, simulating the characteristics of RocketMQ to cut the peaks and fill the valleys under high traffic.
You can see that the number of likes in the database is being dynamically updated.
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112225839.png)
## Other
This example **is just a selection of typical features for each component to serve the application scenario**.
If you are interested or want to go deeper, you are welcome to study the separate example documentation for each component.
- Nacos Examples
- [nacos-config-example](../../nacos-example/nacos-config-example/readme-zh.md)
- [nacos-discovery-example](../../nacos-example/nacos-discovery-example/readme-zh.md)
- [Sentinel-Core-Example](../../sentinel-example/sentinel-core-example/readme-zh.md)
- [Seata Examples](../../seata-example/readme-zh.md)
- [RocketMQ Example](../../rocketmq-example/readme-zh.md)

@ -1,2 +1,117 @@
# Spring Cloud Alibaba容器化部署最佳实践 | Kubernetes Helm-Chart 版本
建设中
## 准备工作
此版本为 Spring Cloud Alibaba 最佳实践 Kubernetes 部署版本,其中需要您准备如下的环境
- Kubernetes建议使用 Docker Desktop 内置集成的 Kubernetes 环境进行体验)
- Helm
如果您还未具备如上的环境,请移步至对应官方文档进行环境搭建
- [Helm 安装](https://helm.sh/zh/docs/intro/install/)
- [Kubernetes Docker Desktop 快捷安装](https://docs.docker.com/desktop/kubernetes/)
## 启动测试
进入到 `spring-cloud-alibaba-examples/integrated-example` 目录下,执行如下命令完成 Helm 的安装
```shell
helm package helm-chart
helm install integrated-example integrated-example-1.0.0.tgz
```
通过上述命令我们根据项目提供的 Helm Chart 文档通过 Helm 一键完成了最佳实践项目的部署
可以通过Kubernetes 提供的 `kubectl` 命令查看各容器资源部署的情况,耐心等待**所有容器完成启动后**即可到对应页面体验各个组件使用场景及能力
如果您想停止体验,输入如下命令
```shell
helm uninstall integrated-example
```
### 分布式事务能力
#### 场景说明
针对分布式事务能力,我们提供了**用户下单购买货物的场景**,下单后:
- 先请求库存模块,扣减库存
- 扣减账户余额
- 生成订单信息返回响应
##### 启动测试
分别启动`integrated_storage`,`integrated_account`,`integrated_order`三个微服务。
访问`http://127.0.0.1:30080/order` 来体验对应场景。
直接点击下单按钮提交表单,我们模拟客户端向网关发送了一个创建订单的请求。
- 用户的 userId 为 admin
- 用户下单的商品编号为1号
- 此次订单购买的商品个数为1个
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112011327.png)
在本 demo 示例中为了便于演示每件商品的单价都为2。
而在前面的准备工作中,**初始化业务数据库表**的时候我们新建了一个用户 userId = admin余额为 3 元;同时新建了一个编号为 1 号的商品,库存为 100 件。
因此通过上述的操作,我们会创建一个订单,扣减对应商品编号为 1 号的库存个数(100-1=99),扣减 admin 用户的余额(3-2=1)。
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008111903019.png)
如果再次请求相同的接口,同样是先扣减库存(99-1=98),但是会因为 admin 用户余额不足而抛出异常,并被 Seata 捕获,执行分布式事务二阶段提交,回滚事务。
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008111924467.png)
可以看到数据库中库存的记录因为回滚之后仍然为 99 件。
### 熔断限流,削峰填谷能力
#### 场景说明
针对大流量背景下的服务熔断限流,削峰天谷,我们提供了**用户为商品进行点赞的场景**。在此场景下,我们提供了两种应对大流量的处理方式。
- Sentinel 在网关侧绑定指定网关路由进行服务的熔断降级。
- RocketMQ 进行流量削峰填谷,在大流量请求下,生产者向 RocketMQ 发送消息,而消费者则通过可配置的消费速率进行拉取消费,减少大流量直接请求数据库增加点赞请求的压力。
#### 启动测试
分别启动`integrated_provider`以及`integrated_consumer`模块。
- Sentinel 服务熔断降级
访问`http://127.0.0.1:30080/sentinel` 体验对应场景。
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112154213.png)
网关路由点赞服务的限流规则为 5而在前端通过异步处理模拟了 10 次并发请求。
因此可以看到 Sentinel 在 Gateway 侧针对多出的流量进行了服务熔断返回 fallback 给客户端,同时数据库的点赞数进行了更新(+5)。
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112036924.png)
- RocketMQ 进行流量削峰填谷
访问`http://127.0.0.1:30080/rocketmq` 体验对应场景。
由于我们之前在 Nacos 中配置了`integrated-consumer`消费者模块的消费速率以及间隔,在点击按钮时我们模拟 1000 个点赞请求,针对 1000 个点赞请求,`integrated_provider`
会将 1000 次请求都向 Broker 投递消息,而在消费者模块中会根据配置的消费速率进行消费,向数据库更新点赞的商品数据,模拟大流量下 RocketMQ 削峰填谷的特性。
可以看到数据库中点赞的个数正在动态更新。
![](https://my-img-1.oss-cn-hangzhou.aliyuncs.com/image-20221008112225839.png)
## 其他
本示例**仅是针对各个组件选取出了较为典型的功能特性来服务应用场景**
当然各个组件的功能特性不仅仅只包含最佳实践中演示的这些,如果您感兴趣或是想要深入了解,欢迎学习各个组件的独立 example 相关文档。
- Nacos Examples
- [nacos-config-example](../../nacos-example/nacos-config-example/readme-zh.md)
- [nacos-discovery-example](../../nacos-example/nacos-discovery-example/readme-zh.md)
- [Sentinel-Core-Example](../../sentinel-example/sentinel-core-example/readme-zh.md)
- [Seata Examples](../../seata-example/readme-zh.md)
- [RocketMQ Example](../../rocketmq-example/readme-zh.md)
Loading…
Cancel
Save