@@ -376,6 +376,51 @@ func schemaNodeConfig() *schema.Schema {
376
376
ForceNew : true ,
377
377
Description : `The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool.` ,
378
378
},
379
+ // Note that AtLeastOneOf can't be set because this schema is reused by
380
+ // two different resources.
381
+ "kubelet_config" : {
382
+ Type : schema .TypeList ,
383
+ Optional : true ,
384
+ MaxItems : 1 ,
385
+ Description : `Node kubelet configs.` ,
386
+ Elem : & schema.Resource {
387
+ Schema : map [string ]* schema.Schema {
388
+ "cpu_manager_policy" : {
389
+ Type : schema .TypeString ,
390
+ Required : true ,
391
+ ValidateFunc : validation .StringInSlice ([]string {"static" , "none" , "" }, false ),
392
+ Description : `Control the CPU management policy on the node.` ,
393
+ },
394
+ "cpu_cfs_quota" : {
395
+ Type : schema .TypeBool ,
396
+ Optional : true ,
397
+ Description : `Enable CPU CFS quota enforcement for containers that specify CPU limits.` ,
398
+ },
399
+ "cpu_cfs_quota_period" : {
400
+ Type : schema .TypeString ,
401
+ Optional : true ,
402
+ Description : `Set the CPU CFS quota period value 'cpu.cfs_period_us'.` ,
403
+ },
404
+ },
405
+ },
406
+ },
407
+
408
+ "linux_node_config" : {
409
+ Type : schema .TypeList ,
410
+ Optional : true ,
411
+ MaxItems : 1 ,
412
+ Description : `Parameters that can be configured on Linux nodes.` ,
413
+ Elem : & schema.Resource {
414
+ Schema : map [string ]* schema.Schema {
415
+ "sysctls" : {
416
+ Type : schema .TypeMap ,
417
+ Required : true ,
418
+ Elem : & schema.Schema {Type : schema .TypeString },
419
+ Description : `The Linux kernel parameters to be applied to the nodes and all pods running on the nodes.` ,
420
+ },
421
+ },
422
+ },
423
+ },
379
424
"node_group" : {
380
425
Type : schema .TypeString ,
381
426
Optional : true ,
@@ -591,6 +636,14 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
591
636
nc .BootDiskKmsKey = v .(string )
592
637
}
593
638
639
+ if v , ok := nodeConfig ["kubelet_config" ]; ok {
640
+ nc .KubeletConfig = expandKubeletConfig (v )
641
+ }
642
+
643
+ if v , ok := nodeConfig ["linux_node_config" ]; ok {
644
+ nc .LinuxNodeConfig = expandLinuxNodeConfig (v )
645
+ }
646
+
594
647
if v , ok := nodeConfig ["node_group" ]; ok {
595
648
nc .NodeGroup = v .(string )
596
649
}
@@ -617,6 +670,51 @@ func expandWorkloadMetadataConfig(v interface{}) *container.WorkloadMetadataConf
617
670
return wmc
618
671
}
619
672
673
+ func expandKubeletConfig (v interface {}) * container.NodeKubeletConfig {
674
+ if v == nil {
675
+ return nil
676
+ }
677
+ ls := v .([]interface {})
678
+ if len (ls ) == 0 {
679
+ return nil
680
+ }
681
+ cfg := ls [0 ].(map [string ]interface {})
682
+ kConfig := & container.NodeKubeletConfig {}
683
+ if cpuManagerPolicy , ok := cfg ["cpu_manager_policy" ]; ok {
684
+ kConfig .CpuManagerPolicy = cpuManagerPolicy .(string )
685
+ }
686
+ if cpuCfsQuota , ok := cfg ["cpu_cfs_quota" ]; ok {
687
+ kConfig .CpuCfsQuota = cpuCfsQuota .(bool )
688
+ kConfig .ForceSendFields = append (kConfig .ForceSendFields , "CpuCfsQuota" )
689
+ }
690
+ if cpuCfsQuotaPeriod , ok := cfg ["cpu_cfs_quota_period" ]; ok {
691
+ kConfig .CpuCfsQuotaPeriod = cpuCfsQuotaPeriod .(string )
692
+ }
693
+ return kConfig
694
+ }
695
+
696
+ func expandLinuxNodeConfig (v interface {}) * container.LinuxNodeConfig {
697
+ if v == nil {
698
+ return nil
699
+ }
700
+ ls := v .([]interface {})
701
+ if len (ls ) == 0 {
702
+ return nil
703
+ }
704
+ cfg := ls [0 ].(map [string ]interface {})
705
+ sysCfgRaw , ok := cfg ["sysctls" ]
706
+ if ! ok {
707
+ return nil
708
+ }
709
+ m := make (map [string ]string )
710
+ for k , v := range sysCfgRaw .(map [string ]interface {}) {
711
+ m [k ] = v .(string )
712
+ }
713
+ return & container.LinuxNodeConfig {
714
+ Sysctls : m ,
715
+ }
716
+ }
717
+
620
718
func flattenNodeConfigDefaults (c * container.NodeConfigDefaults ) []map [string ]interface {} {
621
719
result := make ([]map [string ]interface {}, 0 , 1 )
622
720
@@ -661,6 +759,8 @@ func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
661
759
"taint" : flattenTaints (c .Taints ),
662
760
"workload_metadata_config" : flattenWorkloadMetadataConfig (c .WorkloadMetadataConfig ),
663
761
"boot_disk_kms_key" : c .BootDiskKmsKey ,
762
+ "kubelet_config" : flattenKubeletConfig (c .KubeletConfig ),
763
+ "linux_node_config" : flattenLinuxNodeConfig (c .LinuxNodeConfig ),
664
764
"node_group" : c .NodeGroup ,
665
765
})
666
766
@@ -764,3 +864,25 @@ func flattenWorkloadMetadataConfig(c *container.WorkloadMetadataConfig) []map[st
764
864
}
765
865
return result
766
866
}
867
+
868
+ func flattenKubeletConfig (c * container.NodeKubeletConfig ) []map [string ]interface {} {
869
+ result := []map [string ]interface {}{}
870
+ if c != nil {
871
+ result = append (result , map [string ]interface {}{
872
+ "cpu_cfs_quota" : c .CpuCfsQuota ,
873
+ "cpu_cfs_quota_period" : c .CpuCfsQuotaPeriod ,
874
+ "cpu_manager_policy" : c .CpuManagerPolicy ,
875
+ })
876
+ }
877
+ return result
878
+ }
879
+
880
+ func flattenLinuxNodeConfig (c * container.LinuxNodeConfig ) []map [string ]interface {} {
881
+ result := []map [string ]interface {}{}
882
+ if c != nil {
883
+ result = append (result , map [string ]interface {}{
884
+ "sysctls" : c .Sysctls ,
885
+ })
886
+ }
887
+ return result
888
+ }
0 commit comments