Skip to content

Commit

Permalink
feat: remove svc/endpoint of datasource and use bare ip:port && use u…
Browse files Browse the repository at this point in the history
…rlOverride to fully custom jdbc url (#30)

* feat: remove svc/endpoint of datasource and use bare ip:port

Signed-off-by: Bird <aflybird0@gmail.com>

* feat: use urlOverride to fully custom jdbc url

Signed-off-by: Bird <aflybird0@gmail.com>

---------

Signed-off-by: Bird <aflybird0@gmail.com>
  • Loading branch information
aFlyBird0 authored Apr 16, 2023
1 parent fb03da7 commit 68ca7bc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 89 deletions.
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.6.0
version: 0.6.1
appVersion: "2.5.1"
icon: https://shenyu.apache.org/img/logo.png
maintainers:
Expand Down
8 changes: 4 additions & 4 deletions charts/shenyu/templates/ConfigMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ data:
init_enable: {{ .Values.dataSource.initEnabled }}
spring:
datasource:
url: jdbc:h2:mem:~/shenyu;DB_CLOSE_DELAY=-1;MODE=MySQL;
url: {{ template "shenyu.h2.url" . }}
username: {{ required ".dataSource.h2.username is required" .Values.dataSource.h2.username }}
password: {{ required ".dataSource.h2.password is required" .Values.dataSource.h2.password }}
driver-class-name: org.h2.Driver
Expand All @@ -38,7 +38,7 @@ data:
init_enable: {{ .Values.dataSource.initEnabled }}
spring:
datasource:
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
url: {{ template "shenyu.mysql.url" . }}
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 @@ -52,7 +52,7 @@ data:
spring:
datasource:
url: jdbc:postgresql://{{ template "common.names.fullname" . }}-pg.{{.Release.Namespace}}.svc.cluster.local:5432/{{ .Values.dataSource.pg.database | default "shenyu" }}
url: {{ template "shenyu.pg.url" . }}
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 @@ -69,7 +69,7 @@ data:
spring:
datasource:
url: jdbc:oracle:thin:@{{ template "common.names.fullname" . }}-oracle.{{.Release.Namespace}}.svc.cluster.local:1521/{{ .Values.dataSource.oracle.serviceName | default "shenyu" }}
url: {{ template "shenyu.oracle.url" . }}
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: 33 additions & 0 deletions charts/shenyu/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- define "shenyu.h2.url" }}
{{- .Values.dataSource.h2.url | default "jdbc:h2:mem:~/shenyu;DB_CLOSE_DELAY=-1;MODE=MySQL;" }}
{{- end -}}

{{- define "shenyu.mysql.url" -}}
{{- with .Values.dataSource.mysql -}}
{{- if .urlOverride -}}
{{- .urlOverride | quote -}}
{{- else -}}
jdbc:mysql://{{ required ".dataSource.mysql.ip is required" .ip }}:{{ .port }}/{{ required "" .database | default "shenyu" }}?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
{{- end }}
{{- end }}
{{- end -}}

{{- define "shenyu.pg.url" -}}
{{- with .Values.dataSource.pg -}}
{{- if .urlOverride -}}
{{- .urlOverride -}}
{{- else -}}
jdbc:postgresql://{{ .ip }}:{{ .port }}/{{ .database | default "shenyu" }}
{{- end }}
{{- end }}
{{- end -}}

{{- define "shenyu.oracle.url" -}}
{{- with .Values.dataSource.oracle -}}
{{- if .urlOverride -}}
{{- .urlOverride -}}
{{- else -}}
jdbc:oracle:thin:@{{ .ip }}:{{ .port }}/{{ .serviceName | default "shenyu" }}
{{- end }}
{{- end }}
{{- end -}}
84 changes: 0 additions & 84 deletions charts/shenyu/templates/shenyu-datasource.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions charts/shenyu/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ dataSource:
# init database and tables
initEnabled: true
h2:
# use custom datasource url, default is jdbc:h2:mem:~/shenyu;DB_CLOSE_DELAY=-1;MODE=MySQL;
url: ""
username: sa
password: sa
mysql:
# use custom datasource url and ignore other configs, the format is jdbc:mysql://xxxxxxx
urlOverride: ""
ip:
port: 3306
username: root
Expand All @@ -110,6 +114,8 @@ dataSource:
driverClass: com.mysql.cj.jdbc.Driver
connectorVersion: 8.0.23
pg:
# use custom datasource url and ignore other configs, the format is jdbc:postgresql://xxxxxxx
urlOverride: ""
ip:
port: 5432
username: postgres
Expand All @@ -119,6 +125,8 @@ dataSource:
driverClass: org.postgresql.Driver
connectorVersion: 42.5.0
oracle:
# use custom datasource url and ignore other configs, the format is jdbc:oracle:xxxxxx
urlOverride: ""
ip:
port: 1521
username: root
Expand Down

0 comments on commit 68ca7bc

Please sign in to comment.