init job fix -4

This commit is contained in:
Vaibhav Pathak 2026-02-24 12:06:42 +05:30
parent 73eb35db36
commit 3b1918978a
5 changed files with 66 additions and 38 deletions

View File

@ -129,5 +129,5 @@ Get database secret name
Create JDBC connection string
*/}}
{{- define "hades.jdbcUrl" -}}
{{- printf "jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC&characterEncoding=utf8" (include "hades.databaseHost" .) (include "hades.databasePort" .) (include "hades.databaseName" .) }}
{{- printf "jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=latin1" (include "hades.databaseHost" .) (include "hades.databasePort" .) (include "hades.databaseName" .) }}
{{- end }}

View File

@ -0,0 +1,47 @@
{{- if .Values.config.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hades.fullname" . }}-hibernate
labels:
{{- include "hades.labels" . | nindent 4 }}
data:
hibernate.cfg.xml: |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings (dynamically resolved) -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">{{ include "hades.jdbcUrl" . | replace "&" "&amp;" }}</property>
<property name="connection.username">{{ include "hades.databaseUsername" . }}</property>
<property name="connection.password">{{ .Values.database.password | default .Values.mysql.mysqlPassword | default "local-mysql-pass" }}</property>
<!-- JDBC connection pool settings -->
<property name="connection.pool_size">{{ .Values.hibernate.connectionPoolSize | default 10 }}</property>
<!-- SQL dialect -->
<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>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">{{ .Values.hibernate.showSql | default "true" }}</property>
<property name="connection.isolation">2</property>
<property name="connection.autocommit">true</property>
<property name="use_keying_service">false</property>
<!-- C3P0 connection pool settings -->
<property name="c3p0.acquire_increment">10</property>
<property name="c3p0.idle_test_period">60</property>
<property name="c3p0.max_size">50</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">65</property>
<property name="hibernate.c3p0.maxConnectionAge">3600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
</session-factory>
</hibernate-configuration>
{{- end }}

View File

@ -20,6 +20,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/hibernate: {{ include (print $.Template.BasePath "/configmap-hibernate.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
@ -148,6 +149,10 @@ spec:
- name: config
mountPath: /etc/onlinesales/config/hades
readOnly: true
- name: hibernate-config
mountPath: /etc/onlinesales/config/hades/hibernate.cfg.xml
subPath: hibernate.cfg.xml
readOnly: true
{{- end }}
{{- if .Values.allhosts.enabled }}
- name: allhosts
@ -162,6 +167,9 @@ spec:
- name: config
configMap:
name: {{ include "hades.fullname" . }}-config
- name: hibernate-config
configMap:
name: {{ include "hades.fullname" . }}-hibernate
{{- end }}
{{- if .Values.allhosts.enabled }}
- name: allhosts

View File

@ -290,40 +290,7 @@ config:
}
}
hibernate.cfg.xml: |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://hades-mysql-db-service:3306/hades_db?useSSL=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;characterEncoding=latin1</property>
<property name="connection.username">hades_user</property>
<property name="connection.password">local-hades-pass</property>
<!-- JDBC connection pool settings -->
<property name="connection.pool_size">10</property>
<!-- SQL dialect -->
<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>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="connection.isolation">2</property>
<property name="connection.autocommit">true</property>
<property name="use_keying_service">false</property>
<property name="c3p0.acquire_increment">10</property>
<property name="c3p0.idle_test_period">60</property> <!-- seconds -->
<property name="c3p0.max_size">50</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">65</property> <!-- seconds -->
<property name="hibernate.c3p0.maxConnectionAge">3600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
</session-factory>
</hibernate-configuration>
# Hibernate configuration options (hibernate.cfg.xml is now generated dynamically)
hibernate:
connectionPoolSize: 10
showSql: "true"

View File

@ -182,6 +182,12 @@ config:
allhosts:
enabled: true
# Hibernate configuration options
# The hibernate.cfg.xml is generated dynamically from these values
hibernate:
connectionPoolSize: 10
showSql: "true"
nodeSelector: {}
tolerations: []