-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathvariables.tf
More file actions
1216 lines (1067 loc) · 32.7 KB
/
variables.tf
File metadata and controls
1216 lines (1067 loc) · 32.7 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
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# region Cloud
variable "region" {
description = "Region of the project."
type = string
nullable = false
}
resource "terraform_data" "check_region" {
lifecycle {
precondition {
condition = contains(module.resources.regions, var.region)
error_message = "Unknown region '${var.region}'. See https://docs.nebius.com/overview/regions"
}
}
}
variable "iam_token" {
description = "IAM token used for communicating with Nebius services."
type = string
nullable = false
sensitive = true
}
variable "iam_project_id" {
description = "ID of the IAM project."
type = string
nullable = false
validation {
condition = startswith(var.iam_project_id, "project-")
error_message = "ID of the IAM project must start with `project-`."
}
}
data "nebius_iam_v1_project" "this" {
id = var.iam_project_id
}
variable "iam_tenant_id" {
description = "ID of the IAM tenant."
type = string
nullable = false
validation {
condition = startswith(var.iam_tenant_id, "tenant-")
error_message = "ID of the IAM tenant must start with `tenant-`."
}
}
data "nebius_iam_v1_tenant" "this" {
id = var.iam_tenant_id
}
variable "o11y_iam_tenant_id" {
description = "ID of the IAM tenant for O11y."
type = string
nullable = false
validation {
condition = startswith(var.o11y_iam_tenant_id, "tenant-")
error_message = "ID of the IAM tenant must start with `tenant-`."
}
}
variable "o11y_profile" {
description = "Profile for nebius CLI for public o11y."
type = string
nullable = false
validation {
condition = (
(length(var.o11y_profile) >= 1 && var.public_o11y_enabled) ||
!var.public_o11y_enabled
)
error_message = "O11y profile must be not empty if public o11y enabled is true."
}
}
variable "production" {
type = bool
default = true
}
variable "iam_merge_request_url" {
type = string
default = ""
validation {
condition = (var.production && length(var.iam_merge_request_url) > 0) || !var.production
error_message = <<EOF
This variable must be set for PRODUCTION Soperator Pro clusters. Follow the installation guide and put IAM merge request URL here.
If you provision a NON-PRODUCTION cluster, set "production" variable to false.
EOF
}
}
variable "vpc_subnet_id" {
description = "ID of VPC subnet."
type = string
validation {
condition = startswith(var.vpc_subnet_id, "vpcsubnet-")
error_message = "The ID of the VPC subnet must start with `vpcsubnet-`."
}
}
data "nebius_vpc_v1_subnet" "this" {
id = var.vpc_subnet_id
}
variable "slurm_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 "company_name" {
description = "Name of the company. It is used for naming Slurm & K8s clusters."
type = string
validation {
condition = (
length(var.company_name) >= 1 &&
length(var.company_name) <= 32 &&
length(regexall("^[a-z][a-z\\d\\-]*[a-z\\d]+$", var.company_name)) == 1
)
error_message = <<EOF
The company name must:
- be 1 to 32 characters long
- start with a letter
- end with a letter or digit
- consist of letters, digits, or hyphens (-)
- contain only lowercase letters
EOF
}
}
# endregion Cloud
# region Infrastructure
# region Storage
variable "controller_state_on_filestore" {
description = "Whether to use Filestore for controller node boot disk (true = Filestore, false = PVC)."
type = bool
default = false
}
variable "filestore_controller_spool" {
description = "Shared filesystem to be used on controller nodes."
type = object({
existing = optional(object({
id = string
}))
spec = optional(object({
size_gibibytes = number
block_size_kibibytes = number
}))
})
nullable = false
validation {
condition = (
(var.filestore_controller_spool.existing != null && var.filestore_controller_spool.spec == null) ||
(var.filestore_controller_spool.existing == null && var.filestore_controller_spool.spec != null)
)
error_message = "One of `existing` or `spec` must be provided."
}
}
variable "filestore_jail" {
description = "Shared filesystem to be used on controller, worker, and login nodes."
type = object({
existing = optional(object({
id = string
}))
spec = optional(object({
size_gibibytes = number
block_size_kibibytes = number
}))
})
nullable = false
validation {
condition = (
(var.filestore_jail.existing != null && var.filestore_jail.spec == null) ||
(var.filestore_jail.existing == null && var.filestore_jail.spec != null)
)
error_message = "One of `existing` or `spec` must be provided."
}
}
data "nebius_compute_v1_filesystem" "existing_jail" {
count = var.filestore_jail.existing != null ? 1 : 0
id = var.filestore_jail.existing.id
}
locals {
filestore_jail_calculated_size_gibibytes = (var.filestore_jail.existing != null ?
data.nebius_compute_v1_filesystem.existing_jail[0].size_bytes / 1024 / 1024 / 1024 :
var.filestore_jail.spec.size_gibibytes)
}
variable "allow_empty_jail_submounts" {
description = "Flag for disabling validation for non-empty jail submounts."
type = bool
default = false
}
variable "filestore_jail_submounts" {
description = "Shared filesystems to be mounted inside jail."
type = list(object({
name = string
mount_path = string
existing = optional(object({
id = string
}))
spec = optional(object({
size_gibibytes = number
block_size_kibibytes = number
}))
}))
default = []
validation {
condition = length([
for sm in var.filestore_jail_submounts : true if
(sm.existing != null && sm.spec == null) ||
(sm.existing == null && sm.spec != null)
]) == length(var.filestore_jail_submounts)
error_message = "All submounts must have one of `existing` or `spec` provided."
}
validation {
condition = var.allow_empty_jail_submounts || length(var.filestore_jail_submounts) >= 1
error_message = "Creating clusters without jail submounts is not allowed."
}
}
variable "node_local_jail_submounts" {
description = "Node-local disks to be mounted inside jail on worker nodes."
type = list(object({
name = string
mount_path = string
size_gibibytes = number
disk_type = string
filesystem_type = string
}))
nullable = false
default = []
validation {
condition = alltrue([
for sm in var.node_local_jail_submounts : (
contains(
[
module.resources.disk_types.network_ssd,
module.resources.disk_types.network_ssd_non_replicated,
module.resources.disk_types.network_ssd_io_m3,
],
sm.disk_type
)
)])
error_message = "Disk type must be one of `NETWORK_SSD`, `NETWORK_SSD_NON_REPLICATED` or `NETWORK_SSD_IO_M3`. See https://docs.nebius.com/compute/storage/types#disks-types"
}
validation {
condition = alltrue([
for sm in var.node_local_jail_submounts : (
contains(
[
module.resources.filesystem_types.ext4,
module.resources.filesystem_types.xfs,
],
sm.filesystem_type
)
)])
error_message = "Filesystem type must be one of `ext4` or `xfs`."
}
}
variable "node_local_image_disk" {
description = "Whether to create extra NRD/IO M3 disks for storing Docker/Enroot images and container filesystems on each worker node."
type = object({
enabled = bool
spec = optional(object({
size_gibibytes = number
filesystem_type = string
disk_type = string
}))
})
default = {
enabled = false
}
validation {
condition = (var.node_local_image_disk.enabled
? var.node_local_image_disk.spec != null
: true
)
error_message = "Spec must be provided if enabled."
}
validation {
condition = (var.node_local_image_disk.spec == null
? true
: (contains(
[
module.resources.filesystem_types.ext4,
module.resources.filesystem_types.xfs,
],
var.node_local_image_disk.spec.filesystem_type
))
)
error_message = "Filesystem type must be one of `ext4` or `xfs`."
}
validation {
condition = (var.node_local_image_disk.spec == null
? true
: (contains(
[
module.resources.disk_types.network_ssd_non_replicated,
module.resources.disk_types.network_ssd_io_m3,
],
var.node_local_image_disk.spec.disk_type
))
)
error_message = "Local image disk type must be one of `NETWORK_SSD_NON_REPLICATED` or `NETWORK_SSD_IO_M3`. See https://docs.nebius.com/compute/storage/types#disks-types"
}
}
variable "filestore_accounting" {
description = "Shared filesystem to be used for accounting DB"
type = object({
existing = optional(object({
id = string
}))
spec = optional(object({
size_gibibytes = number
block_size_kibibytes = number
}))
})
default = null
nullable = true
validation {
condition = (var.filestore_accounting != null
? (
(var.filestore_accounting.existing != null && var.filestore_accounting.spec == null) ||
(var.filestore_accounting.existing == null && var.filestore_accounting.spec != null)
)
: true
)
error_message = "One of `existing` or `spec` must be provided."
}
}
# endregion Storage
# region nfs-server
variable "nfs" {
type = object({
enabled = bool
size_gibibytes = number
mount_path = optional(string, "/home")
resource = object({
platform = string
preset = string
})
public_ip = bool
})
default = {
enabled = false
size_gibibytes = 93
resource = {
platform = "cpu-d3"
preset = "32vcpu-128gb"
}
public_ip = false
}
validation {
condition = (var.nfs.enabled
? (
var.nfs.size_gibibytes % 93 == 0 &&
var.nfs.size_gibibytes <= 262074
)
: true
)
error_message = "NFS size must be a multiple of 93 GiB and maximum value is 262074 GiB"
}
}
resource "terraform_data" "check_nfs" {
depends_on = [
terraform_data.check_region,
]
lifecycle {
precondition {
condition = (var.nfs.enabled
? contains(module.resources.platforms, var.nfs.resource.platform)
: true
)
error_message = "Unsupported platform '${var.nfs.resource.platform}'."
}
precondition {
condition = (var.nfs.enabled
? contains(keys(module.resources.by_platform[var.nfs.resource.platform]), var.nfs.resource.preset)
: true
)
error_message = "Unsupported preset '${var.nfs.resource.preset}' for platform '${var.nfs.resource.platform}'."
}
precondition {
condition = (var.nfs.enabled
? contains(module.resources.platform_regions[var.nfs.resource.platform], var.region)
: true
)
error_message = "Unsupported platform '${var.nfs.resource.platform}' in region '${var.region}'. See https://docs.nebius.com/compute/virtual-machines/types"
}
}
}
variable "nfs_in_k8s" {
type = object({
enabled = bool
version = optional(string)
use_stable_repo = optional(bool, true)
size_gibibytes = optional(number)
disk_type = optional(string)
filesystem_type = optional(string)
threads = optional(number)
})
default = {
enabled = false
}
validation {
condition = (
!var.nfs_in_k8s.enabled
||
(
var.nfs_in_k8s.filesystem_type != null
&& var.nfs_in_k8s.disk_type != null
&& var.nfs_in_k8s.size_gibibytes != null
&& (
!contains(["NETWORK_SSD_IO_M3", "NETWORK_SSD_NON_REPLICATED"], var.nfs_in_k8s.disk_type)
|| (var.nfs_in_k8s.size_gibibytes % 93 == 0)
)
)
)
error_message = <<EOT
If NFS in K8s is enabled, filesystem_type, disk_type, and size_gibibytes must be set.
Additionally, if disk_type is NETWORK_SSD_IO_M3 or NETWORK_SSD_NON_REPLICATED, size_gibibytes must be a multiple of 93.
EOT
}
}
# endregion nfs-server
# region k8s
variable "k8s_version" {
description = "Version of the k8s to be used."
type = string
default = null
validation {
condition = var.k8s_version == null || can(regex("^[\\d]+\\.[\\d]+$", var.k8s_version))
error_message = "The k8s cluster version must be null or in format `<MAJOR>.<MINOR>`."
}
}
variable "platform_cuda_versions" {
description = "Per-platform CUDA versions consumed by Slurm/operator (e.g., 12.8.2). Keys are platform IDs (e.g., gpu-h100-sxm)."
type = map(string)
default = {
cpu-e2 = "12.9.0"
cpu-d3 = "12.9.0"
gpu-h100-sxm = "12.9.0"
gpu-h200-sxm = "12.9.0"
gpu-b200-sxm = "12.9.0"
gpu-b200-sxm-a = "12.9.0"
gpu-b300-sxm = "13.0.2"
}
}
variable "platform_driver_presets" {
description = "Per-platform GPU driver presets. Keys are platform IDs (e.g., gpu-h100-sxm); values are driver presets (e.g., cuda13.0)."
type = map(string)
default = {
cpu-e2 = "cuda12.8"
cpu-d3 = "cuda12.8"
gpu-h100-sxm = "cuda12.8"
gpu-h200-sxm = "cuda12.8"
gpu-b200-sxm = "cuda12.8"
gpu-b200-sxm-a = "cuda12.8"
gpu-b300-sxm = "cuda13.0"
}
}
variable "use_preinstalled_gpu_drivers" {
description = "Enable preinstalled mode for worker nodes."
type = bool
default = false
}
variable "nvidia_admin_conf_lines" {
description = "Lines to write to /etc/modprobe.d/nvidia_admin.conf via cloud-init (GPU workers only)."
type = list(string)
default = []
}
variable "k8s_cluster_node_ssh_access_users" {
description = "SSH user credentials for accessing k8s nodes."
type = list(object({
name = string
public_keys = list(string)
}))
nullable = false
default = []
}
variable "etcd_cluster_size" {
description = "Size of the etcd cluster."
type = number
default = 3
}
# endregion k8s
# endregion Infrastructure
# region Slurm
variable "slurm_operator_version" {
description = "Version of soperator."
type = string
nullable = false
}
variable "slurm_operator_stable" {
description = "Is the version of soperator stable."
type = bool
default = true
}
variable "slurm_nodesets_partitions" {
description = <<-EOT
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(setsubtract(
toset(flatten([
for p in var.slurm_nodesets_partitions : coalesce(p.nodeset_refs, [])
])),
toset([for w in var.slurm_nodeset_workers : w.name])
)) == 0
error_message = "All slurm_nodesets_partitions[].nodeset_refs must reference existing slurm_nodeset_workers[].name values."
}
}
# region PartitionConfiguration
variable "slurm_partition_config_type" {
description = "Type of the Slurm partition config. Could be either `default` or `custom`."
default = "default"
type = string
validation {
condition = (contains(["default", "custom"], var.slurm_partition_config_type))
error_message = "Invalid partition config type. It must be one of `default` or `custom`."
}
}
variable "slurm_partition_raw_config" {
description = "Partition config in case of `custom` slurm_partition_config_type. Each string must be started with `PartitionName`."
default = []
type = list(string)
}
# 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 "slurm_nodeset_system" {
description = "Configuration of System node set for system resources created by Soperator."
type = object({
min_size = number
max_size = number
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
})
nullable = false
default = {
min_size = 3
max_size = 9
resource = {
platform = "cpu-d3"
preset = "16vcpu-64gb"
}
boot_disk = {
type = "NETWORK_SSD"
size_gibibytes = 128
block_size_kibibytes = 4
}
}
validation {
condition = var.slurm_nodeset_system.boot_disk.size_gibibytes >= 128
error_message = "Boot disks for system nodes must be at least 128 GiB."
}
validation {
condition = var.slurm_nodeset_system.min_size >= 3
error_message = "Minimum size of the system node group must be at least 3."
}
}
variable "slurm_nodeset_controller" {
description = "Configuration of Slurm Controller node set. Only a single controller node is supported."
type = object({
size = number
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
})
nullable = false
default = {
size = 1
resource = {
platform = "cpu-d3"
preset = "16vcpu-64gb"
}
boot_disk = {
type = "NETWORK_SSD"
size_gibibytes = 128
block_size_kibibytes = 4
}
}
validation {
condition = var.slurm_nodeset_controller.boot_disk.size_gibibytes >= 128
error_message = "Boot disks for controller nodes must be at least 128 GiB."
}
validation {
condition = var.slurm_nodeset_controller.size == 1
error_message = "Size of the controller node group must be exactly 1."
}
}
variable "slurm_nodeset_workers" {
description = "Configuration of Slurm Worker node sets."
type = list(object({
name = string
size = number
autoscaling = optional(object({
enabled = optional(bool, true)
min_size = optional(number)
}), {})
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
gpu_cluster = optional(object({
infiniband_fabric = string
}))
preemptible = optional(object({}))
reservation_policy = optional(object({
policy = optional(string)
reservation_ids = optional(list(string))
}))
features = optional(list(string))
create_partition = optional(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")
}), {})
}))
nullable = false
default = [{
name = "worker"
size = 1
resource = {
platform = "cpu-d3"
preset = "16vcpu-64gb"
}
boot_disk = {
type = "NETWORK_SSD"
size_gibibytes = 512
block_size_kibibytes = 4
}
}]
validation {
condition = alltrue([
for worker in var.slurm_nodeset_workers :
(worker.size > 0)
])
error_message = "Worker nodeset size must be greater than 0."
}
validation {
condition = length(var.slurm_nodeset_workers) > 0
error_message = "At least one worker nodeset must be provided."
}
validation {
condition = length(distinct([for worker in var.slurm_nodeset_workers : worker.name])) == length(var.slurm_nodeset_workers)
error_message = "All worker nodeset names must be unique."
}
validation {
condition = alltrue([
for worker in var.slurm_nodeset_workers :
(worker.boot_disk.size_gibibytes >= 512)
])
error_message = "Boot disks for worker nodes must be at least 512 GiB."
}
validation {
condition = alltrue([
for worker in var.slurm_nodeset_workers :
worker.autoscaling.min_size == null || worker.autoscaling.min_size <= worker.size
])
error_message = "Worker nodeset autoscaling.min_size must be less than or equal to size."
}
validation {
condition = alltrue([
for worker in var.slurm_nodeset_workers :
!try(worker.local_nvme.enabled, false) || (
startswith(try(worker.local_nvme.mount_path, "/mnt/local-nvme"), "/")
)
])
error_message = "When worker local NVMe is enabled, mount_path must be an absolute path."
}
validation {
condition = alltrue([
for worker in var.slurm_nodeset_workers :
contains(["ext4", "xfs"], try(worker.local_nvme.filesystem_type, "ext4"))
])
error_message = "When worker local NVMe filesystem_type is set, it must be `ext4` or `xfs`."
}
}
variable "slurm_nodeset_login" {
description = "Configuration of Slurm Login node set."
type = object({
size = number
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
})
nullable = false
default = {
size = 1
resource = {
platform = "cpu-d3"
preset = "16vcpu-64gb"
}
boot_disk = {
type = "NETWORK_SSD"
size_gibibytes = 256
block_size_kibibytes = 4
}
}
validation {
condition = var.slurm_nodeset_login.boot_disk.size_gibibytes >= 256
error_message = "Boot disks for login nodes must be at least 256 GiB."
}
validation {
condition = var.slurm_nodeset_login.size >= 1
error_message = "Size of the login node group must be at least 1."
}
}
variable "slurm_nodeset_accounting" {
description = "Configuration of Slurm Accounting node set."
type = object({
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
})
default = {
resource = {
platform = "cpu-d3"
preset = "8vcpu-32gb"
}
boot_disk = {
type = "NETWORK_SSD"
size_gibibytes = 128
block_size_kibibytes = 4
}
}
validation {
condition = var.slurm_nodeset_accounting.boot_disk.size_gibibytes >= 128
error_message = "Boot disks for accounting nodes must be at least 128 GiB."
}
}
resource "terraform_data" "check_slurm_nodeset_accounting" {
lifecycle {
precondition {
condition = (var.accounting_enabled
? var.slurm_nodeset_accounting != null
: true
)
error_message = "Accounting node set must be provided when accounting is enabled."
}
}
}
variable "slurm_nodeset_nfs" {
description = "Configuration of NFS node set."
type = object({
size = number
resource = object({
platform = string
preset = string
})
boot_disk = object({
type = string
size_gibibytes = number
block_size_kibibytes = number
})
})
nullable = true
default = null
validation {
condition = var.slurm_nodeset_nfs == null || var.slurm_nodeset_nfs.boot_disk.size_gibibytes >= 128
error_message = "Boot disks for NFS nodes must be at least 128 GiB."
}
validation {
condition = var.slurm_nodeset_nfs == null || var.slurm_nodeset_nfs.size == 1
error_message = "Size of the NFS node group must be exactly 1."
}
}
resource "terraform_data" "check_slurm_nodeset" {
for_each = merge({
"system" = var.slurm_nodeset_system
"controller" = var.slurm_nodeset_controller
"login" = var.slurm_nodeset_login
}, { for i, worker in var.slurm_nodeset_workers :
"worker_${i}" => worker
},
var.slurm_nodeset_nfs != null ? {
"nfs" = var.slurm_nodeset_nfs
} : {}
)
depends_on = [
terraform_data.check_region,
]
lifecycle {
precondition {
condition = (
try(each.value.size, 0) > 0 ||
try(each.value.min_size, 0) > 0
)
error_message = "Either size or min_size must be greater than zero in node set ${each.key}."
}
precondition {
condition = contains(module.resources.platforms, each.value.resource.platform)
error_message = "Unsupported platform '${each.value.resource.platform}' in node set '${each.key}'."
}
precondition {
condition = contains(keys(module.resources.by_platform[each.value.resource.platform]), each.value.resource.preset)
error_message = "Unsupported preset '${each.value.resource.preset}' for platform '${each.value.resource.platform}' in node set '${each.key}'."
}
precondition {
condition = contains(module.resources.platform_regions[each.value.resource.platform], var.region)
error_message = "Unsupported platform '${each.value.resource.platform}' in region '${var.region}'. See https://docs.nebius.com/compute/virtual-machines/types"
}
# TODO: precondition for total node group count
}
}
resource "terraform_data" "check_local_nvme" {
lifecycle {
precondition {
condition = (
!anytrue([
for worker in var.slurm_nodeset_workers :
try(worker.local_nvme.enabled, false)
]) ||
alltrue([
for worker in var.slurm_nodeset_workers :
!try(worker.local_nvme.enabled, false) || (
try(module.resources.local_nvme_supported_by_region_platform_preset[var.region][worker.resource.platform][worker.resource.preset], false)
)
])
)
error_message = "Local NVMe is enabled, but one or more worker nodesets use unsupported region/platform/preset."
}
}
}
# region Worker
variable "slurm_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 "slurm_login_sshd_config_map_ref_name" {
description = "Name of configmap with SSHD config, which runs in slurmd container."
type = string
default = ""
}
variable "slurm_login_ssh_root_public_keys" {
description = "Authorized keys accepted for connecting to Slurm login nodes via SSH as 'root' user."
type = list(string)
nullable = false
validation {
condition = length(var.slurm_login_ssh_root_public_keys) >= 1
error_message = "At least one SSH public key must be provided."
}
validation {
condition = alltrue([for k in var.slurm_login_ssh_root_public_keys : length(k) > 0])
error_message = "SSH public keys must not be empty strings."
}