Helm部署
本文介绍使用 helm 来部署 Apache ShenYu 网关。
先决条件
工具
数据库
在阅读本文档前,你需要先阅读部署先决条件文档来完成部署
shenyu前的环境准备工作。
添加 Helm 仓库
helm repo add shenyu https://apache.github.io/shenyu-helm-chart
helm repo update
安装
说明
- 安装应用:默认同时安装 admin 与 bootstrap。
- 服务暴露:使用 NodePort 暴露服务,admin 默认端口为
31095, bootstrap 为31195。 - 数据库:目前支持 h2, MySQL, PostgreSQL, Oracle 作为数据库。默认使用 h2。
h2 作为数据库
运行以下命令,会在 shenyu namespace 下安装 admin 与 bootstrap ,并创建命名空间。
helm install shenyu shenyu/shenyu -n=shenyu --create-namespace
MySQL 作为数据库
修改以下命令并复制,执行:
helm install shenyu shenyu/shenyu -n=shenyu --create-namespace \
--set dataSource.active=mysql \
--set dataSource.mysql.ip=127.0.0.1 \
--set dataSource.mysql.port=3306 \
--set dataSource.mysql.username=root \
--set dataSource.mysql.password=123456
PostgreSQL 作为数据库(ShenYu 版本 > 2.5.0)
修改以下命令并复制,执行:
helm install shenyu shenyu/shenyu -n=shenyu --create-namespace \
--set dataSource.active=pg \
--set dataSource.pg.ip=127.0.0.1 \
--set dataSource.pg.port=5432 \
--set dataSource.pg.username=postgres \
--set dataSource.pg.password=123456
Oracle 作为数据库
修改以下命令并复制,执行:
helm install shenyu shenyu/shenyu -n=shenyu --create-namespace \
--set dataSource.active=oracle \
--set dataSource.oracle.ip=127.0.0.1 \
--set dataSource.oracle.port=1521 \
--set dataSource.oracle.serviceName=shenyu \
--set dataSource.oracle.username=root \
--set dataSource.oracle.password=123456
Q&A
1. 需要大量修改配置信息,如修改 application.yml ,如何安装
- 下载完整 values.yaml
- 最新 chart 版本:
helm show values shenyu/shenyu > values.yaml - 特定 chart 版本, 如
0.2.0:helm show values shenyu/shenyu --version=0.2.0 > values.yaml
- 修改 values.yaml 文件
- 更改相应配置,使用
-f values.yaml的格式执行helm install命令。 如:helm install shenyu shenyu/shenyu -n=shenyu --create-namespace -f values.yaml
2. 如何只安装 admin 或 bootstrap
- 只安装 admin: 在 helm 安装命令末尾加上
--set bootstrap.enabled=false - 只安装 bootstrap: 在 helm 安装命令末尾加上
--set admin.enabled=false
3. 如何安装旧版本 ShenYu
helm search repo shenyu -l
你会得到类似的输出:
NAME CHART VERSION APP VERSION DESCRIPTION
shenyu/shenyu 0.2.0 2.5.0 Helm Chart for deploying Apache ShenYu in Kubernetes
...
...
其中 APP_VERSION 是 ShenYu 的版本,CHART_VERSION 是 Helm Chart 的版本。
根据要安装的 ShenYu 版本来选择对应的 Chart 版本,在命令末尾加上 --version=CHART_VERSION 参数即可。例如:
helm install shenyu shenyu/shenyu -n=shenyu --version=0.2.0 --create-namespace