From 973fc61ca3ec84ac36672dfc7f343d7f8f0d5b7f Mon Sep 17 00:00:00 2001 From: Bird Date: Thu, 3 Nov 2022 10:31:16 +0800 Subject: [PATCH] feat: support oracle (#21) Signed-off-by: Bird Signed-off-by: Bird --- README.md | 4 +-- charts/shenyu/Chart.yaml | 2 +- charts/shenyu/README.md | 4 +-- charts/shenyu/templates/ConfigMap.yaml | 6 ++-- .../templates/shenyu-admin-deployment.yaml | 33 ++++++++++--------- charts/shenyu/values.yaml | 5 ++- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 00c7532..ec42681 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ [Apache/ShenYu](https://shenyu.apache.org/docs/index/) is an asynchronous, high-performance, cross-language, responsive API gateway. -Helm installation documentation is available on the official website [Helm Deployment](https://shenyu.apache.org/docs/deployment/deployment-helm/). +Helm installation documentation is available on the official website [Helm Deployment](https://shenyu.apache.org/helm/index/). ## 简体中文 [Apache/ShenYu](https://shenyu.apache.org/zh/docs/index) 是一个异步的,高性能的,跨语言的,响应式的 API 网关。 -Helm 安装文档详见官网 [Helm 部署](https://shenyu.apache.org/zh/docs/deployment/deployment-helm)。 +Helm 安装文档详见官网 [Helm 部署](https://shenyu.apache.org/zh/helm/index)。 diff --git a/charts/shenyu/Chart.yaml b/charts/shenyu/Chart.yaml index 193ac4a..b6a33a7 100644 --- a/charts/shenyu/Chart.yaml +++ b/charts/shenyu/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: shenyu description: Helm Chart for deploying Apache ShenYu in Kubernetes type: application -version: 0.4.0 +version: 0.5.0 appVersion: "2.5.0" icon: https://shenyu.apache.org/img/logo.png maintainers: diff --git a/charts/shenyu/README.md b/charts/shenyu/README.md index 00c7532..ec42681 100644 --- a/charts/shenyu/README.md +++ b/charts/shenyu/README.md @@ -4,10 +4,10 @@ [Apache/ShenYu](https://shenyu.apache.org/docs/index/) is an asynchronous, high-performance, cross-language, responsive API gateway. -Helm installation documentation is available on the official website [Helm Deployment](https://shenyu.apache.org/docs/deployment/deployment-helm/). +Helm installation documentation is available on the official website [Helm Deployment](https://shenyu.apache.org/helm/index/). ## 简体中文 [Apache/ShenYu](https://shenyu.apache.org/zh/docs/index) 是一个异步的,高性能的,跨语言的,响应式的 API 网关。 -Helm 安装文档详见官网 [Helm 部署](https://shenyu.apache.org/zh/docs/deployment/deployment-helm)。 +Helm 安装文档详见官网 [Helm 部署](https://shenyu.apache.org/zh/helm/index)。 diff --git a/charts/shenyu/templates/ConfigMap.yaml b/charts/shenyu/templates/ConfigMap.yaml index e798d32..3c3766e 100644 --- a/charts/shenyu/templates/ConfigMap.yaml +++ b/charts/shenyu/templates/ConfigMap.yaml @@ -35,7 +35,7 @@ data: init_enable: {{ .Values.dataSource.initEnabled }} spring: datasource: - url: jdbc:mysql://{{ template "common.names.fullname" . }}-mysql.{{.Release.Namespace}}.svc.cluster.local:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull + url: jdbc:mysql://{{ template "common.names.fullname" . }}-mysql.{{.Release.Namespace}}.svc.cluster.local:3306/{{ required "" .Values.dataSource.mysql.database | default "shenyu" }}?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull username: {{ required ".dataSource.mysql.username is required" .Values.dataSource.mysql.username }} password: {{ required "`dataSource.mysql.password` is required" .Values.dataSource.mysql.password }} driver-class-name: {{ .Values.dataSource.mysql.driverClass }} @@ -49,7 +49,7 @@ data: spring: datasource: - url: jdbc:postgresql://{{ template "common.names.fullname" . }}-pg.{{.Release.Namespace}}.svc.cluster.local:5432/shenyu + url: jdbc:postgresql://{{ template "common.names.fullname" . }}-pg.{{.Release.Namespace}}.svc.cluster.local:5432/{{ .Values.dataSource.pg.database | default "shenyu" }} username: {{ required ".dataSource.pg.username is required" .Values.dataSource.pg.username }} password: {{ required "`dataSource.pg.password` is required" .Values.dataSource.pg.password }} driver-class-name: {{ .Values.dataSource.pg.driverClass }} @@ -66,7 +66,7 @@ data: spring: datasource: - url: jdbc:oracle:thin:@{{ template "common.names.fullname" . }}-oracle.{{.Release.Namespace}}.svc.cluster.local:1521/shenyu + url: jdbc:oracle:thin:@{{ template "common.names.fullname" . }}-oracle.{{.Release.Namespace}}.svc.cluster.local:1521/{{ .Values.dataSource.oracle.serviceName | default "shenyu" }} username: {{ required ".dataSource.oracle.username is required" .Values.dataSource.oracle.username }} password: {{ required "`dataSource.oracle.password` is required" .Values.dataSource.oracle.password }} driver-class-name: oracle.jdbc.OracleDriver diff --git a/charts/shenyu/templates/shenyu-admin-deployment.yaml b/charts/shenyu/templates/shenyu-admin-deployment.yaml index 2f793c3..d90ce27 100644 --- a/charts/shenyu/templates/shenyu-admin-deployment.yaml +++ b/charts/shenyu/templates/shenyu-admin-deployment.yaml @@ -24,57 +24,58 @@ spec: "app.kubernetes.io/instance": "{{ .Release.Name }}" spec: {{/* check if database type is valid */}} - {{- $dataSourceTypeValid := has .Values.dataSource.active (list "h2" "mysql" "pg") -}} - {{- if not $dataSourceTypeValid -}}{{- required "Invalid `.dataSource.active`. Must be one of h2, mysql, pg" "" -}}{{- end}} + {{- $dataSourceTypeValid := has .Values.dataSource.active (list "h2" "mysql" "pg" "oracle") -}} + {{- if not $dataSourceTypeValid -}}{{- required "Invalid `.dataSource.active`. Must be one of 'h2', 'mysql', 'pg', 'oracle'" -}}{{- end}} {{- if eq .Values.dataSource.active "mysql"}} {{- $mysqlConnectorVersion := (required "once `dataSource.active` is set to 'mysql', `dataSource.mysql.connectorVersion` should not be empty" .Values.dataSource.mysql.connectorVersion)}} + {{- $mysqlJarName := (print "mysql-connector-java-" $mysqlConnectorVersion ".jar") -}} initContainers: - name: download-mysql-jar image: busybox:1.35.0 command: - "sh" - "-c" - - "wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/{{$mysqlConnectorVersion}}/mysql-connector-java-{{$mysqlConnectorVersion}}.jar; - wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/{{$mysqlConnectorVersion}}/mysql-connector-java-{{$mysqlConnectorVersion}}.jar.md5; - if [ $(md5sum mysql-connector-java-{{$mysqlConnectorVersion}}.jar | cut -d ' ' -f1) = $(cat mysql-connector-java-{{$mysqlConnectorVersion}}.jar.md5) ]; + - "wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/{{$mysqlConnectorVersion}}/{{$mysqlJarName}}; + wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/{{$mysqlConnectorVersion}}/{{$mysqlJarName}}.md5; + if [ $(md5sum {{$mysqlJarName}} | cut -d ' ' -f1) = $(cat {{$mysqlJarName}}.md5) ]; then echo success; - else echo failed;exit 1;fi;mv /mysql-connector-java-{{$mysqlConnectorVersion}}.jar /opt/shenyu-admin/ext-lib/mysql-connector.jar" + else echo failed;exit 1;fi;mv /{{$mysqlJarName}} /opt/shenyu-admin/ext-lib/mysql-connector.jar" volumeMounts: - name: mysql-connector-volume mountPath: /opt/shenyu-admin/ext-lib {{- end }} {{- if eq .Values.dataSource.active "pg"}} {{- $pgConnectorVersion := (required "once `dataSource.active` is set to 'pg', `dataSource.pg.connectorVersion` should not be empty" .Values.dataSource.pg.connectorVersion)}} + {{- $pgJarName := (print "postgresql-" $pgConnectorVersion ".jar") -}} initContainers: - name: download-pg-jar image: busybox:1.35.0 command: - "sh" - "-c" - - "wget https://repo1.maven.org/maven2/org/postgresql/postgresql/{{$pgConnectorVersion}}/postgresql-{{$pgConnectorVersion}}.jar; - wget https://repo1.maven.org/maven2/org/postgresql/postgresql/{{$pgConnectorVersion}}/postgresql-{{$pgConnectorVersion}}.jar.md5; - if [ $(md5sum postgresql-{{$pgConnectorVersion}}.jar | cut -d ' ' -f1) = $(cat postgresql-{{$pgConnectorVersion}}.jar.md5) ]; + - "wget https://repo1.maven.org/maven2/org/postgresql/postgresql/{{$pgConnectorVersion}}/{{$pgJarName}}; + wget https://repo1.maven.org/maven2/org/postgresql/postgresql/{{$pgConnectorVersion}}/{{$pgJarName}}.md5; + if [ $(md5sum {{$pgJarName}} | cut -d ' ' -f1) = $(cat {{$pgJarName}}.md5) ]; then echo success; - else echo failed;exit 1;fi;mv /postgresql-{{$pgConnectorVersion}}.jar /opt/shenyu-admin/ext-lib/postgresql-connector.jar" + else echo failed;exit 1;fi;mv /{{$pgJarName}} /opt/shenyu-admin/ext-lib/postgresql-connector.jar" volumeMounts: - name: pg-connector-volume mountPath: /opt/shenyu-admin/ext-lib {{- end }} - # same as oracle {{- if eq .Values.dataSource.active "oracle"}} {{- $oracleConnectorVersion := (required "once `dataSource.active` is set to 'oracle', `dataSource.oracle.connectorVersion` should not be empty" .Values.dataSource.oracle.connectorVersion)}} + {{- $oracleJarName := (print "ojdbc8-" $oracleConnectorVersion ".jar") -}} initContainers: - name: download-oracle-jar image: busybox:1.35.0 command: - # fixme: oracle jdbc driver is not free, so we can't download it from maven central, we need to download it from oracle official website - "sh" - "-c" - - "wget https://repo1.maven.org/maven2/com/oracle/ojdbc/ojdbc8/{{$oracleConnectorVersion}}/ojdbc8-{{$oracleConnectorVersion}}.jar; - wget https://repo1.maven.org/maven2/com/oracle/ojdbc/ojdbc8/{{$oracleConnectorVersion}}/ojdbc8-{{$oracleConnectorVersion}}.jar.md5; - if [ $(md5sum ojdbc8-{{$oracleConnectorVersion}}.jar | cut -d ' ' -f1) = $(cat ojdbc8-{{$oracleConnectorVersion}}.jar.md5) ]; + - "wget https://repo1.maven.org/maven2/com/oracle/ojdbc/ojdbc8/{{$oracleConnectorVersion}}/{{$oracleJarName}}; + wget https://repo1.maven.org/maven2/com/oracle/ojdbc/ojdbc8/{{$oracleConnectorVersion}}/{{$oracleJarName}}.md5; + if [ $(md5sum {{$oracleJarName}} | cut -d ' ' -f1) = $(cat {{$oracleJarName}}.md5) ]; then echo success; - else echo failed;exit 1;fi;mv /ojdbc8-{{$oracleConnectorVersion}}.jar /opt/shenyu-admin/ext-lib/oracle-connector.jar" + else echo failed;exit 1;fi;mv /{{$oracleJarName}} /opt/shenyu-admin/ext-lib/oracle-connector.jar" volumeMounts: - name: oracle-connector-volume mountPath: /opt/shenyu-admin/ext-lib diff --git a/charts/shenyu/values.yaml b/charts/shenyu/values.yaml index d2dbcbd..9bf77cf 100644 --- a/charts/shenyu/values.yaml +++ b/charts/shenyu/values.yaml @@ -40,7 +40,7 @@ bootstrap: ################################################# dataSource: - # options: [h2, mysql, pg] + # options: [h2, mysql, pg, oracle] active: h2 # init database and tables initEnabled: true @@ -52,6 +52,7 @@ dataSource: port: 3306 username: root password: + database: shenyu # mysql driver class name # mysql5 : com.mysql.jdbc.Driver # mysql6-8 : com.mysql.cj.jdbc.Driver @@ -62,6 +63,7 @@ dataSource: port: 5432 username: postgres password: + database: shenyu # pg driver class name driverClass: org.postgresql.Driver connectorVersion: 42.5.0 @@ -70,6 +72,7 @@ dataSource: port: 1521 username: root password: + serviceName: shenyu # oracle driver class name driverClass: oracle.jdbc.OracleDriver connectorVersion: 19.3.0.0