API网关-Apache shenyu配置与使用
功能
- 支持各种语言(http 协议),支持 Dubbo、 Spring Cloud、 gRPC、 Motan、 Sofa、 Tars 等协议。
- 插件化设计思想,插件热插拔,易扩展。
- 灵活的流量筛选,能满足各种流量控制。
- 内置丰富的插件支持,鉴权,限流,熔断,防火墙等等。
- 流量配置动态化,性能极高。
- 支持集群部署,支持 A/B Test,蓝绿发布。
脑图
模块
-
shenyu-admin : 插件和其他信息配置的管理后台
-
shenyu-bootstrap : 用于启动项目,用户可以参考
-
shenyu-client : 用户可以使用 Spring MVC,Dubbo,Spring Cloud 快速访问
-
shenyu-disruptor : 基于disruptor的封装
-
shenyu-register-center : shenyu-client提供各种rpc接入注册中心的支持
-
shenyu-common : 框架的通用类
-
shenyu-dist : 构建项目
-
shenyu-metrics : prometheus(普罗米修斯)实现的 metrics
-
shenyu-plugin : ShenYu 支持的插件集合
-
shenyu-spi : 定义 ShenYu spi
-
shenyu-spring-boot-starter : 支持 spring boot starter
-
shenyu-sync-data-center : 提供 ZooKeeper,HTTP,WebSocket,Nacos 的方式同步数据
-
shenyu-examples : RPC 示例项目
-
shenyu-web : 包括插件、请求路由和转发等的核心处理包
端口
9095 ui 页面
9195 api接口
docker-compsoe 部署
docker-compose.yml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#
version: "3"
services:
shenyu-bootstrap:
image: apache/shenyu-bootstrap:latest
container_name: shenyu-bootstrap
ports:
- "9195:9195"
volumes:
- ./shenyu-bootstrap/logs/:/opt/shenyu-bootstrap/logs
- ./shenyu-bootstrap/conf/:/opt/shenyu-bootstrap/conf
depends_on:
- shenyu-admin
environment:
- shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
healthcheck:
test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
timeout: 2s
retries: 30
shenyu-admin:
image: apache/shenyu-admin:latest
container_name: shenyu-admin
volumes:
- ./shenyu-admin/logs/:/opt/shenyu-admin/logs
- ./shenyu-admin/conf/:/opt/shenyu-admin/conf
ports:
- "9095:9095"
healthcheck:
test: [ "CMD-SHELL", "wget -q -O - http://shenyu-admin:9095/actuator/health | grep UP || exit 1" ]
timeout: 2s
retries: 30
配置
选择器配置
服务发现为需要代理的服务
配置规则
验证
访问 shenyu 9195 api接口可以下有返回的数据。
http://127.0.0.1:9195/
具体插件使用可查看官网。
本文来自博客园,作者:王竹笙,转载请注明原文链接:https://www.cnblogs.com/edeny/p/18600099