2026-01-30 10:31:27 +05:30

119 lines
4.1 KiB
YAML

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 }}
{{- if .Values.externalDatabase.host }}
initContainers:
- name: wait-for-mysql-init
image: mysql:5.7
command:
- sh
- -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
echo "Waiting for database tables to be created..."
sleep 5
done
echo "MySQL is fully initialized!"
env:
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "schedulerservice.fullname" . }}-db-config
key: password
{{- end }}
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 }}
{{- if or .Values.config.enabled .Values.externalDatabase.host }}
volumeMounts:
{{- if .Values.config.enabled }}
- name: config
mountPath: {{ .Values.config.mountPath }}
{{- end }}
{{- if .Values.externalDatabase.host }}
- name: db-config
mountPath: /etc/onlinesales/db
readOnly: true
{{- end }}
{{- end }}
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or .Values.config.enabled .Values.externalDatabase.host }}
volumes:
{{- if .Values.config.enabled }}
- name: config
configMap:
name: {{ include "schedulerservice.fullname" . }}-config
{{- end }}
{{- if .Values.externalDatabase.host }}
- name: db-config
secret:
secretName: {{ include "schedulerservice.fullname" . }}-db-config
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}