1+ {{- if and .Values.multiRegion.enabled (eq .Values.multiRegion.dataSource "") -}}
2+ {{ fail "multiRegion.dataSource must be set when multiRegion.enabled is true" }}
3+ {{- end }}
4+ {{- if and .Values.multiRegion.enabled (eq .Values.multiRegion.host "") -}}
5+ {{ fail "multiRegion.host must be set when multiRegion.enabled is true" }}
6+ {{- end }}
17apiVersion : apps/v1
28kind : Deployment
39metadata :
5561 - name : loft-data
5662 emptyDir : {}
5763 {{- end }}
58- {{- if .Values.additionalCA }}
64+ {{- if and .Values.additionalCA (not .Values.insecureSkipVerify) }}
5965 - name : loft-additional-ca
6066 secret :
6167 secretName : loft-additional-ca
6571 {{- if .Values.agentOnly }}
6672 command : ["loft", "agent"]
6773 {{- end }}
68- image : {{ default (include "loft.image" .) .Values.image }}
74+ image : {{ include "loft.image" . }}
75+ {{- if .Values.imagePullPolicy }}
76+ imagePullPolicy : {{ .Values.imagePullPolicy }}
77+ {{- end }}
6978 ports :
7079 - name : http
7180 containerPort : 8080
@@ -98,19 +107,35 @@ spec:
98107 {{- end }}
99108 {{- end }}
100109 env :
110+ {{- if not .Values.admin.create }}
111+ - name : ADMIN_SKIP_CREATE
112+ value : " true"
113+ {{- end }}
101114 - name : ADMIN_EMAIL
102115 value : {{ .Values.admin.email | quote }}
103116 - name : CHART_VERSION
104117 value : {{ .Chart.Version }}
105118 {{- if .Values.admin.password }}
119+ {{- if hasPrefix "$" .Values.admin.password }}
120+ - name : ADMIN_PASSWORD_ENV
121+ value : {{ .Values.admin.password }}
122+ {{- else }}
106123 - name : ADMIN_PASSWORD_HASH
107124 value : {{ .Values.admin.password | sha256sum | quote }}
108125 {{- end }}
126+ {{- end }}
127+ {{- if .Values.admin.username }}
128+ - name : ADMIN_USERNAME
129+ value : {{ .Values.admin.username | quote }}
130+ {{- end }}
109131 {{- if (gt (int .Values.replicaCount) 1) }}
110132 {{- if not (and .Values.env .Values.env.LEADER_ELECTION_ENABLED) }}
111133 - name : LEADER_ELECTION_ENABLED
112134 value : " true"
113135 {{- end }}
136+ {{- else if .Values.multiRegion.enabled }}
137+ - name : LEADER_ELECTION_ENABLED
138+ value : " true"
114139 {{- end }}
115140 {{- range $key, $value := .Values.envValueFrom }}
116141 - name : {{ $key | quote }}
@@ -141,6 +166,36 @@ spec:
141166 - name : TS_DEBUG_TLS_DIAL_INSECURE_SKIP_VERIFY
142167 value : " true"
143168 {{- end }}
169+ {{- if not (hasKey .Values.env "LOFT_MANAGER_IMAGE") }}
170+ - name : LOFT_MANAGER_IMAGE
171+ value : {{ include "loft.image" . | quote }}
172+ {{- end }}
173+ {{- if .Values.multiRegion.enabled }}
174+ {{- if .Values.config.loftHost }}
175+ - name : LOFT_HOST
176+ value : {{ .Values.config.loftHost | quote }}
177+ {{- end }}
178+ - name : LOFT_MULTI_REGION_PLATFORM
179+ value : " true"
180+ - name : LOFT_MULTI_REGION_PLATFORM_HOST
181+ value : {{ .Values.multiRegion.host | quote }}
182+ - name : LOFT_EMBEDDED_K8S
183+ value : " true"
184+ - name : LOFT_EMBEDDED_K8S_DATA_SOURCE
185+ value : {{ .Values.multiRegion.dataSource | quote }}
186+ {{- if .Values.multiRegion.dataSourceIdentityProvider }}
187+ - name : LOFT_EMBEDDED_K8S_DATA_SOURCE_IDENTITY_PROVIDER
188+ value : {{ .Values.multiRegion.dataSourceIdentityProvider | quote }}
189+ {{- end }}
190+ {{- if (gt (int .Values.multiRegion.dataSourceMaxConnections) 1) }}
191+ - name : LOFT_EMBEDDED_K8S_MAX_DATABASE_CONNECTIONS
192+ value : {{ .Values.multiRegion.dataSourceMaxConnections | quote }}
193+ {{- end }}
194+ {{- if (gt (int .Values.multiRegion.dataSourceMaxIdleConnections) 1) }}
195+ - name : LOFT_EMBEDDED_K8S_MAX_IDLE_CONNECTIONS
196+ value : {{ .Values.multiRegion.dataSourceMaxIdleConnections | quote }}
197+ {{- end }}
198+ {{- end }}
144199 {{- range $key, $value := .Values.env }}
145200 - name : {{ $key | quote }}
146201 value : {{ $value | quote }}
@@ -151,7 +206,7 @@ spec:
151206 {{- end }}
152207 - mountPath : /var/lib/loft
153208 name : loft-data
154- {{- if .Values.additionalCA }}
209+ {{- if and .Values.additionalCA (not .Values.insecureSkipVerify) }}
155210 - name : loft-additional-ca
156211 mountPath : /etc/ssl/certs/loft-additional-ca.crt
157212 readOnly : true
@@ -164,25 +219,60 @@ spec:
164219 {{- if .Values.audit }}
165220 {{- if .Values.audit.enableSideCar }}
166221 - name : audit
167- image : " {{ .Values.audit.image }}"
222+ image : {{ include "loft.auditImage" . }}
168223 command : ["sh"]
169224 args : ["-c", "touch /var/lib/loft/audit.log && tail -F /var/lib/loft/audit.log"]
170225 volumeMounts :
171226 - mountPath : /var/lib/loft
172227 name : loft-data
228+ securityContext :
229+ {{- toYaml .Values.audit.securityContext | nindent 12 }}
173230 {{- end }}
174231 {{- end }}
175232 {{- if .Values.nodeSelector }}
176233 nodeSelector :
177234{{ toYaml .Values.nodeSelector | indent 8 }}
178235 {{- end }}
179- {{- if .Values.affinity }}
236+
237+ {{- $preferredSchedulingTerms := list -}}
238+ {{- if and .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances.enabled }}
239+ {{- range $index, $term := .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances.terms -}}
240+ {{- $preferredSchedulingTerms = append $preferredSchedulingTerms $term -}}
241+ {{- end }}
242+ {{- end }}
243+ {{- range $index, $term := .Values.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution -}}
244+ {{- $preferredSchedulingTerms = append $preferredSchedulingTerms $term -}}
245+ {{- end }}
246+ {{- if or .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution $preferredSchedulingTerms .Values.affinity.podAffinity .Values.affinity.podAntiAffinity }}
180247 affinity :
181- {{ toYaml .Values.affinity | indent 8 }}
248+ {{- if or .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution $preferredSchedulingTerms }}
249+ nodeAffinity :
250+ {{- if $preferredSchedulingTerms }}
251+ preferredDuringSchedulingIgnoredDuringExecution :
252+ {{ toYaml $preferredSchedulingTerms | indent 12 }}
253+ {{- end }}
254+ {{- if .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution }}
255+ requiredDuringSchedulingIgnoredDuringExecution :
256+ {{ toYaml .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution | indent 12 }}
257+ {{- end }}
258+ {{- end }}
259+ {{- if or .Values.affinity.podAffinity }}
260+ podAffinity :
261+ {{ toYaml .Values.affinity.podAffinity | indent 10 }}
262+ {{- end }}
263+ {{- if or .Values.affinity.podAntiAffinity }}
264+ podAntiAffinity :
265+ {{ toYaml .Values.affinity.podAntiAffinity | indent 10 }}
266+ {{- end }}
182267 {{- end }}
268+
183269 {{- if .Values.tolerations }}
184270 tolerations :
185271{{ toYaml .Values.tolerations | indent 8 }}
272+ {{- end }}
273+ {{- if .Values.hostAliases }}
274+ hostAliases :
275+ {{ toYaml .Values.hostAliases | indent 8 }}
186276 {{- end }}
187277 securityContext :
188278 {{- toYaml .Values.podSecurityContext | nindent 8 }}
0 commit comments