-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathvariables.tf
More file actions
843 lines (712 loc) · 20 KB
/
variables.tf
File metadata and controls
843 lines (712 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
variable "name" {
description = "Name of the Slurm cluster in k8s cluster."
type = string
}
variable "operator_version" {
description = "Version of the Soperator."
type = string
}
variable "operator_stable" {
description = "Whether to use stable version of the Soperator."
type = bool
default = true
}
variable "iam_tenant_id" {
description = "ID of the IAM tenant."
type = string
}
variable "iam_project_id" {
description = "ID of the IAM project."
type = string
}
variable "k8s_cluster_context" {
description = "Context name of the K8s cluster."
type = string
nullable = false
}
variable "k8s_cluster_id" {
description = "ID of the mk8s cluster."
type = string
}
# region PartitionConfiguration
variable "slurm_partition_config_type" {
description = "Type of the Slurm partition config. Could be either `default` or `custom`."
default = "default"
type = string
}
variable "slurm_partition_raw_config" {
description = "Partition config in case of `custom` slurm_partition_config_type. Each string must be started with `PartitionName`."
type = list(string)
default = []
}
# endregion PartitionConfiguration
# region HealthCheckConfig
variable "slurm_health_check_config" {
description = "Health check configuration."
type = object({
health_check_interval = number
health_check_program = string
health_check_node_state = list(object({
state = string
}))
})
nullable = true
default = null
}
# endregion HealthCheckConfig
# region Nodes
variable "node_count" {
description = "Count of Slurm nodes."
type = object({
controller = number
worker = list(number)
login = number
})
validation {
condition = var.node_count.controller == 1
error_message = "Only a single Slurm controller node is supported."
}
}
# endregion Nodes
# region Resources
variable "resources" {
description = "Resources of Slurm nodes."
type = object({
system = object({
cpu_cores = number
memory_gibibytes = number
ephemeral_storage_gibibytes = number
})
controller = object({
cpu_cores = number
memory_gibibytes = number
ephemeral_storage_gibibytes = number
})
worker = list(object({
cpu_cores = number
memory_gibibytes = number
ephemeral_storage_gibibytes = number
gpus = number
}))
login = object({
cpu_cores = number
memory_gibibytes = number
ephemeral_storage_gibibytes = number
})
accounting = optional(object({
cpu_cores = number
memory_gibibytes = number
ephemeral_storage_gibibytes = number
}))
nfs = optional(object({
cpu_cores = number
memory_gibibytes = number
}))
})
validation {
condition = length(var.resources.worker) > 0
error_message = "At least one worker node must be provided."
}
}
resource "terraform_data" "check_worker_nodesets" {
lifecycle {
precondition {
condition = length(var.node_count.worker) == length(var.resources.worker)
error_message = "Worker node set resources must accord to the worker node count."
}
}
}
# endregion Resources
# region Worker
variable "worker_sshd_config_map_ref_name" {
description = "Name of configmap with SSHD config, which runs in slurmd container."
type = string
default = ""
}
# endregion Worker
# region Login
variable "login_allocation_id" {
description = "ID of the VPC allocation used in case of `LoadBalancer` service type."
type = string
nullable = true
default = null
}
variable "login_public_ip" {
description = "Public or private ip for login node load balancer"
type = bool
default = true
}
variable "tailscale_enabled" {
description = "Whether to enable tailscale init container on login pod"
type = bool
default = false
}
variable "login_sshd_config_map_ref_name" {
description = "Name of configmap with SSHD config, which runs in slurmd container."
type = string
default = ""
}
variable "sssd_conf_secret_ref_name" {
description = "Name of Secret containing sssd.conf propagated to controller, login, and worker sssd containers."
type = string
default = ""
}
variable "sssd_ldap_ca_config_map_ref_name" {
description = "Name of ConfigMap containing LDAP CA certificates propagated to controller, login, and worker sssd containers."
type = string
default = ""
}
variable "sssd_enabled" {
description = "Whether to enable the SSSD sidecar on Slurm controller, login, and worker nodes."
type = bool
default = false
}
variable "login_ssh_root_public_keys" {
description = "Authorized keys accepted for connecting to Slurm login nodes via SSH as 'root' user."
type = list(string)
validation {
condition = length(var.login_ssh_root_public_keys) >= 1
error_message = "At least one SSH public key must be provided."
}
validation {
condition = alltrue([for k in var.login_ssh_root_public_keys : length(k) > 0])
error_message = "SSH public keys must not be empty strings."
}
}
# endregion Login
# region Exporter
variable "exporter_enabled" {
description = "Whether to enable Slurm metrics exporter."
type = bool
default = false
}
# endregion Exporter
# region REST API
variable "rest_enabled" {
description = "Whether to enable Slurm REST API."
type = bool
default = true
}
# endregion REST API
# endregion Nodes
# region Filestore
variable "filestores" {
description = "Filestores to be used in Slurm cluster."
type = object({
controller_spool = object({
size_gibibytes = number
device = string
})
jail = object({
size_gibibytes = number
device = string
})
jail_submounts = list(object({
name = string
size_gibibytes = number
device = string
mount_path = string
}))
accounting = optional(object({
size_gibibytes = number
device = string
}))
})
}
# endregion Filestore
# region Disks
variable "controller_state_on_filestore" {
description = "Whether to use filestore for controller node storage (when true) or PVC (when false)."
type = bool
default = false
}
variable "node_local_jail_submounts" {
description = "Node-local disks to be mounted inside jail."
type = list(object({
name = string
mount_path = string
size_gibibytes = number
disk_type = string
filesystem_type = string
storage_class_name = string
}))
nullable = false
default = []
}
variable "node_local_image_storage" {
description = "Node-local disk to store Docker/Enroot data."
type = object({
enabled = bool
spec = optional(object({
size_gibibytes = number
filesystem_type = string
storage_class_name = string
}))
})
nullable = false
default = {
enabled = false
}
}
# endregion Disks
# region nfs-server
variable "nfs" {
type = object({
enabled = bool
mount_path = optional(string, "/mnt/nfs")
path = optional(string)
host = optional(string)
})
default = {
enabled = false
}
validation {
condition = var.nfs.enabled ? var.nfs.path != null && var.nfs.host != null : true
error_message = "NFS path and host must be set."
}
}
variable "nfs_node_group_enabled" {
description = "Whether the NFS node group is enabled."
type = bool
default = false
}
variable "nfs_in_k8s" {
type = object({
enabled = bool
version = optional(string)
use_stable_repo = optional(bool, true)
size_gibibytes = optional(number)
storage_class = optional(string, "compute-csi-network-ssd-io-m3-ext4")
threads = optional(number)
})
default = {
enabled = false
}
validation {
condition = var.nfs_in_k8s.enabled ? var.nfs_in_k8s.version != null : true
error_message = "NFS version must be set."
}
validation {
condition = var.nfs_in_k8s.enabled ? var.nfs_in_k8s.size_gibibytes != null : true
error_message = "NFS size_gibibytes must be set."
}
validation {
condition = var.nfs_in_k8s.enabled ? var.nfs.enabled == false : true
error_message = "Only one of nfs or nfs_in_k8s should be set."
}
validation {
condition = (
(
var.nfs_in_k8s.enabled &&
var.nfs_in_k8s.storage_class == "compute-csi-network-ssd-io-m3-ext4" &&
var.nfs_in_k8s.size_gibibytes != null
)
?
(
var.nfs_in_k8s.size_gibibytes % 93 == 0 &&
var.nfs_in_k8s.size_gibibytes <= 262074
)
: true
)
error_message = "NFS size must be a multiple of 93 GiB and maximum value is 262074 GiB"
}
}
# endregion nfs-server
# region Config
variable "shared_memory_size_gibibytes" {
description = "Shared memory size for Slurm controller and worker nodes in GiB."
type = number
default = 64
}
# endregion Config
# region Telemetry
variable "telemetry_enabled" {
description = "Whether to enable telemetry."
type = bool
default = true
}
variable "dcgm_job_mapping_enabled" {
description = "Whether to enable HPC job mapping by installing a separate dcgm-exporter"
type = bool
default = true
}
variable "dcgm_job_map_dir" {
description = "Directory where HPC job mapping files are located"
type = string
default = "/var/run/nebius/slurm"
}
# endregion Telemetry
# region Accounting
variable "accounting_enabled" {
description = "Whether to enable accounting."
type = bool
default = true
}
variable "use_protected_secret" {
description = "If true, protected user secret MariaDB will not be deleted after the MariaDB CR is deleted."
type = bool
default = true
}
variable "slurmdbd_config" {
description = "Slurmdbd.conf configuration. See https://slurm.schedmd.com/slurmdbd.conf.html.Not all options are supported."
type = map(any)
default = {}
}
variable "slurm_accounting_config" {
description = "Slurm.conf accounting configuration. See https://slurm.schedmd.com/slurm.conf.html. Not all options are supported."
type = map(any)
default = {}
}
# endregion Accounting
# region Apparmor
variable "use_default_apparmor_profile" {
description = "Whether to use default AppArmor profile."
type = bool
default = true
}
# endregion Apparmor
# region Maintenance
variable "maintenance" {
description = "Whether to enable maintenance mode."
type = string
default = "none"
validation {
condition = contains(["downscaleAndDeletePopulateJail", "downscaleAndOverwritePopulateJail", "downscale", "none", "skipPopulateJail"], var.maintenance)
error_message = "The maintenance variable must be one of: downscaleAndDeletePopulateJail, downscaleAndOverwritePopulateJail, downscale, none, skipPopulateJail."
}
}
variable "maintenance_ignore_node_groups" {
description = "List of node groups that Soperator should ignore for maintenance events. Supported values: controller, nfs, system, login, accounting."
type = list(string)
default = ["controller", "nfs"]
validation {
condition = alltrue([
for group in var.maintenance_ignore_node_groups :
contains(["system", "controller", "login", "accounting", "nfs"], group)
])
error_message = "maintenance_ignore_node_groups must only contain: system, controller, login, accounting, nfs."
}
}
# endregion Maintenance
# region NodeConfigurator
variable "enable_node_configurator" {
description = "Defined whether it's need to deploy node configurator"
type = bool
default = true
}
variable "node_configurator_log_level" {
description = "Log level of node configurator"
type = string
default = "info"
}
# endregion NodeConfigurator
# region SoperatorChecks
variable "enable_soperator_checks" {
description = "Defined whether it's need to deploy soperator checks"
type = bool
default = true
}
# endregion SoperatorChecks
# region Monitoring
variable "cluster_name" {
description = "the cluster name to use for the monitoring"
type = string
}
variable "public_o11y_enabled" {
description = "Whether to enable public observability endpoints."
type = bool
default = true
}
variable "soperator_notifier" {
description = "Configuration of the Soperator Notifier (https://github.com/nebius/soperator/tree/main/helm/soperator-notifier)."
type = object({
enabled = bool
slack_webhook_url = optional(string)
})
default = {
enabled = false
}
nullable = false
}
variable "create_pvcs" {
description = "Whether to create PVCs. Uses emptyDir if false."
type = bool
default = true
}
variable "resources_vm_operator" {
description = "Resources for VictoriaMetrics Operator."
type = object({
memory = string
cpu = string
})
default = {
memory = "512Mi"
cpu = "250m"
}
}
variable "resources_vm_logs_server" {
type = object({
memory = string
cpu = string
size = string
})
default = {
memory = "2Gi"
cpu = "1000m"
size = "256Gi"
}
}
variable "resources_vm_single" {
type = object({
memory = string
cpu = string
size = string
gomaxprocs = number
})
default = {
memory = "24Gi"
cpu = "6000m"
size = "512Gi"
gomaxprocs = 6
}
}
variable "resources_vm_agent" {
type = object({
memory = string
cpu = string
})
default = {
memory = "10Gi"
cpu = "5000m"
}
}
variable "resources_events_collector" {
type = object({
memory = string
cpu = string
})
default = {
memory = "128Mi"
cpu = "100m"
}
}
variable "resources_logs_collector" {
type = object({
memory = string
cpu = string
})
default = {
memory = "200Mi"
cpu = "200m"
}
}
variable "resources_jail_logs_collector" {
type = object({
memory = string
cpu = string
})
default = {
memory = "1Gi"
cpu = "1000m"
}
}
# endregion Monitoring
# region SConfigController
variable "sconfigcontroller" {
description = "Configuration for the sConfigController"
type = object({
node = object({
k8s_node_filter_name = string
size = number
})
container = object({
image_pull_policy = string
resources = object({
cpu = number
memory = number
ephemeral_storage = number
})
})
})
default = {
node = {
k8s_node_filter_name = "system"
size = 2
}
container = {
image_pull_policy = "IfNotPresent"
resources = {
cpu = 250
memory = 256
ephemeral_storage = 500
}
}
}
}
# endregion SConfigController
# region fluxcd
variable "cert_manager_version" {
description = "The version of the cert-manager."
type = string
default = ""
}
variable "k8up_version" {
description = "The version of the k8up."
type = string
default = ""
}
variable "mariadb_operator_version" {
description = "The version of the mariadb operator."
type = string
default = "25.10.2"
}
variable "opentelemetry_collector_version" {
description = "The version of the opentelemetry operator."
type = string
default = ""
}
variable "prometheus_crds_version" {
description = "The version of the prometheus crds."
type = string
default = ""
}
variable "security_profiles_operator_version" {
description = "The version of the security profiles operator."
type = string
default = ""
}
variable "vmstack_version" {
description = "The version of the vmstack."
type = string
default = ""
}
variable "vmstack_crds_version" {
description = "The version of the vmstack."
type = string
default = ""
}
variable "vmlogs_version" {
description = "The version of the vmlogs."
type = string
default = ""
}
variable "flux_namespace" {
description = "Kubernetes namespace to look for jail in."
type = string
}
# endregion fluxcd
variable "backups_enabled" {
description = "Whether to enable backups."
type = bool
default = false
}
variable "backups_config" {
description = "Configuration for backups."
type = object({
secret_name = string
password = string
schedule = string
prune_schedule = string
retention = map(any)
storage = object({
bucket = string
endpoint = string
bucket_id = string
})
})
}
variable "region" {
description = "Region where the Slurm cluster is deployed."
type = string
default = "eu-north1"
}
variable "use_preinstalled_gpu_drivers" {
description = "Whether to use preinstalled GPU drivers."
type = bool
default = false
}
# region ActiveChecks
variable "active_checks_scope" {
type = string
description = "Scope of active health-checks. Defines what checks should run after the cluster is provisioned."
default = ""
validation {
condition = contains(["dev", "testing", "prod_quick", "prod_acceptance", "essential"], var.active_checks_scope)
error_message = "active_checks_scope should be one of: dev, testing, prod_quick, prod_acceptance, essential."
}
}
# endregion ActiveChecks
# region Nodesets
variable "worker_nodesets" {
type = list(object({
name = string
replicas = number
max_unavailable = string
features = list(string)
cpu_topology = map(number)
gres_name = optional(string)
gres_config = list(string)
create_partition = bool
ephemeral_nodes = optional(bool, false)
local_nvme = optional(object({
enabled = optional(bool, false)
mount_path = optional(string, "/mnt/local-nvme")
filesystem_type = optional(string, "ext4")
}), {})
}))
default = []
}
variable "slurm_nodesets_partitions" {
description = <<-EOT
Partition configuration for nodesets.
Users must not remove the "hidden" partition.
Users can modify the "main" partition, but should not remove it (there must be at least one default partition).
EOT
type = list(object({
name = string
is_all = optional(bool, false)
nodeset_refs = optional(list(string), [])
config = string
}))
default = []
validation {
condition = (
length(var.slurm_nodesets_partitions) == 0 ||
anytrue([for p in var.slurm_nodesets_partitions : (p.name == "hidden")])
)
error_message = "slurm_nodesets_partitions must include a partition named \"hidden\"."
}
validation {
condition = (
length(var.slurm_nodesets_partitions) == 0 ||
length([for p in var.slurm_nodesets_partitions : p if can(regex("Default=YES", p.config))]) == 1
)
error_message = "Exactly one partition in slurm_nodesets_partitions must have \"Default=YES\" in its config."
}
validation {
condition = alltrue([
for p in var.slurm_nodesets_partitions :
(p.is_all || length(p.nodeset_refs) > 0)
])
error_message = "Each partition must have either is_all = true or non-empty nodeset_refs."
}
validation {
condition = alltrue([
for p in var.slurm_nodesets_partitions :
!(p.is_all && length(p.nodeset_refs) > 0)
])
error_message = "A partition cannot have both is_all = true and non-empty nodeset_refs."
}
validation {
condition = (
length(distinct([for p in var.slurm_nodesets_partitions : p.name])) == length(var.slurm_nodesets_partitions)
)
error_message = "All partition names in slurm_nodesets_partitions must be unique."
}
}
# endregion Nodesets
variable "cuda_version" {
description = "CUDA version used for populate-jail image selection and active checks."
type = string
default = "12.9.0"
}