mysql issue fix 1
This commit is contained in:
parent
03d088b692
commit
f7c1ed5830
@ -30,17 +30,45 @@ spec:
|
|||||||
serviceAccountName: {{ include "schedulerservice.serviceAccountName" . }}
|
serviceAccountName: {{ include "schedulerservice.serviceAccountName" . }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||||
{{- $dbHost := include "schedulerservice.dbHost" . }}
|
|
||||||
{{- if $dbHost }}
|
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: wait-for-mysql-init
|
# Generate hibernate.cfg.xml and wait for MySQL to be ready
|
||||||
|
- name: init-db-config
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
|
# Derive MySQL host from namespace
|
||||||
|
MYSQL_HOST="{{ .Release.Namespace }}-os-schedules-argo-syncer-mysql"
|
||||||
|
MYSQL_PORT="{{ .Values.externalDatabase.port }}"
|
||||||
|
MYSQL_DB="{{ .Values.externalDatabase.database }}"
|
||||||
|
MYSQL_USER="{{ .Values.externalDatabase.username }}"
|
||||||
|
|
||||||
|
echo "Generating hibernate.cfg.xml..."
|
||||||
|
cat > /db-config/hibernate.cfg.xml <<EOF
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!DOCTYPE hibernate-configuration PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||||
|
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
||||||
|
<hibernate-configuration>
|
||||||
|
<session-factory>
|
||||||
|
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
|
||||||
|
<property name="connection.url">jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DB}?useUnicode=true&characterEncoding=utf8</property>
|
||||||
|
<property name="connection.username">${MYSQL_USER}</property>
|
||||||
|
<property name="connection.password">${MYSQL_PASSWORD}</property>
|
||||||
|
<property name="connection.pool_size">1</property>
|
||||||
|
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
|
||||||
|
<property name="current_session_context_class">thread</property>
|
||||||
|
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
|
||||||
|
<property name="show_sql">false</property>
|
||||||
|
<property name="connection.isolation">2</property>
|
||||||
|
<property name="connection.autocommit">true</property>
|
||||||
|
</session-factory>
|
||||||
|
</hibernate-configuration>
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "Waiting for MySQL to be fully initialized..."
|
echo "Waiting for MySQL to be fully initialized..."
|
||||||
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
|
until mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "SELECT 1 FROM group_details LIMIT 1" ${MYSQL_DB} 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
|
||||||
@ -49,9 +77,11 @@ spec:
|
|||||||
- name: MYSQL_PASSWORD
|
- name: MYSQL_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: {{ include "schedulerservice.fullname" . }}-db-config
|
name: {{ .Release.Namespace }}-os-schedules-argo-syncer-mysql
|
||||||
key: password
|
key: mysql-password
|
||||||
{{- end }}
|
volumeMounts:
|
||||||
|
- name: db-config
|
||||||
|
mountPath: /db-config
|
||||||
containers:
|
containers:
|
||||||
- name: {{ .Chart.Name }}
|
- name: {{ .Chart.Name }}
|
||||||
securityContext:
|
securityContext:
|
||||||
@ -76,36 +106,27 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources | nindent 12 }}
|
{{- toYaml .Values.resources | nindent 12 }}
|
||||||
{{- 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 $dbHost }}
|
|
||||||
- name: db-config
|
- name: db-config
|
||||||
mountPath: /etc/onlinesales/config/schedulerService/hibernate.cfg.xml
|
mountPath: /etc/onlinesales/config/schedulerService/hibernate.cfg.xml
|
||||||
subPath: hibernate.cfg.xml
|
subPath: hibernate.cfg.xml
|
||||||
readOnly: true
|
readOnly: true
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- with .Values.env }}
|
{{- with .Values.env }}
|
||||||
env:
|
env:
|
||||||
{{- toYaml . | nindent 12 }}
|
{{- toYaml . | nindent 12 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- 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 $dbHost }}
|
|
||||||
- name: db-config
|
- name: db-config
|
||||||
secret:
|
emptyDir: {}
|
||||||
secretName: {{ include "schedulerservice.fullname" . }}-db-config
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- with .Values.nodeSelector }}
|
{{- with .Values.nodeSelector }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
|
|||||||
@ -1,33 +0,0 @@
|
|||||||
{{- $dbHost := include "schedulerservice.dbHost" . }}
|
|
||||||
{{- if $dbHost }}
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: {{ include "schedulerservice.fullname" . }}-db-config
|
|
||||||
labels:
|
|
||||||
{{- include "schedulerservice.labels" . | nindent 4 }}
|
|
||||||
type: Opaque
|
|
||||||
stringData:
|
|
||||||
password: {{ .Values.externalDatabase.password | quote }}
|
|
||||||
hibernate.cfg.xml: |
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<!DOCTYPE hibernate-configuration PUBLIC
|
|
||||||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
|
||||||
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
|
||||||
<hibernate-configuration>
|
|
||||||
<session-factory>
|
|
||||||
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</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>
|
|
||||||
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
|
|
||||||
<property name="current_session_context_class">thread</property>
|
|
||||||
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
|
|
||||||
<property name="show_sql">false</property>
|
|
||||||
<!-- Transaction isolation 2 = READ_COMMITTED -->
|
|
||||||
<property name="connection.isolation">2</property>
|
|
||||||
<property name="connection.autocommit">true</property>
|
|
||||||
</session-factory>
|
|
||||||
</hibernate-configuration>
|
|
||||||
{{- end }}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user