apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "schedulerservice.fullname" . }} labels: {{- include "schedulerservice.labels" . | nindent 4 }} spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} selector: matchLabels: {{- include "schedulerservice.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "schedulerservice.labels" . | nindent 8 }} {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "schedulerservice.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: # Generate hibernate.cfg.xml and wait for MySQL to be ready - name: init-db-config image: mysql:5.7 command: - sh - -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 < com.mysql.cj.jdbc.Driver jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DB}?useUnicode=true&characterEncoding=utf8 ${MYSQL_USER} ${MYSQL_PASSWORD} 1 org.hibernate.dialect.MySQLDialect thread org.hibernate.cache.NoCacheProvider false 2 true EOF echo "Waiting for MySQL to be fully initialized..." 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..." sleep 5 done echo "MySQL is fully initialized!" env: - name: MYSQL_PASSWORD value: {{ .Values.externalDatabase.password | quote }} volumeMounts: - name: db-config mountPath: /db-config containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.service.targetPort }} protocol: TCP {{- if .Values.livenessProbe }} livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} {{- end }} {{- if .Values.readinessProbe }} readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }} {{- end }} {{- if .Values.startupProbe }} startupProbe: {{- toYaml .Values.startupProbe | nindent 12 }} {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: {{- if .Values.config.enabled }} - name: config mountPath: {{ .Values.config.mountPath }} {{- end }} - name: db-config mountPath: /etc/onlinesales/db readOnly: true {{- with .Values.env }} env: {{- toYaml . | nindent 12 }} {{- end }} volumes: {{- if .Values.config.enabled }} - name: config configMap: name: {{ include "schedulerservice.fullname" . }}-config {{- end }} - name: db-config emptyDir: {} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }}