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