-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[type:feat] complete h2 and mysql (#9)
* ci: make release ci work Signed-off-by: Bird <aflybird0@gmail.com> * feat: update chart template to complete h2 Signed-off-by: Bird <aflybird0@gmail.com> * feat: support mysql as data source Signed-off-by: Bird <aflybird0@gmail.com> * feat: remove pv and classStorage Signed-off-by: Bird <aflybird0@gmail.com> * fix: pvc name error Signed-off-by: Bird <aflybird0@gmail.com> * fix: configMap name error Signed-off-by: Bird <aflybird0@gmail.com> * fix: svc url error Signed-off-by: Bird <aflybird0@gmail.com> * fix: endpoints name error Signed-off-by: Bird <aflybird0@gmail.com> * feat: support separate installation of admin and bootstrap Signed-off-by: Bird <aflybird0@gmail.com> * doc: update README Signed-off-by: Bird <aflybird0@gmail.com> * feat: update datasource config Signed-off-by: Bird <aflybird0@gmail.com> * ci: switch into prod env Signed-off-by: Bird <aflybird0@gmail.com> * doc: update README Signed-off-by: Bird <aflybird0@gmail.com> * doc: update README Signed-off-by: Bird <aflybird0@gmail.com> * chore: reset chart version Signed-off-by: Bird <aflybird0@gmail.com> Signed-off-by: Bird <aflybird0@gmail.com>
- Loading branch information
Showing
19 changed files
with
470 additions
and
125 deletions.
There are no files selected for viewing
Submodule chart-releaser-action
added at
6d70e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,6 @@ name: Lint and Test Charts | |
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint-test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# shenyu-helm-chart | ||
# shenyu-helm-chart | ||
|
||
See [here](./charts/shenyu/README.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,139 @@ | ||
# shenyu-helm-chart | ||
|
||
Helm deployment documentation written for Apache/Shenyu | ||
Helm deployment documentation written for Apache/Shenyu. | ||
|
||
[English] [[简体中文]](#使用Helm安装ShenYu) | ||
|
||
[Apache/ShenYu](https://shenyu.apache.org/docs/index/) is an asynchronous, high-performance, cross-language, responsive API gateway. | ||
|
||
## Get Repo Info | ||
|
||
```shell | ||
helm repo add shenyu https://apache.github.io/shenyu-helm-chart | ||
helm repo update | ||
``` | ||
|
||
_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._ | ||
|
||
todo: complete English version | ||
|
||
--- | ||
|
||
## 使用Helm安装ShenYu | ||
[[English]](#shenyu-helm-chart) [简体中文] | ||
|
||
[Apache/ShenYu](https://shenyu.apache.org/zh/docs/index) 是一个异步的,高性能的,跨语言的,响应式的 API 网关。 | ||
|
||
## 添加 Helm 仓库 | ||
|
||
```shell | ||
helm repo add shenyu https://apache.github.io/shenyu-helm-chart | ||
helm repo update | ||
``` | ||
|
||
## 安装 | ||
* helm 安装方式目前支持 h2 与 MySQL 两种数据库。默认使用 h2。 | ||
* 默认同时安装 admin 与 bootstrap。 | ||
* 使用 NodePort 暴露服务,admin 默认端口为 31095, bootstrap 为 31195。 | ||
|
||
### h2 作为数据库 | ||
|
||
运行以下命令,会在 shenyu namespace 下安装 admin 与 bootstrap ,并创建命名空间。 | ||
|
||
```shell | ||
helm install shenyu shenyu/shenyu -n=shenyu --create-namespace | ||
``` | ||
|
||
### MySQL 作为数据库 | ||
|
||
MySQL 安装方式需要提前安装好 MySQ,并提前创建好 pv 以存放 connector。详见 [部署先决条件](https://shenyu.apache.org/zh/docs/deployment/deployment-before/)。 | ||
|
||
#### 1. 提前创建 pv | ||
|
||
可复制以下 yaml,至少**替换以下两处内容**: | ||
|
||
* `YOUR_K8S_NODE_NAME`:存放 MySQL connector 的 K8s 节点名称 | ||
* `YOUR_PATH_TO_STORE_MYSQL_CONNECTOR`:# 指定节点上的目录, 该目录下面需要包含 mysql-connector.jar | ||
|
||
```shell | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: shenyu-pv | ||
spec: | ||
capacity: | ||
storage: 1Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
persistentVolumeReclaimPolicy: Delete | ||
storageClassName: shenyu-local-storage | ||
local: | ||
path: YOUR_PATH_TO_STORE_MYSQL_CONNECTOR | ||
nodeAffinity: | ||
required: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: kubernetes.io/hostname | ||
operator: In | ||
values: | ||
- YOUR_K8S_NODE_NAME | ||
--- | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: shenyu-local-storage | ||
provisioner: kubernetes.io/no-provisioner | ||
volumeBindingMode: WaitForFirstConsumer | ||
``` | ||
|
||
修改并保存为 `shenyu-store.yaml`, 然后执行: | ||
|
||
```shell | ||
kubectl apply -f shenyu-store.yaml -n=shenyu | ||
``` | ||
|
||
#### 2. 安装 | ||
|
||
修改以下命令并复制,执行: | ||
|
||
其中,storageClass 和上面的 yaml 创建的 StorageClass 的 name 对应。 | ||
|
||
```shell | ||
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.password=123456 \ | ||
--set dataSource.mysql.storageClass=shenyu-local-storage | ||
``` | ||
|
||
## Q&A | ||
|
||
### 1. 如果只安装 admin 或 bootstrap | ||
|
||
* 只安装 admin: 在 helm 安装命令末尾加上 `--set bootstrap.enabled=false` | ||
* 只安装 bootstrap: 在 helm 安装命令末尾加上 `--set admin.enabled=false` | ||
|
||
### 2. 如何安装旧版本 ShenYu | ||
|
||
```shell | ||
helm search repo shenyu -l | ||
``` | ||
|
||
你会得到类似的输出: | ||
|
||
```shell | ||
NAME CHART VERSION APP VERSION DESCRIPTION | ||
shenyu/shenyu 2.4.3 2.4.3 Helm Chart for deploying Apache ShenYu in Kuber... | ||
... | ||
... | ||
``` | ||
其中 APP_VERSION 是 ShenYu 的版本,CHART_VERSION 是 helm chart 的版本。 | ||
根据要安装的 ShenYu 版本来选择对应的 Chart 版本,在命令末尾加上 `--version=CHART_VERSION` 参数即可。例如: | ||
```shell | ||
helm install shenyu shenyu/shenyu -n=shenyu --version=2.4.3 --create-namespace | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,86 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: shenyu-cm | ||
namespace: default | ||
namespace: {{.Release.Namespace}} | ||
name: {{ template "shenyu.fullname" . }}-configmap | ||
labels: | ||
"app.kubernetes.io/name": '{{ template "shenyu.name" . }}' | ||
"app.kubernetes.io/managed-by": "{{ .Release.Service }}" | ||
"app.kubernetes.io/component": "shenyu-configmap" | ||
"app.kubernetes.io/instance": "{{ .Release.Name }}" | ||
data: | ||
application-local.yml: | | ||
server: | ||
port: 9195 | ||
address: 0.0.0.0 | ||
port: 9195 | ||
address: 0.0.0.0 | ||
spring: | ||
main: | ||
allow-bean-definition-overriding: true | ||
application: | ||
name: shenyu-bootstrap | ||
profiles: | ||
active: {{ .Values.dataSource.active }} | ||
main: | ||
allow-bean-definition-overriding: true | ||
application: | ||
name: shenyu-bootstrap | ||
management: | ||
health: | ||
defaults: | ||
enabled: false | ||
health: | ||
defaults: | ||
enabled: false | ||
shenyu: | ||
local: | ||
enabled: true | ||
file: | ||
enabled: true | ||
cross: | ||
enabled: true | ||
dubbo: | ||
parameter: multi | ||
sync: | ||
websocket: | ||
urls: ws://shenyu-admin-svc.shenyu.svc.cluster.local:9095/websocket | ||
exclude: | ||
enabled: false | ||
paths: | ||
- /favicon.ico | ||
extPlugin: | ||
enabled: true | ||
threads: 1 | ||
scheduleTime: 300 | ||
scheduleDelay: 30 | ||
scheduler: | ||
enabled: false | ||
type: fixed | ||
threads: 16 | ||
local: | ||
enabled: true | ||
file: | ||
enabled: true | ||
cross: | ||
enabled: true | ||
dubbo: | ||
parameter: multi | ||
sync: | ||
websocket: | ||
urls: ws://{{ template "shenyu.fullname" . }}-admin.shenyu.svc.cluster.local:9095/websocket | ||
exclude: | ||
enabled: false | ||
paths: | ||
- /favicon.ico | ||
extPlugin: | ||
enabled: true | ||
threads: 1 | ||
scheduleTime: 300 | ||
scheduleDelay: 30 | ||
scheduler: | ||
enabled: false | ||
type: fixed | ||
threads: 16 | ||
logging: | ||
level: | ||
root: info | ||
org.springframework.boot: info | ||
org.apache.ibatis: info | ||
org.apache.shenyu.bonuspoint: info | ||
org.apache.shenyu.lottery: info | ||
org.apache.shenyu: info | ||
level: | ||
root: info | ||
org.springframework.boot: info | ||
org.apache.ibatis: info | ||
org.apache.shenyu.bonuspoint: info | ||
org.apache.shenyu.lottery: info | ||
org.apache.shenyu: info | ||
{{- if eq .Values.dataSource.active "h2" }} | ||
application-h2.yml: | | ||
shenyu: | ||
database: | ||
dialect: h2 | ||
init_script: "sql-script/h2/schema.sql" | ||
init_enable: {{ .Values.dataSource.initEnabled }} | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:~/shenyu;DB_CLOSE_DELAY=-1;MODE=MySQL; | ||
username: {{ .Values.dataSource.h2.username }} | ||
password: {{ .Values.dataSource.h2.password }} | ||
driver-class-name: org.h2.Driver | ||
{{- end }} | ||
{{- if eq .Values.dataSource.active "mysql" }} | ||
application-mysql.yml: | | ||
shenyu: | ||
database: | ||
dialect: mysql | ||
init_enable: {{ .Values.dataSource.initEnabled }} | ||
spring: | ||
datasource: | ||
url: jdbc:mysql://{{ template "shenyu.fullname" . }}-mysql.shenyu.svc.cluster.local:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false | ||
username: {{ .Values.dataSource.mysql.username }} | ||
password: {{ .Values.dataSource.mysql.password }} | ||
driver-class-name: {{ .Values.dataSource.mysql.driverClass }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- define "shenyu.name" -}} | ||
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
|
||
{{- define "shenyu.fullname" -}} | ||
{{- $name := .Chart.Name -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.