Skip to content

Commit

Permalink
feat: support oracle (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Bird <aflybird0@gmail.com>

Signed-off-by: Bird <aflybird0@gmail.com>
  • Loading branch information
aFlyBird0 authored Nov 3, 2022
1 parent 75065cf commit 973fc61
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion charts/shenyu/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions charts/shenyu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions charts/shenyu/templates/ConfigMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
33 changes: 17 additions & 16 deletions charts/shenyu/templates/shenyu-admin-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion charts/shenyu/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bootstrap:
#################################################

dataSource:
# options: [h2, mysql, pg]
# options: [h2, mysql, pg, oracle]
active: h2
# init database and tables
initEnabled: true
Expand All @@ -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
Expand All @@ -62,6 +63,7 @@ dataSource:
port: 5432
username: postgres
password:
database: shenyu
# pg driver class name
driverClass: org.postgresql.Driver
connectorVersion: 42.5.0
Expand All @@ -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
Expand Down

0 comments on commit 973fc61

Please sign in to comment.