11{{- if and (gt (int .Values.server.replicas) 1) (eq .Values.database.kind "sqlite") }}
22 {{- fail "unable to set more than 1 replica when using sqlite, please switch to postgres database for multiple replicas" }}
33{{- end }}
4+ {{- $tlsEnabled := or (not (empty (index .Values.tls.data "tls.key"))) .Values.tls.certManager.enabled }}
5+ {{- if and .Values.saml.enabled (not .Values.dashboard.enabled) }}
6+ {{- fail "saml.enabled=true requires dashboard.enabled=true" }}
7+ {{- end }}
8+ {{- if and .Values.saml.enabled .Values.dashboard.enabled (not (or .Values.saml.proxy.assets.existingSecret .Values.saml.proxy.assets.data)) }}
9+ {{- fail "saml.proxy.assets.existingSecret or saml.proxy.assets.data is required when saml.enabled=true" }}
10+ {{- end }}
411
512apiVersion : apps/v1
613kind : Deployment
1623 selector :
1724 matchLabels :
1825 app : mirrord-license-server
19- {{- if eq .Values.database.kind "sqlite" }}
26+ {{- if or ( eq .Values.database.kind "sqlite") .Values.database.migrateFromSqlite }}
2027 strategy :
2128 # This is needed, as the license server uses a ReadWriteOnce PVC.
2229 type : Recreate
@@ -49,10 +56,10 @@ spec:
4956 runAsGroup : 2000
5057 fsGroup : 2000
5158 {{/* Allow low port using ip_unprivileged_port_start */}}
52- {{- if lt (int .Values.server.port) 1024 -}}
59+ {{- if or ( lt (int .Values.server.port) 1024) (lt (int .Values.dashboard.port) 1024) -}}
5360 sysctls :
5461 - name : net.ipv4.ip_unprivileged_port_start
55- value : {{ .Values.server.port | quote}}
62+ value : {{ min (int .Values.server.port) (int .Values.dashboard.port) | quote}}
5663 {{- end }}
5764 {{- if .Values.server.tolerations }}
5865 tolerations :
6875 {{- end }}
6976
7077 containers :
78+ # License server container
7179 - args : ["license-server"]
7280 env :
7381 - name : RUST_LOG
8088 {{- else if eq .Values.database.kind "postgres" }}
8189 - name : DATABASE_TYPE
8290 value : " postgres"
91+ {{- if .Values.database.migrateFromSqlite }}
92+ - name : MIGRATE_DATABASE_URL
93+ value : sqlite:///opt/mirrord/data/license-server.db
94+ {{- end }}
8395 {{- if kindIs "string" .Values.database.host }}
8496 - name : PGHOST
8597 value : {{ .Values.database.host | quote }}
@@ -148,12 +160,27 @@ spec:
148160 {{- if .Values.dashboard.enabled }}
149161 - name : DASHBOARD_ENABLED
150162 value : " true"
151- - name : DASHBOARD_PORT
152- value : {{ .Values.dashboard.port | quote }}
163+ {{- end }}
164+ {{- if .Values.dashboard.enabled }}
165+ - name : DASHBOARD_ADDRESS
166+ {{- if .Values.saml.enabled }}
167+ # SAML proxy listens on the dashboard port on public IP.
168+ # License server listens on a different port on localhost.
169+ value : {{ printf "127.0.0.1:%d" (add (int .Values.dashboard.port) 1) | quote }}
170+ {{- else }}
171+ # There is no proxy.
172+ # License server listens on the dashboard port on public IP.
173+ value : {{ printf "0.0.0.0:%d" (int .Values.dashboard.port) | quote }}
174+ {{- end }}
175+ {{- if .Values.saml.enabled }}
176+ # SAML proxy terminates TLS and injects verified headers.
177+ - name : DASHBOARD_AUTH_PROXY
178+ value : " true"
179+ {{- end }}
153180 {{- end }}
154181 - name : ERROR_EVENTS_RETENTION_DAYS
155182 value : {{ .Values.server.retention.operatorErrors | quote }}
156- {{- if or (index .Values.tls.data "tls.key") .Values.tls.certManager.enabled }}
183+ {{- if $tlsEnabled }}
157184 - name : TLS_CERT_PATH
158185 value : /tls/tls.crt
159186 - name : TLS_KEY_PATH
@@ -182,21 +209,21 @@ spec:
182209 httpGet :
183210 path : /health
184211 port : {{ .Values.server.port }}
185- scheme : {{ or (index .Values.tls.data "tls.key") .Values.tls.certManager.enabled | ternary "HTTPS" "HTTP" | quote }}
212+ scheme : {{ $tlsEnabled | ternary "HTTPS" "HTTP" | quote }}
186213 periodSeconds : 5
187214 name : license-server
188215 ports :
189216 - containerPort : {{ .Values.server.port }}
190217 name : https
191- {{- if .Values.dashboard.enabled }}
218+ {{- if and .Values.dashboard.enabled (not .Values.saml.enabled) }}
192219 - containerPort : {{ .Values.dashboard.port }}
193220 name : dashboard
194221 {{- end }}
195222 readinessProbe :
196223 httpGet :
197224 path : /health
198225 port : {{ .Values.server.port }}
199- scheme : {{ or (index .Values.tls.data "tls.key") .Values.tls.certManager.enabled | ternary "HTTPS" "HTTP" | quote }}
226+ scheme : {{ $tlsEnabled | ternary "HTTPS" "HTTP" | quote }}
200227 periodSeconds : 5
201228 resources :
202229 requests :
@@ -210,7 +237,7 @@ spec:
210237 privileged : false
211238 readOnlyRootFilesystem : true
212239 volumeMounts :
213- {{- if or (index .Values.tls.data "tls.key") .Values.tls.certManager.enabled }}
240+ {{- if $tlsEnabled }}
214241 - mountPath : /tls
215242 name : tls-volume
216243 {{- end }}
@@ -220,15 +247,54 @@ spec:
220247 name : license-volume
221248 {{- end }}
222249 # needed for the license-server create sqlite database
223- {{- if eq .Values.database.kind "sqlite" }}
250+ {{- if or ( eq .Values.database.kind "sqlite") .Values.database.migrateFromSqlite }}
224251 - mountPath : /opt/mirrord/data
225252 name : data
226253 {{- end }}
227254 - mountPath : /tmp
228255 name : tmp
256+
257+ {{- if and .Values.saml.enabled .Values.dashboard.enabled }}
258+ # SAML proxy container
259+ - name : saml-proxy
260+ image : {{ .Values.saml.proxy.image }}:{{ .Values.saml.proxy.tag }}
261+ imagePullPolicy : {{ default "IfNotPresent" .Values.saml.proxy.imagePullPolicy }}
262+ {{- if .Values.saml.proxy.extraEnv }}
263+ env :
264+ {{- range $name, $value := .Values.saml.proxy.extraEnv }}
265+ - name : {{ $name }}
266+ value : {{ $value | quote }}
267+ {{- end }}
268+ {{- end }}
269+ ports :
270+ - containerPort : {{ .Values.dashboard.port }}
271+ name : dashboard
272+ resources :
273+ {{- toYaml .Values.saml.proxy.resources | nindent 10 }}
274+ securityContext :
275+ allowPrivilegeEscalation : false
276+ privileged : false
277+ readOnlyRootFilesystem : false
278+ volumeMounts :
279+ - mountPath : /usr/local/apache2/conf/httpd.conf
280+ name : saml-proxy-config
281+ subPath : httpd.conf
282+ {{- if or .Values.saml.proxy.assets.existingSecret .Values.saml.proxy.assets.data }}
283+ - mountPath : {{ .Values.saml.proxy.assets.mountPath }}
284+ name : saml-proxy-assets
285+ readOnly : true
286+ {{- end }}
287+ {{- if $tlsEnabled }}
288+ - mountPath : /tls
289+ name : tls-volume
290+ {{- end }}
291+ - mountPath : /tmp
292+ name : tmp
293+ {{- end }}
294+
229295 serviceAccountName : {{ .Values.sa.name }}
230296 volumes :
231- {{- if or (index .Values.tls.data "tls.key") .Values.tls.certManager.enabled }}
297+ {{- if $tlsEnabled }}
232298 - name : tls-volume
233299 secret :
234300 secretName : {{ .Values.tls.secret }}
@@ -239,10 +305,20 @@ spec:
239305 secret :
240306 secretName : {{ .Values.license.file.secret }}
241307 {{- end }}
242- {{- if eq .Values.database.kind "sqlite" }}
308+ {{- if or ( eq .Values.database.kind "sqlite") .Values.database.migrateFromSqlite }}
243309 - name : data
244310 persistentVolumeClaim :
245311 claimName : mirrord-license-server-pvc
246312 {{- end }}
313+ {{- if and .Values.saml.enabled .Values.dashboard.enabled }}
314+ - name : saml-proxy-config
315+ configMap :
316+ name : {{ include "mirrord-license-server.samlProxyConfigMapName" . }}
317+ {{- if or .Values.saml.proxy.assets.existingSecret .Values.saml.proxy.assets.data }}
318+ - name : saml-proxy-assets
319+ secret :
320+ secretName : {{ default (include "mirrord-license-server.samlProxyAssetsSecretName" .) .Values.saml.proxy.assets.existingSecret }}
321+ {{- end }}
322+ {{- end }}
247323 - emptyDir : {}
248324 name : tmp
0 commit comments