18
18
{{- toYaml . | nindent 8 }}
19
19
{{- end }}
20
20
labels :
21
- {{- include "scsctl.labels" . | nindent 8 }}
22
- {{- with .Values.podLabels }}
23
- {{- toYaml . | nindent 8 }}
24
- {{- end }}
21
+ {{- include "scsctl.selectorLabels" . | nindent 8 }}
25
22
spec :
26
23
{{- with .Values.imagePullSecrets }}
27
24
imagePullSecrets :
30
27
serviceAccountName : {{ include "scsctl.serviceAccountName" . }}
31
28
securityContext :
32
29
{{- 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 }}
33
53
containers :
34
54
- name : {{ .Chart.Name }}
35
55
securityContext :
@@ -40,24 +60,39 @@ spec:
40
60
- name : http
41
61
containerPort : {{ .Values.service.port }}
42
62
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
+
43
86
livenessProbe :
44
87
httpGet :
45
- path : /
88
+ path : /healthz
46
89
port : http
47
90
readinessProbe :
48
91
httpGet :
49
- path : /
92
+ path : /ready
50
93
port : http
51
94
resources :
52
95
{{- 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 }}
61
96
{{- with .Values.nodeSelector }}
62
97
nodeSelector :
63
98
{{- toYaml . | nindent 8 }}
0 commit comments