|
6 | 6 | x86Pkgs, |
7 | 7 | armPkgs, |
8 | 8 | curPkgs, |
9 | | - mkNCSI, |
10 | 9 | ... |
11 | 10 | }: |
12 | 11 | let |
|
85 | 84 | }; |
86 | 85 | config = |
87 | 86 | let |
88 | | - baseLabels = { |
| 87 | + labels = cfg.labels // { |
89 | 88 | "app.kubernetes.io/component" = "builder"; |
90 | 89 | }; |
| 90 | + matchLabels = cfg.matchLabels // labels; |
91 | 91 | in |
92 | 92 | lib.mkIf (cfg.enable && cfg.builders.enable) { |
93 | 93 | nix-csi.builders.nixConfig.settings.sandbox = cfg.builders.privilegedSandboxedBuilds; |
|
195 | 195 | n: v: |
196 | 196 | let |
197 | 197 | v2 = lib.recursiveUpdate v { |
198 | | - labels = baseLabels // { |
| 198 | + labels = labels // { |
199 | 199 | "kubernetes.io/arch" = v.arch; |
200 | 200 | "nix.csi/deployment" = n; |
201 | 201 | }; |
202 | 202 | }; |
203 | 203 | in |
204 | | - mkNCSI { |
| 204 | + { |
| 205 | + metadata.labels = v2.labels; |
205 | 206 | spec = { |
206 | 207 | replicas = v.replicas; |
207 | | - selector.matchLabels = v2.labels; |
| 208 | + selector.matchLabels = cfg.matchLabels // v2.labels; |
208 | 209 | template = podTemplate v2; |
209 | 210 | }; |
210 | 211 | } |
211 | 212 | ) (lib.filterAttrs (n: v: v.enable) cfg.builders.deployments)) |
212 | 213 | // { |
213 | | - proxy = lib.mkIf (cfg.builders.loadBalancerPort != null) { |
214 | | - spec = |
215 | | - let |
216 | | - labels = { |
217 | | - "app.kubernetes.io/component" = "proxy"; |
218 | | - }; |
219 | | - in |
220 | | - { |
| 214 | + proxy = lib.mkIf (cfg.builders.loadBalancerPort != null) ( |
| 215 | + let |
| 216 | + labels = cfg.labels // { |
| 217 | + "app.kubernetes.io/component" = "proxy"; |
| 218 | + }; |
| 219 | + in |
| 220 | + { |
| 221 | + metadata.labels = labels; |
| 222 | + spec = { |
221 | 223 | replicas = 1; |
222 | | - selector.matchLabels = labels; |
| 224 | + selector.matchLabels = cfg.matchLabels // labels; |
223 | 225 | template = { |
224 | 226 | metadata.labels = labels; |
225 | 227 | metadata.annotations = { |
|
279 | 281 | }; |
280 | 282 | }; |
281 | 283 | }; |
282 | | - }; |
| 284 | + } |
| 285 | + ); |
283 | 286 | }; |
284 | 287 |
|
285 | 288 | DaemonSet = lib.mapAttrs ( |
286 | 289 | n: v: |
287 | 290 | let |
288 | 291 | v2 = lib.recursiveUpdate v { |
289 | | - labels = baseLabels // { |
| 292 | + labels = labels // { |
290 | 293 | "kubernetes.io/arch" = v.arch; |
291 | 294 | "nix.csi/daemonset" = n; |
292 | 295 | }; |
293 | 296 | }; |
294 | 297 | in |
295 | | - mkNCSI { |
| 298 | + { |
| 299 | + metadata.labels = v2.labels; |
296 | 300 | spec = { |
297 | | - selector.matchLabels = v2.labels; |
| 301 | + selector.matchLabels = cfg.matchLabels // v2.labels; |
298 | 302 | template = lib.recursiveUpdate (podTemplate v2) { |
299 | 303 | spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms = [ |
300 | 304 | { |
|
312 | 316 | ) (lib.filterAttrs (n: v: v.enable) cfg.builders.daemonsets); |
313 | 317 |
|
314 | 318 | # Headless service for DNS discovery of individual builder pods |
315 | | - Service.nix-csi-builders = mkNCSI { |
| 319 | + Service.nix-csi-builders = { |
| 320 | + metadata.labels = labels; |
316 | 321 | spec = { |
317 | 322 | clusterIP = "None"; |
318 | | - selector = baseLabels; |
| 323 | + selector = matchLabels; |
319 | 324 | ports = lib.mkNamedList { |
320 | 325 | ssh.port = 22; |
321 | 326 | }; |
322 | 327 | }; |
323 | 328 | }; |
324 | 329 |
|
325 | | - Service.nix-proxy = |
326 | | - lib.mkIf (cfg.builders.enable && cfg.builders.loadBalancerPort != null) |
327 | | - (mkNCSI { |
328 | | - spec = { |
329 | | - selector = baseLabels // { |
330 | | - "nix.csi/proxy" = "true"; |
331 | | - }; |
332 | | - ports = lib.mkNamedList { |
333 | | - ssh = { |
334 | | - port = cfg.builders.loadBalancerPort; |
335 | | - targetPort = "ssh"; |
336 | | - }; |
337 | | - }; |
338 | | - type = "LoadBalancer"; |
| 330 | + Service.nix-proxy = lib.mkIf (cfg.builders.enable && cfg.builders.loadBalancerPort != null) { |
| 331 | + metadata.labels = labels; |
| 332 | + spec = { |
| 333 | + selector = matchLabels // { |
| 334 | + "nix.csi/proxy" = "true"; |
| 335 | + }; |
| 336 | + ports = lib.mkNamedList { |
| 337 | + ssh = { |
| 338 | + port = cfg.builders.loadBalancerPort; |
| 339 | + targetPort = "ssh"; |
339 | 340 | }; |
340 | | - }); |
| 341 | + }; |
| 342 | + type = "LoadBalancer"; |
| 343 | + }; |
| 344 | + }; |
341 | 345 | }; |
342 | 346 | }; |
343 | 347 | } |
0 commit comments