diff --git a/helm/schedulerservice/templates/_helpers.tpl b/helm/schedulerservice/templates/_helpers.tpl index f77e21c..b9137c3 100644 --- a/helm/schedulerservice/templates/_helpers.tpl +++ b/helm/schedulerservice/templates/_helpers.tpl @@ -64,21 +64,14 @@ Create the name of the service account to use {{/* Get the effective database host -Returns host if set, otherwise derives from mysqlRelease if set +Priority: host > mysqlRelease > autoDerive (from namespace) */}} {{- 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 }} +{{- else if .Values.externalDatabase.autoDerive }} +{{- printf "%s-os-schedules-argo-syncer-mysql" .Release.Namespace }} {{- end }} {{- end }} diff --git a/helm/schedulerservice/templates/deployment.yaml b/helm/schedulerservice/templates/deployment.yaml index 31f9ef5..dc2231d 100644 --- a/helm/schedulerservice/templates/deployment.yaml +++ b/helm/schedulerservice/templates/deployment.yaml @@ -84,7 +84,8 @@ spec: {{- end }} {{- if $dbHost }} - name: db-config - mountPath: /etc/onlinesales/db + mountPath: /etc/onlinesales/config/schedulerService/hibernate.cfg.xml + subPath: hibernate.cfg.xml readOnly: true {{- end }} {{- end }} diff --git a/helm/schedulerservice/values-local.yaml b/helm/schedulerservice/values-local.yaml index fcef555..1478cb3 100644 --- a/helm/schedulerservice/values-local.yaml +++ b/helm/schedulerservice/values-local.yaml @@ -102,10 +102,11 @@ env: value: "DEBUG" # External Database - connects to os-schedules-argo-syncer's MySQL subchart -# mysqlRelease auto-derives host as {mysqlRelease}-mysql +# autoDerive: true will auto-derive host as {namespace}-os-schedules-argo-syncer-mysql externalDatabase: - host: "" # Leave empty to use mysqlRelease-derived host - mysqlRelease: "" # Set by Backstage: {namespace}-os-schedules-argo-syncer + host: "" # Leave empty to use auto-derived host + mysqlRelease: "" # Optional: set to override auto-derive + autoDerive: true # Auto-derive host from namespace: {namespace}-os-schedules-argo-syncer-mysql port: "3306" database: "os_scheduling_db" username: "scheduler_user" diff --git a/helm/schedulerservice/values.yaml b/helm/schedulerservice/values.yaml index 45809fb..7d0d795 100644 --- a/helm/schedulerservice/values.yaml +++ b/helm/schedulerservice/values.yaml @@ -132,11 +132,14 @@ env: [] # External Database configuration # MySQL is deployed as a shared dependency (not a subchart) -# Set externalDatabase.host to connect to the shared MySQL instance -# Or set externalDatabase.mysqlRelease to auto-derive host as {mysqlRelease}-mysql +# Options (in priority order): +# 1. host: explicit MySQL host +# 2. mysqlRelease: derives host as {mysqlRelease}-mysql +# 3. autoDerive: derives host as {namespace}-os-schedules-argo-syncer-mysql externalDatabase: host: "" - mysqlRelease: "" # If set, derives host as {mysqlRelease}-mysql + mysqlRelease: "" + autoDerive: false # Set to true to auto-derive host from namespace port: "3306" database: "os_scheduling_db" username: "scheduler_user"