Skip to content

Commit

Permalink
Merge pull request #2214 from wangyu096/issue_2213
Browse files Browse the repository at this point in the history
fix: db 账号没有 super 权限,导致 job-backup 微服务启动失败 #2213
  • Loading branch information
jsonwan authored Jul 11, 2023
2 parents 744707b + 47186ad commit dab5b71
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions support-files/kubernetes/charts/bk-job/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ apiVersion: v2
name: "bk-job"
description: The BK-JOB is a ops script management and execution system with the capability of dealing with multiple tasks simultaneously.
type: application
# release 的时候需要改为实际的版本号
version: {{CHART_VERSION}}
# release 的时候需要改为实际的版本号
appVersion: "{{APP_VERSION}}"

dependencies:
Expand Down
11 changes: 11 additions & 0 deletions support-files/kubernetes/charts/bk-job/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ Return the JDBC MySQL Driver Class
{{- printf "io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver" -}}
{{- end -}}

{{/*
Return the MariaDB jdbc connection url properties
*/}}
{{- define "job.mariadb.connection.properties" -}}
{{- if .Values.mariadb.enabled }}
{{- printf "%s" .Values.mariadb.connection.properties -}}
{{- else -}}
{{- printf "%s" .Values.externalMariaDB.connection.properties -}}
{{- end -}}
{{- end -}}

{{/*
Return the JDBC MySQL scheme
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
job-analysis:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_analysis?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_analysis{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
job-backup:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_backup?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_backup{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand All @@ -50,7 +50,7 @@ data:
job-execute-db:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&sessionVariables=binlog_format=statement
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand All @@ -65,7 +65,7 @@ data:
job-execute-archive:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
job-crontab:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down Expand Up @@ -116,7 +116,7 @@ data:
job:
crontab:
db:
url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ data:
job-execute:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_execute{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
job-file-gateway:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_file_gateway?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_file_gateway{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
job-manage:
driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_manage?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_manage{{ include "job.mariadb.connection.properties" . }}
username: {{ include "job.mariadb.username" . }}
{{ if .Values.externalMariaDB.existingPasswordSecret }}
password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }}
Expand Down
6 changes: 6 additions & 0 deletions support-files/kubernetes/charts/bk-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ mariadb:
grant all privileges on *.* to 'root'@'%' identified by 'job';
grant all privileges on *.* to 'job'@'%' identified by 'job';
flush privileges;
## JDBC Connection properties
connection:
properties: ?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull

## External MariaDB configuration
##
Expand All @@ -142,6 +145,9 @@ externalMariaDB:
## @param externalMariaDB.rootPassword Password for the MariaDB `root` user
##
rootPassword: ""
## JDBC Connection properties
connection:
properties: ?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull


## Redis chart configuration
Expand Down
4 changes: 2 additions & 2 deletions support-files/templates/#etc#job#job-backup#job-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spring:
job-execute-db:
driver-class-name: io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: jdbc:otel:mysql://__BK_JOB_EXECUTE_MYSQL_HOST__:__BK_JOB_EXECUTE_MYSQL_PORT__/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&sessionVariables=binlog_format=statement
jdbc-url: jdbc:otel:mysql://__BK_JOB_EXECUTE_MYSQL_HOST__:__BK_JOB_EXECUTE_MYSQL_PORT__/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
username: __BK_JOB_EXECUTE_MYSQL_USERNAME__
password: __BK_JOB_EXECUTE_MYSQL_PASSWORD__
maximum-pool-size: 10
Expand All @@ -42,7 +42,7 @@ spring:
#job-execute-archive:
#driver-class-name: io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
#type: com.zaxxer.hikari.HikariDataSource
#jdbc-url: jdbc:otel:mysql://__BK_JOB_EXECUTE_ARCHIVE_MYSQL_HOST__:__BK_JOB_EXECUTE_ARCHIVE_MYSQL_PORT__/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
#jdbc-url: jdbc:otel:mysql://__BK_JOB_EXECUTE_ARCHIVE_MYSQL_HOST__:__BK_JOB_EXECUTE_ARCHIVE_MYSQL_PORT__/job_execute?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#username: __BK_JOB_EXECUTE_ARCHIVE_MYSQL_USERNAME__
#password: __BK_JOB_EXECUTE_ARCHIVE_MYSQL_PASSWORD__
#maximum-pool-size: 10
Expand Down

0 comments on commit dab5b71

Please sign in to comment.