diff --git a/helm/schedulerservice/templates/deployment.yaml b/helm/schedulerservice/templates/deployment.yaml index 71a829f..dd81eb3 100644 --- a/helm/schedulerservice/templates/deployment.yaml +++ b/helm/schedulerservice/templates/deployment.yaml @@ -32,18 +32,24 @@ spec: {{- toYaml .Values.podSecurityContext | nindent 8 }} {{- if .Values.externalDatabase.host }} initContainers: - - name: wait-for-mysql - image: busybox:1.36 + - name: wait-for-mysql-init + image: mysql:5.7 command: - sh - -c - | - echo "Waiting for MySQL at {{ .Values.externalDatabase.host }}:{{ .Values.externalDatabase.port }}..." - until nc -z {{ .Values.externalDatabase.host }} {{ .Values.externalDatabase.port }}; do - echo "MySQL not ready, waiting..." + 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 + echo "Waiting for database tables to be created..." sleep 5 done - echo "MySQL is available!" + echo "MySQL is fully initialized!" + env: + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "schedulerservice.fullname" . }}-db-config + key: password {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/helm/schedulerservice/templates/secret-db.yaml b/helm/schedulerservice/templates/secret-db.yaml index af70bb6..6da6318 100644 --- a/helm/schedulerservice/templates/secret-db.yaml +++ b/helm/schedulerservice/templates/secret-db.yaml @@ -7,6 +7,7 @@ metadata: {{- include "schedulerservice.labels" . | nindent 4 }} type: Opaque stringData: + password: {{ .Values.externalDatabase.password | quote }} hibernate.cfg.xml: |