1818 {{- toYaml . | nindent 8 }}
1919 {{- end }}
2020 labels :
21- {{- include "scsctl.labels" . | nindent 8 }}
22- {{- with .Values.podLabels }}
23- {{- toYaml . | nindent 8 }}
24- {{- end }}
21+ {{- include "scsctl.selectorLabels" . | nindent 8 }}
2522 spec :
2623 {{- with .Values.imagePullSecrets }}
2724 imagePullSecrets :
3027 serviceAccountName : {{ include "scsctl.serviceAccountName" . }}
3128 securityContext :
3229 {{- toYaml .Values.podSecurityContext | nindent 8 }}
30+ initContainers :
31+ - name : create-postgres-datbase
32+ image : " docker.io/bitnami/postgresql:16.0.0-debian-11-r13"
33+ imagePullPolicy : Always
34+ command :
35+ - " /bin/sh"
36+ - " -c"
37+ - >
38+ echo "Creating database {{ .Values.postgresql.database }} if it does not exist..." &&
39+ psql -h {{ .Values.postgresql.host }} -p {{ .Values.postgresql.port }} -U {{ .Values.postgresql.username }} -lqt | cut -d \| -f 1 | grep -qw {{ .Values.postgresql.database }} || psql -h {{ .Values.postgresql.host }} -p {{ .Values.postgresql.port }} -U {{ .Values.postgresql.username }} -c "CREATE DATABASE {{ .Values.postgresql.database }};" &&
40+ echo "Database {{ .Values.postgresql.database }} created or already exists. Listing all databases:" &&
41+ psql -h {{ .Values.postgresql.host }} -p {{ .Values.postgresql.port }} -U {{ .Values.postgresql.username }} -l &&
42+ sleep 5
43+ env :
44+ - name : PGPASSWORD
45+ {{- if not .Values.postgresql.existingSecret }}
46+ value : " {{ .Values.postgresql.password }}"
47+ {{- else }}
48+ valueFrom :
49+ secretKeyRef :
50+ name : {{ .Values.postgresql.existingSecret.name }}
51+ key : {{ .Values.postgresql.existingSecret.passwordKey }}
52+ {{- end }}
3353 containers :
3454 - name : {{ .Chart.Name }}
3555 securityContext :
@@ -40,24 +60,39 @@ spec:
4060 - name : http
4161 containerPort : {{ .Values.service.port }}
4262 protocol : TCP
63+ args :
64+ - server
65+ env :
66+ - name : SCSCTL_PG_HOST
67+ value : " {{ .Values.postgresql.host }}"
68+ - name : SCSCTL_PG_PORT
69+ value : " {{ .Values.postgresql.port }}"
70+ - name : SCSCTL_PG_USER
71+ value : " {{ .Values.postgresql.username }}"
72+ - name : SCSCTL_PG_PASSWORD
73+ {{- if not .Values.postgresql.existingSecret }}
74+ value : " {{ .Values.postgresql.password }}"
75+ {{- else }}
76+ valueFrom :
77+ secretKeyRef :
78+ name : {{ .Values.postgresql.existingSecret.name }}
79+ key : {{ .Values.postgresql.existingSecret.passwordKey }}
80+ {{- end }}
81+ - name : SCSCTL_PG_DATABASE
82+ value : " {{ .Values.postgresql.database }}"
83+ - name : SCSCTL_ENVIRONMENT
84+ value : " {{ .Values.env.SCSCTL_ENVIRONMENT }}"
85+
4386 livenessProbe :
4487 httpGet :
45- path : /
88+ path : /healthz
4689 port : http
4790 readinessProbe :
4891 httpGet :
49- path : /
92+ path : /ready
5093 port : http
5194 resources :
5295 {{- toYaml .Values.resources | nindent 12 }}
53- {{- with .Values.volumeMounts }}
54- volumeMounts :
55- {{- toYaml . | nindent 12 }}
56- {{- end }}
57- {{- with .Values.volumes }}
58- volumes :
59- {{- toYaml . | nindent 8 }}
60- {{- end }}
6196 {{- with .Values.nodeSelector }}
6297 nodeSelector :
6398 {{- toYaml . | nindent 8 }}
0 commit comments