1- {{- if .Values.fusillade.enabled }}
1+ {{- define "control-layer.fusillade.deployment" -}}
2+ {{- $root := .root -}}
3+ {{- $fusillade := $root.Values.fusillade -}}
4+ {{- $config := .config | default dict -}}
5+ {{- $component := .component -}}
6+ {{- $suffix := .suffix -}}
7+ {{- $mode := .mode -}}
8+ {{- $image := get $config "image" | default dict -}}
9+ {{- $baseImage := $fusillade.image | default dict -}}
10+ {{- $database := mergeOverwrite (deepCopy ($fusillade.database | default dict)) (get $config "database" | default dict) -}}
11+ {{- $podAnnotations := mergeOverwrite (deepCopy ($fusillade.podAnnotations | default dict)) (get $config "podAnnotations" | default dict) -}}
12+ {{- $podLabels := mergeOverwrite (deepCopy ($fusillade.podLabels | default dict)) (get $config "podLabels" | default dict) -}}
213apiVersion : apps/v1
314kind : Deployment
415metadata :
5- name : {{ include "control-layer.fullname" . }}-fusillade
16+ name : {{ include "control-layer.fullname" $root }}{{ $suffix }}
617 labels :
7- {{- include "control-layer.fusillade.labels" . | nindent 4 }}
18+ {{- include "control-layer.fusillade.labelsFor" (dict "root" $root "component" $component) | nindent 4 }}
819spec :
9- replicas : {{ .Values. fusillade.replicaCount }}
20+ replicas : {{- if hasKey $config "replicaCount" }} {{ get $config "replicaCount" }}{{- else }} {{ $ fusillade.replicaCount }}{{- end }}
1021 selector :
1122 matchLabels :
12- {{- include "control-layer.fusillade.selectorLabels" . | nindent 6 }}
23+ {{- include "control-layer.fusillade.selectorLabelsFor" (dict "root" $root "component" $component) | nindent 6 }}
1324 template :
1425 metadata :
1526 annotations :
16- checksum/secret : {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
17- checksum/config : {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
18- {{- with .Values.fusillade. podAnnotations }}
27+ checksum/secret : {{ include (print $root .Template.BasePath "/secret.yaml") $root | sha256sum }}
28+ checksum/config : {{ include (print $root .Template.BasePath "/configmap.yaml") $root | sha256sum }}
29+ {{- with $ podAnnotations }}
1930 {{- toYaml . | nindent 8 }}
2031 {{- end }}
2132 labels :
22- {{- include "control-layer.fusillade.labels" . | nindent 8 }}
23- {{- with .Values.fusillade. podLabels }}
33+ {{- include "control-layer.fusillade.labelsFor" (dict "root" $root "component" $component) | nindent 8 }}
34+ {{- with $ podLabels }}
2435 {{- toYaml . | nindent 8 }}
2536 {{- end }}
2637 spec :
27- {{- with .Values.imagePullSecrets }}
38+ {{- with $root .Values.imagePullSecrets }}
2839 imagePullSecrets :
2940 {{- toYaml . | nindent 8 }}
3041 {{- end }}
31- serviceAccountName : {{ include "control-layer.serviceAccountName" . }}
32- {{- with (.Values. fusillade.podSecurityContext | default .Values.podSecurityContext) }}
42+ serviceAccountName : {{ include "control-layer.serviceAccountName" $root }}
43+ {{- with (get $config "podSecurityContext" | default $ fusillade.podSecurityContext | default $root .Values.podSecurityContext) }}
3344 securityContext :
3445 {{- toYaml . | nindent 8 }}
3546 {{- end }}
3647 containers :
3748 - name : fusillade
38- {{- with (.Values. fusillade.securityContext | default .Values.securityContext) }}
49+ {{- with (get $config "securityContext" | default $ fusillade.securityContext | default $root .Values.securityContext) }}
3950 securityContext :
4051 {{- toYaml . | nindent 12 }}
4152 {{- end }}
42- image : " {{ .Values.fusillade. image. repository | default .Values.image.repository }}:{{ .Values.fusillade. image. tag | default .Values.image.tag | default .Chart.AppVersion }}"
43- imagePullPolicy : {{ .Values.fusillade. image. pullPolicy | default .Values.image.pullPolicy }}
53+ image : " {{ get $ image " repository" | default (get $baseImage "repository") | default $root .Values.image.repository }}:{{ get $ image " tag" | default (get $baseImage "tag") | default $root .Values.image.tag | default $root .Chart.AppVersion }}"
54+ imagePullPolicy : {{ get $ image " pullPolicy" | default (get $baseImage "pullPolicy") | default $root .Values.image.pullPolicy }}
4455 ports :
4556 - name : http
46- containerPort : {{ .Values.service.port }}
57+ containerPort : {{ $root .Values.service.port }}
4758 protocol : TCP
4859 envFrom :
4960 - secretRef :
50- name : {{ include "control-layer.fullname" . }}-secret
61+ name : {{ include "control-layer.fullname" $root }}-secret
5162 env :
52- # Enable fusillade daemon on these pods
53- - name : DWCTL_BACKGROUND_SERVICES__BATCH_DAEMON__ENABLED
54- value : " always"
5563 {{- /* Database pool overrides for fusillade */}}
56- {{- with .Values.fusillade.database }}
57- {{- range $key, $value := .pool }}
64+ {{- range $key, $value := (get $database "pool" | default dict) }}
5865 - name : DWCTL_DATABASE__POOL__{{ $key | upper }}
5966 value : {{ $value | quote }}
6067 {{- end }}
61- {{- range $key, $value := . replica_pool }}
68+ {{- range $key, $value := (get $database " replica_pool" | default dict) }}
6269 - name : DWCTL_DATABASE__REPLICA_POOL__{{ $key | upper }}
6370 value : {{ $value | quote }}
6471 {{- end }}
65- {{- range $key, $value := . fusillade_pool }}
72+ {{- range $key, $value := (get $database " fusillade_pool" | default dict) }}
6673 - name : DWCTL_DATABASE__FUSILLADE__POOL__{{ $key | upper }}
6774 value : {{ $value | quote }}
6875 {{- end }}
69- {{- range $key, $value := . fusillade_replica_pool }}
76+ {{- range $key, $value := (get $database " fusillade_replica_pool" | default dict) }}
7077 - name : DWCTL_DATABASE__FUSILLADE__REPLICA_POOL__{{ $key | upper }}
7178 value : {{ $value | quote }}
7279 {{- end }}
73- {{- range $key, $value := . outlet_pool }}
80+ {{- range $key, $value := (get $database " outlet_pool" | default dict) }}
7481 - name : DWCTL_DATABASE__OUTLET__POOL__{{ $key | upper }}
7582 value : {{ $value | quote }}
7683 {{- end }}
77- {{- range $key, $value := . outlet_replica_pool }}
84+ {{- range $key, $value := (get $database " outlet_replica_pool" | default dict) }}
7885 - name : DWCTL_DATABASE__OUTLET__REPLICA_POOL__{{ $key | upper }}
7986 value : {{ $value | quote }}
8087 {{- end }}
88+ {{- if $root.Values.keystore.enabled }}
89+ {{- include "control-layer.keystoreEnv" $root | nindent 12 }}
8190 {{- end }}
82- {{- if .Values.keystore.enabled }}
83- {{- include "control-layer.keystoreEnv" . | nindent 12 }}
91+ {{- range $key, $value := $root.Values.env }}
92+ - name : {{ $key }}
93+ value : {{ $value | quote }}
8494 {{- end }}
85- {{- range $key, $value := .Values .env }}
95+ {{- range $key, $value := $fusillade .env }}
8696 - name : {{ $key }}
8797 value : {{ $value | quote }}
8898 {{- end }}
89- {{- range $key, $value := .Values.fusillade. env }}
99+ {{- range $key, $value := (get $config " env" | default dict) }}
90100 - name : {{ $key }}
91101 value : {{ $value | quote }}
92102 {{- end }}
93- {{- with .Values.fusillade.livenessProbe }}
103+ # Enable fusillade daemon on these pods
104+ - name : DWCTL_BACKGROUND_SERVICES__BATCH_DAEMON__ENABLED
105+ value : " always"
106+ {{- if $mode }}
107+ - name : DWCTL_BACKGROUND_SERVICES__BATCH_DAEMON__MODE
108+ value : {{ $mode | quote }}
109+ {{- end }}
110+ {{- with (get $config "livenessProbe" | default $fusillade.livenessProbe) }}
94111 livenessProbe :
95112 {{- toYaml . | nindent 12 }}
96113 {{- end }}
97- {{- with .Values. fusillade.readinessProbe }}
114+ {{- with (get $config "readinessProbe" | default $ fusillade.readinessProbe) }}
98115 readinessProbe :
99116 {{- toYaml . | nindent 12 }}
100117 {{- end }}
101- {{- with .Values. fusillade.startupProbe }}
118+ {{- with (get $config "startupProbe" | default $ fusillade.startupProbe) }}
102119 startupProbe :
103120 {{- toYaml . | nindent 12 }}
104121 {{- end }}
105- {{- with (.Values. fusillade.resources | default .Values.resources) }}
122+ {{- with (get $config "resources" | default $ fusillade.resources | default $root .Values.resources) }}
106123 resources :
107124 {{- toYaml . | nindent 12 }}
108125 {{- end }}
@@ -111,32 +128,63 @@ spec:
111128 mountPath : /app/config.yaml
112129 subPath : control-layer-config.yaml
113130 readOnly : true
114- {{- with .Values. fusillade.volumeMounts }}
131+ {{- with $ fusillade.volumeMounts }}
115132 {{- toYaml . | nindent 12 }}
116133 {{- end }}
117- {{- with .Values.volumeMounts }}
134+ {{- with (get $config "volumeMounts" | default list) }}
135+ {{- toYaml . | nindent 12 }}
136+ {{- end }}
137+ {{- with $root.Values.volumeMounts }}
118138 {{- toYaml . | nindent 12 }}
119139 {{- end }}
120140 volumes :
121141 - name : config
122142 configMap :
123- name : {{ include "control-layer.fullname" . }}-config
124- {{- with .Values. fusillade.volumes }}
143+ name : {{ include "control-layer.fullname" $root }}-config
144+ {{- with $ fusillade.volumes }}
125145 {{- toYaml . | nindent 8 }}
126146 {{- end }}
127- {{- with .Values. volumes }}
147+ {{- with (get $config " volumes" | default list) }}
128148 {{- toYaml . | nindent 8 }}
129149 {{- end }}
130- {{- with (.Values.fusillade.nodeSelector | default .Values.nodeSelector) }}
150+ {{- with $root.Values.volumes }}
151+ {{- toYaml . | nindent 8 }}
152+ {{- end }}
153+ {{- with (get $config "nodeSelector" | default $fusillade.nodeSelector | default $root.Values.nodeSelector) }}
131154 nodeSelector :
132155 {{- toYaml . | nindent 8 }}
133156 {{- end }}
134- {{- with (.Values. fusillade.affinity | default .Values.affinity) }}
157+ {{- with (get $config "affinity" | default $ fusillade.affinity | default $root .Values.affinity) }}
135158 affinity :
136159 {{- toYaml . | nindent 8 }}
137160 {{- end }}
138- {{- with (.Values. fusillade.tolerations | default .Values.tolerations) }}
161+ {{- with (get $config "tolerations" | default $ fusillade.tolerations | default $root .Values.tolerations) }}
139162 tolerations :
140163 {{- toYaml . | nindent 8 }}
141164 {{- end }}
165+ {{- end -}}
166+
167+ {{- if .Values.fusillade.enabled }}
168+ {{- $split := .Values.fusillade.split | default dict -}}
169+ {{- if $split.enabled }}
170+ {{- $request := $split.request | default dict -}}
171+ {{- $batch := $split.batch | default dict -}}
172+ {{- $requestEnabled := true -}}
173+ {{- $batchEnabled := true -}}
174+ {{- if hasKey $request "enabled" }}{{- $requestEnabled = $request.enabled -}}{{- end -}}
175+ {{- if hasKey $batch "enabled" }}{{- $batchEnabled = $batch.enabled -}}{{- end -}}
176+ {{- $rendered := false -}}
177+ {{- if $requestEnabled }}
178+ {{- include "control-layer.fusillade.deployment" (dict "root" . "suffix" "-fusillade-request" "component" "fusillade-request" "mode" "request_only" "config" $request) }}
179+ {{- $rendered = true -}}
180+ {{- end }}
181+ {{- if $batchEnabled }}
182+ {{- if $rendered }}
183+ ---
184+ {{- end }}
185+ {{- include "control-layer.fusillade.deployment" (dict "root" . "suffix" "-fusillade-batch" "component" "fusillade-batch" "mode" "batch_only" "config" $batch) }}
186+ {{- end }}
187+ {{- else }}
188+ {{- include "control-layer.fusillade.deployment" (dict "root" . "suffix" "-fusillade" "component" "fusillade" "mode" (.Values.fusillade.mode | default "") "config" dict) }}
189+ {{- end }}
142190{{- end }}
0 commit comments