diff --git a/mmv1/third_party/terraform/services/container/node_config.go.erb b/mmv1/third_party/terraform/services/container/node_config.go.erb
index f03dbaa03537..a1ded9350b7e 100644
--- a/mmv1/third_party/terraform/services/container/node_config.go.erb
+++ b/mmv1/third_party/terraform/services/container/node_config.go.erb
@@ -646,6 +646,26 @@ func schemaNodeConfig() *schema.Schema {
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.`,
+ },
+ },
+ },
+ },
},
},
},
@@ -1245,6 +1265,10 @@ func expandLinuxNodeConfig(v interface{}) *container.LinuxNodeConfig {
linuxNodeConfig.CgroupMode = cgroupMode
}
+ if v, ok := cfg["hugepages_config"]; ok {
+ linuxNodeConfig.Hugepages = expandHugepagesConfig(v)
+ }
+
return linuxNodeConfig
}
@@ -1269,6 +1293,32 @@ func expandCgroupMode(cfg map[string]interface{}) string {
return cgroupMode.(string)
}
+func expandHugepagesConfig(v interface{}) *container.HugepagesConfig {
+ if v == nil {
+ return nil
+ }
+ ls := v.([]interface{})
+ if len(ls) == 0 {
+ return nil
+ }
+ if ls[0] == nil {
+ return &container.HugepagesConfig{}
+ }
+ cfg := ls[0].(map[string]interface{})
+
+ hugepagesConfig := &container.HugepagesConfig{}
+
+ if v, ok := cfg["hugepage_size_2m"]; ok {
+ hugepagesConfig.HugepageSize2m = int64(v.(int))
+ }
+
+ if v, ok := cfg["hugepage_size_1g"]; ok {
+ hugepagesConfig.HugepageSize1g = int64(v.(int))
+ }
+
+ return hugepagesConfig
+}
+
func expandContainerdConfig(v interface{}) *container.ContainerdConfig {
if v == nil {
return nil
@@ -1799,8 +1849,20 @@ func flattenLinuxNodeConfig(c *container.LinuxNodeConfig) []map[string]interface
result := []map[string]interface{}{}
if c != nil {
result = append(result, map[string]interface{}{
- "sysctls": c.Sysctls,
- "cgroup_mode": c.CgroupMode,
+ "sysctls": c.Sysctls,
+ "cgroup_mode": c.CgroupMode,
+ "hugepages_config": flattenHugepagesConfig(c.Hugepages),
+ })
+ }
+ return result
+}
+
+func flattenHugepagesConfig(c *container.HugepagesConfig) []map[string]interface{} {
+ result := []map[string]interface{}{}
+ if c != nil {
+ result = append(result, map[string]interface{}{
+ "hugepage_size_2m": c.HugepageSize2m,
+ "hugepage_size_1g": c.HugepageSize1g,
})
}
return result
diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb
index 5adcfc374cc3..05018f304885 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb
+++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb
@@ -671,6 +671,40 @@ func TestAccContainerNodePool_withCgroupMode(t *testing.T) {
})
}
+func TestAccContainerNodePool_withHugepageConfig(t *testing.T) {
+ t.Parallel()
+
+ cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
+ np := fmt.Sprintf("tf-test-np-%s", acctest.RandString(t, 10))
+ networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
+ subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
+
+ acctest.VcrTest(t, resource.TestCase{
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccContainerNodePool_withHugepageConfig(cluster, np, networkName, subnetworkName, 1),
+ },
+ {
+ ResourceName: "google_container_node_pool.np",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ // Perform an update.
+ {
+ Config: testAccContainerNodePool_withHugepageConfig(cluster, np, networkName, subnetworkName, 2),
+ },
+ {
+ ResourceName: "google_container_node_pool.np",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
func TestAccContainerNodePool_withNetworkConfig(t *testing.T) {
t.Parallel()
@@ -3387,6 +3421,46 @@ resource "google_container_node_pool" "with_tier1_net" {
`, network, cluster, np, np, np, np, netTier)
}
+
+func testAccContainerNodePool_withHugepageConfig(cluster, np, networkName, subnetworkName string, hugepage int) string {
+ return fmt.Sprintf(`
+data "google_container_engine_versions" "central1a" {
+ location = "us-central1-a"
+}
+
+resource "google_container_cluster" "cluster" {
+ name = "%s"
+ location = "us-central1-a"
+ initial_node_count = 1
+ min_master_version = data.google_container_engine_versions.central1a.latest_master_version
+ deletion_protection = false
+ network = "%s"
+ subnetwork = "%s"
+}
+
+resource "google_container_node_pool" "np" {
+ name = "%s"
+ location = "us-central1-a"
+ cluster = google_container_cluster.cluster.name
+ initial_node_count = 1
+ node_config {
+ image_type = "COS_CONTAINERD"
+ machine_type = "c2d-standard-2" # This is required for hugepage_size_1g https://cloud.google.com/kubernetes-engine/docs/how-to/node-system-config#huge-page-options
+ linux_node_config {
+ hugepages_config {
+ hugepage_size_2m = %d
+ hugepage_size_1g = %d
+ }
+ }
+ oauth_scopes = [
+ "https://www.googleapis.com/auth/logging.write",
+ "https://www.googleapis.com/auth/monitoring",
+ ]
+ }
+}
+`, cluster, networkName, subnetworkName, np, hugepage, hugepage)
+}
+
func testAccContainerNodePool_withMultiNicNetworkConfig(cluster, np, network string) string {
return fmt.Sprintf(`
resource "google_compute_network" "container_network" {
diff --git a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
index df2af254ebee..c4fc1f7c3a78 100644
--- a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
+++ b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
@@ -1328,6 +1328,14 @@ linux_node_config {
* `CGROUP_MODE_V1`: CGROUP_MODE_V1 specifies to use cgroupv1 for the cgroup configuration on the node image.
* `CGROUP_MODE_V2`: CGROUP_MODE_V2 specifies to use cgroupv2 for the cgroup configuration on the node image.
+* `hugepages_config` - (Optional) Amounts for 2M and 1G hugepages. Structure is [documented below](#nested_hugepages_config).
+
+The `hugepages_config` block supports:
+
+* `hugepage_size_2m` - (Optional) Amount of 2M hugepages.
+
+* `hugepage_size_1g` - (Optional) Amount of 1G hugepages.
+
The `containerd_config` block supports:
* `private_registry_access_config` (Optional) - Configuration for private container registries. There are two fields in this config: