mysql issue fix
This commit is contained in:
parent
7c53e4bbaa
commit
0b54e0983d
@ -19,8 +19,7 @@ metadata:
|
||||
{
|
||||
"mysql": {
|
||||
"source": "os-schedules-argo-syncer",
|
||||
"helmParam": "externalDatabase.host",
|
||||
"serviceSuffix": "-mysql"
|
||||
"helmParam": "externalDatabase.mysqlRelease"
|
||||
}
|
||||
}
|
||||
tags:
|
||||
|
||||
@ -61,3 +61,24 @@ Create the name of the service account to use
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Get the effective database host
|
||||
Returns host if set, otherwise derives from mysqlRelease if set
|
||||
*/}}
|
||||
{{- define "schedulerservice.dbHost" -}}
|
||||
{{- if .Values.externalDatabase.host }}
|
||||
{{- .Values.externalDatabase.host }}
|
||||
{{- else if .Values.externalDatabase.mysqlRelease }}
|
||||
{{- printf "%s-mysql" .Values.externalDatabase.mysqlRelease }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Check if database config is enabled (host or mysqlRelease is set)
|
||||
*/}}
|
||||
{{- define "schedulerservice.dbEnabled" -}}
|
||||
{{- if or .Values.externalDatabase.host .Values.externalDatabase.mysqlRelease }}
|
||||
{{- true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@ -30,7 +30,8 @@ spec:
|
||||
serviceAccountName: {{ include "schedulerservice.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
{{- if .Values.externalDatabase.host }}
|
||||
{{- $dbHost := include "schedulerservice.dbHost" . }}
|
||||
{{- if $dbHost }}
|
||||
initContainers:
|
||||
- name: wait-for-mysql-init
|
||||
image: mysql:5.7
|
||||
@ -39,7 +40,7 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
echo "Waiting for MySQL to be fully initialized..."
|
||||
until mysql -h {{ .Values.externalDatabase.host }} -P {{ .Values.externalDatabase.port }} -u {{ .Values.externalDatabase.username }} -p${MYSQL_PASSWORD} -e "SELECT 1 FROM group_details LIMIT 1" {{ .Values.externalDatabase.database }} 2>/dev/null; do
|
||||
until mysql -h {{ $dbHost }} -P {{ .Values.externalDatabase.port }} -u {{ .Values.externalDatabase.username }} -p${MYSQL_PASSWORD} -e "SELECT 1 FROM group_details LIMIT 1" {{ .Values.externalDatabase.database }} 2>/dev/null; do
|
||||
echo "Waiting for database tables to be created..."
|
||||
sleep 5
|
||||
done
|
||||
@ -75,13 +76,13 @@ spec:
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- if or .Values.config.enabled .Values.externalDatabase.host }}
|
||||
{{- if or .Values.config.enabled $dbHost }}
|
||||
volumeMounts:
|
||||
{{- if .Values.config.enabled }}
|
||||
- name: config
|
||||
mountPath: {{ .Values.config.mountPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.externalDatabase.host }}
|
||||
{{- if $dbHost }}
|
||||
- name: db-config
|
||||
mountPath: /etc/onlinesales/db
|
||||
readOnly: true
|
||||
@ -91,14 +92,14 @@ spec:
|
||||
env:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.config.enabled .Values.externalDatabase.host }}
|
||||
{{- if or .Values.config.enabled $dbHost }}
|
||||
volumes:
|
||||
{{- if .Values.config.enabled }}
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ include "schedulerservice.fullname" . }}-config
|
||||
{{- end }}
|
||||
{{- if .Values.externalDatabase.host }}
|
||||
{{- if $dbHost }}
|
||||
- name: db-config
|
||||
secret:
|
||||
secretName: {{ include "schedulerservice.fullname" . }}-db-config
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
{{- if .Values.externalDatabase.host }}
|
||||
{{- $dbHost := include "schedulerservice.dbHost" . }}
|
||||
{{- if $dbHost }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
@ -16,7 +17,7 @@ stringData:
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
|
||||
<property name="connection.url">jdbc:mysql://{{ .Values.externalDatabase.host }}:{{ .Values.externalDatabase.port }}/{{ .Values.externalDatabase.database }}?useUnicode=true&characterEncoding=utf8</property>
|
||||
<property name="connection.url">jdbc:mysql://{{ $dbHost }}:{{ .Values.externalDatabase.port }}/{{ .Values.externalDatabase.database }}?useUnicode=true&characterEncoding=utf8</property>
|
||||
<property name="connection.username">{{ .Values.externalDatabase.username }}</property>
|
||||
<property name="connection.password">{{ .Values.externalDatabase.password }}</property>
|
||||
<property name="connection.pool_size">1</property>
|
||||
|
||||
@ -101,10 +101,11 @@ env:
|
||||
- name: LOG_LEVEL
|
||||
value: "DEBUG"
|
||||
|
||||
# External Database - auto-injected by Backstage from os-schedules-argo-syncer
|
||||
# Backstage resolves: {namespace}-os-schedules-argo-syncer-mysql
|
||||
# External Database - connects to os-schedules-argo-syncer's MySQL subchart
|
||||
# mysqlRelease auto-derives host as {mysqlRelease}-mysql
|
||||
externalDatabase:
|
||||
host: "" # Auto-injected by Backstage dependency system
|
||||
host: "" # Leave empty to use mysqlRelease-derived host
|
||||
mysqlRelease: "" # Set by Backstage: {namespace}-os-schedules-argo-syncer
|
||||
port: "3306"
|
||||
database: "os_scheduling_db"
|
||||
username: "scheduler_user"
|
||||
|
||||
@ -133,8 +133,10 @@ env: []
|
||||
# External Database configuration
|
||||
# MySQL is deployed as a shared dependency (not a subchart)
|
||||
# Set externalDatabase.host to connect to the shared MySQL instance
|
||||
# Or set externalDatabase.mysqlRelease to auto-derive host as {mysqlRelease}-mysql
|
||||
externalDatabase:
|
||||
host: ""
|
||||
mysqlRelease: "" # If set, derives host as {mysqlRelease}-mysql
|
||||
port: "3306"
|
||||
database: "os_scheduling_db"
|
||||
username: "scheduler_user"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user