@@ -73,6 +73,18 @@ func schemaContainerdConfig() *schema.Schema {
73
73
}
74
74
}
75
75
76
+ // Note: this is a bool internally, but implementing as an enum internally to
77
+ // make it easier to accept API level defaults.
78
+ func schemaInsecureKubeletReadonlyPortEnabled () * schema.Schema {
79
+ return & schema.Schema {
80
+ Type : schema .TypeString ,
81
+ Optional : true ,
82
+ Computed : true ,
83
+ Description : "Controls whether the kubelet read-only port is enabled. It is strongly recommended to set this to `FALSE`. Possible values: `TRUE`, `FALSE`." ,
84
+ ValidateFunc : validation .StringInSlice ([]string {"FALSE" , "TRUE" }, false ),
85
+ }
86
+ }
87
+
76
88
func schemaLoggingVariant () * schema.Schema {
77
89
return & schema.Schema {
78
90
Type : schema .TypeString ,
@@ -591,6 +603,7 @@ func schemaNodeConfig() *schema.Schema {
591
603
Optional : true ,
592
604
Description : `Set the CPU CFS quota period value 'cpu.cfs_period_us'.` ,
593
605
},
606
+ "insecure_kubelet_readonly_port_enabled" : schemaInsecureKubeletReadonlyPortEnabled (),
594
607
"pod_pids_limit" : {
595
608
Type : schema .TypeInt ,
596
609
Optional : true ,
@@ -771,6 +784,12 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau
771
784
772
785
nodeConfigDefaults := & container.NodeConfigDefaults {}
773
786
nodeConfigDefaults .ContainerdConfig = expandContainerdConfig (config ["containerd_config" ])
787
+ if v , ok := config ["insecure_kubelet_readonly_port_enabled" ]; ok {
788
+ nodeConfigDefaults .NodeKubeletConfig = & container.NodeKubeletConfig {
789
+ InsecureKubeletReadonlyPortEnabled : expandInsecureKubeletReadonlyPortEnabled (v ),
790
+ ForceSendFields : []string {"InsecureKubeletReadonlyPortEnabled" },
791
+ }
792
+ }
774
793
if variant , ok := config ["logging_variant" ]; ok {
775
794
nodeConfigDefaults .LoggingConfig = & container.NodePoolLoggingConfig {
776
795
VariantConfig : & container.LoggingVariantConfig {
@@ -1116,6 +1135,13 @@ func expandWorkloadMetadataConfig(v interface{}) *container.WorkloadMetadataConf
1116
1135
return wmc
1117
1136
}
1118
1137
1138
+ func expandInsecureKubeletReadonlyPortEnabled (v interface {}) bool {
1139
+ if v == "TRUE" {
1140
+ return true
1141
+ }
1142
+ return false
1143
+ }
1144
+
1119
1145
func expandKubeletConfig (v interface {}) * container.NodeKubeletConfig {
1120
1146
if v == nil {
1121
1147
return nil
@@ -1136,6 +1162,10 @@ func expandKubeletConfig(v interface{}) *container.NodeKubeletConfig {
1136
1162
if cpuCfsQuotaPeriod , ok := cfg ["cpu_cfs_quota_period" ]; ok {
1137
1163
kConfig .CpuCfsQuotaPeriod = cpuCfsQuotaPeriod .(string )
1138
1164
}
1165
+ if insecureKubeletReadonlyPortEnabled , ok := cfg ["insecure_kubelet_readonly_port_enabled" ]; ok {
1166
+ kConfig .InsecureKubeletReadonlyPortEnabled = expandInsecureKubeletReadonlyPortEnabled (insecureKubeletReadonlyPortEnabled )
1167
+ kConfig .ForceSendFields = append (kConfig .ForceSendFields , "InsecureKubeletReadonlyPortEnabled" )
1168
+ }
1139
1169
if podPidsLimit , ok := cfg ["pod_pids_limit" ]; ok {
1140
1170
kConfig .PodPidsLimit = int64 (podPidsLimit .(int ))
1141
1171
}
@@ -1342,6 +1372,8 @@ func flattenNodeConfigDefaults(c *container.NodeConfigDefaults) []map[string]int
1342
1372
1343
1373
result [0 ]["containerd_config" ] = flattenContainerdConfig (c .ContainerdConfig )
1344
1374
1375
+ result [0 ]["insecure_kubelet_readonly_port_enabled" ] = flattenInsecureKubeletReadonlyPortEnabled (c .NodeKubeletConfig )
1376
+
1345
1377
result [0 ]["logging_variant" ] = flattenLoggingVariant (c .LoggingConfig )
1346
1378
1347
1379
result [0 ]["gcfs_config" ] = flattenGcfsConfig (c .GcfsConfig )
@@ -1521,6 +1553,14 @@ func flattenSecondaryBootDisks(c []*container.SecondaryBootDisk) []map[string]in
1521
1553
return result
1522
1554
}
1523
1555
1556
+ func flattenInsecureKubeletReadonlyPortEnabled (c * container.NodeKubeletConfig ) string {
1557
+ // Convert bool from the API to the enum values used internally
1558
+ if c != nil && c .InsecureKubeletReadonlyPortEnabled {
1559
+ return "TRUE"
1560
+ }
1561
+ return "FALSE"
1562
+ }
1563
+
1524
1564
func flattenLoggingVariant (c * container.NodePoolLoggingConfig ) string {
1525
1565
variant := "DEFAULT"
1526
1566
if c != nil && c .VariantConfig != nil && c .VariantConfig .Variant != "" {
@@ -1668,10 +1708,11 @@ func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface
1668
1708
result := []map [string ]interface {}{}
1669
1709
if c != nil {
1670
1710
result = append (result , map [string ]interface {}{
1671
- "cpu_cfs_quota" : c .CpuCfsQuota ,
1672
- "cpu_cfs_quota_period" : c .CpuCfsQuotaPeriod ,
1673
- "cpu_manager_policy" : c .CpuManagerPolicy ,
1674
- "pod_pids_limit" : c .PodPidsLimit ,
1711
+ "cpu_cfs_quota" : c .CpuCfsQuota ,
1712
+ "cpu_cfs_quota_period" : c .CpuCfsQuotaPeriod ,
1713
+ "cpu_manager_policy" : c .CpuManagerPolicy ,
1714
+ "insecure_kubelet_readonly_port_enabled" : flattenInsecureKubeletReadonlyPortEnabled (c ),
1715
+ "pod_pids_limit" : c .PodPidsLimit ,
1675
1716
})
1676
1717
}
1677
1718
return result
0 commit comments