-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
node_config.go.tmpl
2521 lines (2272 loc) · 77.4 KB
/
node_config.go.tmpl
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
package container
import (
"log"
{{- if ne $.TargetVersionName "ga" }}
"strings"
{{- end }}
"time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
{{ if eq $.TargetVersionName `ga` }}
"google.golang.org/api/container/v1"
{{- else }}
container "google.golang.org/api/container/v1beta1"
{{- end }}
)
// Matches gke-default scope from https://cloud.google.com/sdk/gcloud/reference/container/clusters/create
var defaultOauthScopes = []string{
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append",
}
func schemaContainerdConfig() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Description: "Parameters for containerd configuration.",
MaxItems: 1,
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"private_registry_access_config": {
Type: schema.TypeList,
Optional: true,
Description: "Parameters for private container registries configuration.",
MaxItems: 1,
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: "Whether or not private registries are configured.",
},
"certificate_authority_domain_config": {
Type: schema.TypeList,
Optional: true,
Description: "Parameters for configuring CA certificate and domains.",
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"fqdns": {
Type: schema.TypeList,
Required: true,
Description: "List of fully-qualified-domain-names. IPv4s and port specification are supported.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"gcp_secret_manager_certificate_config": {
Type: schema.TypeList,
Required: true,
Description: "Parameters for configuring a certificate hosted in GCP SecretManager.",
MaxItems: 1,
Elem: &schema.Resource{Schema: map[string]*schema.Schema{
"secret_uri": {
Type: schema.TypeString,
Required: true,
Description: "URI for the secret that hosts a certificate. Must be in the format 'projects/PROJECT_NUM/secrets/SECRET_NAME/versions/VERSION_OR_LATEST'.",
},
}},
},
}},
},
}},
},
}},
}
}
// Note: this is a bool internally, but implementing as an enum internally to
// make it easier to accept API level defaults.
func schemaInsecureKubeletReadonlyPortEnabled() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Controls whether the kubelet read-only port is enabled. It is strongly recommended to set this to `FALSE`. Possible values: `TRUE`, `FALSE`.",
ValidateFunc: validation.StringInSlice([]string{"FALSE","TRUE"}, false),
}
}
func schemaLoggingVariant() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `Type of logging agent that is used as the default value for node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT.`,
ValidateFunc: validation.StringInSlice([]string{"DEFAULT", "MAX_THROUGHPUT"}, false),
}
}
func schemaGcfsConfig() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `GCFS configuration for this node.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: `Whether or not GCFS is enabled`,
},
},
},
}
}
func schemaNodeConfig() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Description: `The configuration of the nodepool`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"containerd_config": schemaContainerdConfig(),
"disk_size_gb": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(10),
Description: `Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB.`,
},
"disk_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `Type of the disk attached to each node. Such as pd-standard, pd-balanced or pd-ssd`,
},
"guest_accelerator": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Description: `List of the type and count of accelerator cards attached to the instance.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"count": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: `The number of the accelerator cards exposed to an instance.`,
},
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The accelerator type resource name.`,
},
"gpu_driver_installation_config": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
ForceNew: true,
Description: `Configuration for auto installation of GPU driver.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"gpu_driver_version": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Mode for how the GPU driver is installed.`,
ValidateFunc: validation.StringInSlice([]string{"GPU_DRIVER_VERSION_UNSPECIFIED", "INSTALLATION_DISABLED", "DEFAULT", "LATEST"}, false),
},
},
},
},
"gpu_partition_size": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Size of partitions to create on the GPU. Valid values are described in the NVIDIA mig user guide (https://docs.nvidia.com/datacenter/tesla/mig-user-guide/#partitioning)`,
},
"gpu_sharing_config": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: `Configuration for GPU sharing.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"gpu_sharing_strategy": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `The type of GPU sharing strategy to enable on the GPU node. Possible values are described in the API package (https://pkg.go.dev/google.golang.org/api/container/v1#GPUSharingConfig)`,
},
"max_shared_clients_per_gpu": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: `The maximum number of containers that can share a GPU.`,
},
},
},
},
},
},
},
"image_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: tpgresource.CaseDiffSuppress,
Description: `The image type to use for this node. Note that for a given image type, the latest version of it will be used.`,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
// Computed=true because GKE Sandbox will automatically add labels to nodes that can/cannot run sandboxed pods.
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The map of Kubernetes labels (key/value pairs) to be applied to each node. These will added in addition to any default label(s) that Kubernetes may apply to the node.`,
{{- if not (or (eq $.TargetVersionName "") (eq $.TargetVersionName "ga")) }}
DiffSuppressFunc: containerNodePoolLabelsSuppress,
{{- end }}
},
"resource_labels": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
},
"local_ssd_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
Description: `The number of local SSD disks to be attached to the node.`,
},
"logging_variant": schemaLoggingVariant(),
{{ if ne $.TargetVersionName `ga` -}}
"ephemeral_storage_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Parameters for the ephemeral storage filesystem. If unspecified, ephemeral storage is backed by the boot disk.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_ssd_count": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
Description: `Number of local SSDs to use to back ephemeral storage. Uses NVMe interfaces. Each local SSD must be 375 or 3000 GB in size, and all local SSDs must share the same size.`,
},
},
},
},
{{- end }}
"ephemeral_storage_local_ssd_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Parameters for the ephemeral storage filesystem. If unspecified, ephemeral storage is backed by the boot disk.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_ssd_count": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
Description: `Number of local SSDs to use to back ephemeral storage. Uses NVMe interfaces. Each local SSD must be 375 or 3000 GB in size, and all local SSDs must share the same size.`,
},
},
},
},
"local_nvme_ssd_block_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Parameters for raw-block local NVMe SSDs.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_ssd_count": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
Description: `Number of raw-block local NVMe SSD disks to be attached to the node. Each local SSD is 375 GB in size.`,
},
},
},
},
"secondary_boot_disks": {
Type: schema.TypeList,
Optional: true,
MaxItems: 127,
Description: `Secondary boot disks for preloading data or container images.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_image": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Disk image to create the secondary boot disk from`,
},
"mode": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Mode for how the secondary boot disk is used.`,
},
},
},
},
"gcfs_config": schemaGcfsConfig(),
"gvnic": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Enable or disable gvnic in the node pool.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
ForceNew: true,
Description: `Whether or not gvnic is enabled`,
},
},
},
},
"machine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `The name of a Google Compute Engine machine type.`,
},
"metadata": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The metadata key/value pairs assigned to instances in the cluster.`,
},
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: `Minimum CPU platform to be used by this instance. The instance may be scheduled on the specified or newer CPU platform.`,
},
"oauth_scopes": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Description: `The set of Google API scopes to be made available on all of the node VMs.`,
Elem: &schema.Schema{
Type: schema.TypeString,
StateFunc: func(v interface{}) string {
return tpgresource.CanonicalizeServiceScope(v.(string))
},
},
DiffSuppressFunc: containerClusterAddedScopesSuppress,
Set: tpgresource.StringScopeHashcode,
},
"preemptible": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
Description: `Whether the nodes are created as preemptible VM instances.`,
},
"reservation_affinity": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `The reservation affinity configuration for the node pool.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"consume_reservation_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Corresponds to the type of reservation consumption.`,
ValidateFunc: validation.StringInSlice([]string{"UNSPECIFIED", "NO_RESERVATION", "ANY_RESERVATION", "SPECIFIC_RESERVATION"}, false),
},
"key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `The label key of a reservation resource.`,
},
"values": {
Type: schema.TypeSet,
Description: "The label values of the reservation resource.",
ForceNew: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"spot": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
Description: `Whether the nodes are created as spot VM instances.`,
},
"service_account": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: `The Google Cloud Platform Service Account to be used by the node VMs.`,
},
"tags": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The list of instance tags applied to all nodes.`,
},
"storage_pools": {
Type: schema.TypeList,
ForceNew: true,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The list of Storage Pools where boot disks are provisioned.`,
},
"shielded_instance_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Description: `Shielded Instance options.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enable_secure_boot": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
Description: `Defines whether the instance has Secure Boot enabled.`,
},
"enable_integrity_monitoring": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: true,
Description: `Defines whether the instance has integrity monitoring enabled.`,
},
},
},
},
"taint": {
Type: schema.TypeList,
Optional: true,
Description: `List of Kubernetes taints to be applied to each node.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Required: true,
Description: `Key for taint.`,
},
"value": {
Type: schema.TypeString,
Required: true,
Description: `Value for taint.`,
},
"effect": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"NO_SCHEDULE", "PREFER_NO_SCHEDULE", "NO_EXECUTE"}, false),
Description: `Effect for taint.`,
},
},
},
},
"effective_taints": {
Type: schema.TypeList,
Computed: true,
Description: `List of kubernetes taints applied to each node.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Computed: true,
Description: `Key for taint.`,
},
"value": {
Type: schema.TypeString,
Computed: true,
Description: `Value for taint.`,
},
"effect": {
Type: schema.TypeString,
Computed: true,
Description: `Effect for taint.`,
},
},
},
},
"workload_metadata_config": {
Computed: true,
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `The workload metadata configuration for this node.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mode": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"MODE_UNSPECIFIED", "GCE_METADATA", "GKE_METADATA"}, false),
Description: `Mode is the configuration for how to expose metadata to workloads running on the node.`,
},
},
},
},
{{ if ne $.TargetVersionName `ga` -}}
"sandbox_config": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Description: `Sandbox configuration for this node.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sandbox_type": {
Type: schema.TypeString,
Required: true,
Description: `Type of the sandbox to use for the node (e.g. 'gvisor')`,
ValidateFunc: validation.StringInSlice([]string{"gvisor"}, false),
},
},
},
},
{{- end }}
"boot_disk_kms_key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool.`,
},
// Note that AtLeastOneOf can't be set because this schema is reused by
// two different resources.
"kubelet_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Node kubelet configs.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu_manager_policy": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"static", "none", ""}, false),
Description: `Control the CPU management policy on the node.`,
},
"cpu_cfs_quota": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable CPU CFS quota enforcement for containers that specify CPU limits.`,
},
"cpu_cfs_quota_period": {
Type: schema.TypeString,
Optional: true,
Description: `Set the CPU CFS quota period value 'cpu.cfs_period_us'.`,
},
"insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(),
"pod_pids_limit": {
Type: schema.TypeInt,
Optional: true,
Description: `Controls the maximum number of processes allowed to run in a pod.`,
},
},
},
},
"linux_node_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Parameters that can be configured on Linux nodes.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sysctls": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The Linux kernel parameters to be applied to the nodes and all pods running on the nodes.`,
},
"cgroup_mode": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"CGROUP_MODE_UNSPECIFIED", "CGROUP_MODE_V1", "CGROUP_MODE_V2"}, false),
Description: `cgroupMode specifies the cgroup mode to be used on the node.`,
DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("CGROUP_MODE_UNSPECIFIED"),
},
"hugepages_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Amounts for 2M and 1G hugepages.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"hugepage_size_2m": {
Type: schema.TypeInt,
Optional: true,
Description: `Amount of 2M hugepages.`,
},
"hugepage_size_1g": {
Type: schema.TypeInt,
Optional: true,
Description: `Amount of 1G hugepages.`,
},
},
},
},
},
},
},
"node_group": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Setting this field will assign instances of this pool to run on the specified node group. This is useful for running workloads on sole tenant nodes.`,
},
"advanced_machine_features": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Specifies options for controlling advanced machine features.`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"threads_per_core": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`,
},
"enable_nested_virtualization": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `Whether the node should have nested virtualization enabled.`,
},
},
},
},
"sole_tenant_config": {
Type: schema.TypeList,
Optional: true,
Description: `Node affinity options for sole tenant node pools.`,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_affinity": {
Type: schema.TypeSet,
Required: true,
ForceNew: true,
Description: `.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `.`,
},
"operator": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `.`,
ValidateFunc: validation.StringInSlice([]string{"IN", "NOT_IN"}, false),
},
"values": {
Type: schema.TypeList,
Required: true,
ForceNew: true,
Description: `.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
},
},
},
"host_maintenance_policy": {
Type: schema.TypeList,
Optional: true,
Description: `The maintenance policy for the hosts on which the GKE VMs run on.`,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"maintenance_interval": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `.`,
ValidateFunc: validation.StringInSlice([]string{"MAINTENANCE_INTERVAL_UNSPECIFIED", "AS_NEEDED", "PERIODIC"}, false),
},
},
},
},
"confidential_nodes": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Description: `Configuration for the confidential nodes feature, which makes nodes run on confidential VMs. Warning: This configuration can't be changed (or added/removed) after pool creation without deleting and recreating the entire pool.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
ForceNew: true,
Description: `Whether Confidential Nodes feature is enabled for all nodes in this pool.`,
},
},
},
},
"fast_socket": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Enable or disable NCCL Fast Socket in the node pool.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: `Whether or not NCCL Fast Socket is enabled`,
},
},
},
},
"resource_manager_tags": {
Type: schema.TypeMap,
Optional: true,
Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored (both PUT & PATCH) when empty.`,
},
"enable_confidential_storage": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `If enabled boot disks are configured with confidential mode.`,
},
},
},
}
}
// Separate since this currently only supports a single value -- a subset of
// the overall NodeKubeletConfig
func schemaNodePoolAutoConfigNodeKubeletConfig() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Node kubelet configs.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"insecure_kubelet_readonly_port_enabled": schemaInsecureKubeletReadonlyPortEnabled(),
},
},
}
}
func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefaults {
configs := configured.([]interface{})
if len(configs) == 0 || configs[0] == nil {
return nil
}
config := configs[0].(map[string]interface{})
nodeConfigDefaults := &container.NodeConfigDefaults{}
nodeConfigDefaults.ContainerdConfig = expandContainerdConfig(config["containerd_config"])
if v, ok := config["insecure_kubelet_readonly_port_enabled"]; ok {
nodeConfigDefaults.NodeKubeletConfig = &container.NodeKubeletConfig{
InsecureKubeletReadonlyPortEnabled: expandInsecureKubeletReadonlyPortEnabled(v),
}
}
if variant, ok := config["logging_variant"]; ok {
nodeConfigDefaults.LoggingConfig = &container.NodePoolLoggingConfig{
VariantConfig: &container.LoggingVariantConfig{
Variant: variant.(string),
},
}
}
if v, ok := config["gcfs_config"]; ok && len(v.([]interface{})) > 0 {
gcfsConfig := v.([]interface{})[0].(map[string]interface{})
nodeConfigDefaults.GcfsConfig = &container.GcfsConfig{
Enabled: gcfsConfig["enabled"].(bool),
}
}
return nodeConfigDefaults
}
func expandNodeConfig(v interface{}) *container.NodeConfig {
nodeConfigs := v.([]interface{})
nc := &container.NodeConfig{
// Defaults can't be set on a list/set in the schema, so set the default on create here.
OauthScopes: defaultOauthScopes,
}
if len(nodeConfigs) == 0 {
return nc
}
nodeConfig := nodeConfigs[0].(map[string]interface{})
if v, ok := nodeConfig["containerd_config"]; ok {
nc.ContainerdConfig = expandContainerdConfig(v)
}
if v, ok := nodeConfig["machine_type"]; ok {
nc.MachineType = v.(string)
}
if v, ok := nodeConfig["guest_accelerator"]; ok {
accels := v.([]interface{})
guestAccelerators := make([]*container.AcceleratorConfig, 0, len(accels))
for _, raw := range accels {
data := raw.(map[string]interface{})
if data["count"].(int) == 0 {
continue
}
guestAcceleratorConfig := &container.AcceleratorConfig{
AcceleratorCount: int64(data["count"].(int)),
AcceleratorType: data["type"].(string),
GpuPartitionSize: data["gpu_partition_size"].(string),
}
if v, ok := data["gpu_driver_installation_config"]; ok && len(v.([]interface{})) > 0 {
gpuDriverInstallationConfig := data["gpu_driver_installation_config"].([]interface{})[0].(map[string]interface{})
guestAcceleratorConfig.GpuDriverInstallationConfig = &container.GPUDriverInstallationConfig{
GpuDriverVersion: gpuDriverInstallationConfig["gpu_driver_version"].(string),
}
}
if v, ok := data["gpu_sharing_config"]; ok && len(v.([]interface{})) > 0 {
gpuSharingConfig := data["gpu_sharing_config"].([]interface{})[0].(map[string]interface{})
guestAcceleratorConfig.GpuSharingConfig = &container.GPUSharingConfig{
GpuSharingStrategy: gpuSharingConfig["gpu_sharing_strategy"].(string),
MaxSharedClientsPerGpu: int64(gpuSharingConfig["max_shared_clients_per_gpu"].(int)),
}
}
guestAccelerators = append(guestAccelerators, guestAcceleratorConfig)
}
nc.Accelerators = guestAccelerators
}
if v, ok := nodeConfig["disk_size_gb"]; ok {
nc.DiskSizeGb = int64(v.(int))
}
if v, ok := nodeConfig["disk_type"]; ok {
nc.DiskType = v.(string)
}
if v, ok := nodeConfig["local_ssd_count"]; ok {
nc.LocalSsdCount = int64(v.(int))
}
if v, ok := nodeConfig["logging_variant"]; ok {
nc.LoggingConfig = &container.NodePoolLoggingConfig{
VariantConfig: &container.LoggingVariantConfig{
Variant: v.(string),
},
}
}
{{ if ne $.TargetVersionName `ga` -}}
if v, ok := nodeConfig["ephemeral_storage_config"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.EphemeralStorageConfig = &container.EphemeralStorageConfig{
LocalSsdCount: int64(conf["local_ssd_count"].(int)),
}
}
{{- end }}
if v, ok := nodeConfig["local_nvme_ssd_block_config"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.LocalNvmeSsdBlockConfig = &container.LocalNvmeSsdBlockConfig{
LocalSsdCount: int64(conf["local_ssd_count"].(int)),
}
}
if v, ok := nodeConfig["ephemeral_storage_local_ssd_config"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.EphemeralStorageLocalSsdConfig = &container.EphemeralStorageLocalSsdConfig{
LocalSsdCount: int64(conf["local_ssd_count"].(int)),
}
}
if v, ok := nodeConfig["secondary_boot_disks"]; ok && len(v.([]interface{})) > 0 {
conf, confOK := v.([]interface{})[0].(map[string]interface{})
if confOK {
modeValue, modeOK := conf["mode"]
diskImage := conf["disk_image"].(string)
if modeOK {
nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{
DiskImage: diskImage,
Mode: modeValue.(string),
})
} else {
nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{
DiskImage: diskImage,
})
}
} else {
nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{
DiskImage: "",
})
}
}
if v, ok := nodeConfig["gcfs_config"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.GcfsConfig = &container.GcfsConfig{
Enabled: conf["enabled"].(bool),
}
}
if v, ok := nodeConfig["gvnic"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.Gvnic = &container.VirtualNIC{
Enabled: conf["enabled"].(bool),
}
}
if v, ok := nodeConfig["fast_socket"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.FastSocket = &container.FastSocket{
Enabled: conf["enabled"].(bool),
}
}