Skip to content

Commit 704cc9e

Browse files
container: bump flex_start to GA (#14094) (#23093)
[upstream:dbe831ecb4420d283a0010b177db372b6aa8fb60] Signed-off-by: Modular Magician <[email protected]>
1 parent 977c86c commit 704cc9e

File tree

5 files changed

+178
-1
lines changed

5 files changed

+178
-1
lines changed

.changelog/14094.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: bump flex_start to GA
3+
```

google/services/container/node_config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,12 @@ func schemaNodeConfig() *schema.Schema {
842842
ForceNew: true,
843843
Description: `The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s".`,
844844
},
845+
"flex_start": {
846+
Type: schema.TypeBool,
847+
Optional: true,
848+
ForceNew: true,
849+
Description: `Enables Flex Start provisioning model for the node pool`,
850+
},
845851
},
846852
},
847853
}
@@ -1221,6 +1227,10 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
12211227
nc.MaxRunDuration = v.(string)
12221228
}
12231229

1230+
if v, ok := nodeConfig["flex_start"]; ok {
1231+
nc.FlexStart = v.(bool)
1232+
}
1233+
12241234
if v, ok := nodeConfig["confidential_nodes"]; ok {
12251235
nc.ConfidentialNodes = expandConfidentialNodes(v)
12261236
}
@@ -1620,6 +1630,7 @@ func flattenNodeConfig(c *container.NodeConfig, v interface{}) []map[string]inte
16201630
"node_group": c.NodeGroup,
16211631
"advanced_machine_features": flattenAdvancedMachineFeaturesConfig(c.AdvancedMachineFeatures),
16221632
"max_run_duration": c.MaxRunDuration,
1633+
"flex_start": c.FlexStart,
16231634
"sole_tenant_config": flattenSoleTenantConfig(c.SoleTenantConfig),
16241635
"fast_socket": flattenFastSocket(c.FastSocket),
16251636
"resource_manager_tags": flattenResourceManagerTags(c.ResourceManagerTags),

google/services/container/resource_container_cluster_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,38 @@ func TestAccContainerCluster_withMaxRunDuration(t *testing.T) {
519519
})
520520
}
521521

522+
func TestAccContainerCluster_withFlexStart(t *testing.T) {
523+
t.Parallel()
524+
525+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
526+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
527+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
528+
npName := fmt.Sprintf("tf-test-node-pool-%s", acctest.RandString(t, 10))
529+
530+
acctest.VcrTest(t, resource.TestCase{
531+
PreCheck: func() { acctest.AccTestPreCheck(t) },
532+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
533+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
534+
Steps: []resource.TestStep{
535+
{
536+
Config: testAccContainerCluster_withFlexStart(clusterName, npName, networkName, subnetworkName),
537+
Check: resource.ComposeTestCheckFunc(
538+
resource.TestCheckResourceAttr("google_container_cluster.flex_start", "node_pool.0.node_config.0.machine_type", "n1-standard-1"),
539+
resource.TestCheckResourceAttr("google_container_cluster.flex_start",
540+
"node_pool.0.node_config.0.reservation_affinity.0.consume_reservation_type", "NO_RESERVATION"),
541+
resource.TestCheckResourceAttr("google_container_cluster.flex_start", "node_pool.0.node_config.0.flex_start", "true"),
542+
),
543+
},
544+
{
545+
ResourceName: "google_container_cluster.flex_start",
546+
ImportState: true,
547+
ImportStateVerify: true,
548+
ImportStateVerifyIgnore: []string{"deletion_protection", "min_master_version", "node_pool.0.node_config.0.taint"},
549+
},
550+
},
551+
})
552+
}
553+
522554
func TestAccContainerCluster_withILBSubsetting(t *testing.T) {
523555
t.Parallel()
524556

@@ -6726,6 +6758,56 @@ resource "google_container_cluster" "max_run_duration" {
67266758
`, clusterName, npName, duration, networkName, subnetworkName)
67276759
}
67286760

6761+
func testAccContainerCluster_withFlexStart(clusterName, npName, networkName, subnetworkName string) string {
6762+
return fmt.Sprintf(`
6763+
data "google_container_engine_versions" "uscentral1a" {
6764+
location = "us-central1-a"
6765+
}
6766+
6767+
resource "google_container_cluster" "flex_start" {
6768+
min_master_version = data.google_container_engine_versions.uscentral1a.release_channel_latest_version["RAPID"]
6769+
6770+
name = "%s"
6771+
location = "us-central1-a"
6772+
6773+
release_channel {
6774+
channel = "RAPID"
6775+
}
6776+
6777+
6778+
node_pool {
6779+
name = "%s"
6780+
initial_node_count = 0
6781+
autoscaling {
6782+
total_min_node_count = 0
6783+
total_max_node_count = 1
6784+
}
6785+
6786+
node_config {
6787+
machine_type = "n1-standard-1"
6788+
flex_start = true
6789+
max_run_duration = "604800s"
6790+
6791+
reservation_affinity {
6792+
consume_reservation_type = "NO_RESERVATION"
6793+
}
6794+
6795+
taint {
6796+
key = "taint_key"
6797+
value = "taint_value"
6798+
effect = "NO_SCHEDULE"
6799+
}
6800+
}
6801+
}
6802+
6803+
deletion_protection = false
6804+
network = "%s"
6805+
subnetwork = "%s"
6806+
6807+
}
6808+
`, clusterName, npName, networkName, subnetworkName)
6809+
}
6810+
67296811
func testAccContainerCluster_withILBSubSetting(clusterName, npName, networkName, subnetworkName string) string {
67306812
return fmt.Sprintf(`
67316813
resource "google_container_cluster" "confidential_nodes" {

google/services/container/resource_container_node_pool_test.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,6 +4464,87 @@ resource "google_container_node_pool" "np" {
44644464
`, clusterName, networkName, subnetworkName, np)
44654465
}
44664466

4467+
func TestAccContainerNodePool_withFlexStart(t *testing.T) {
4468+
t.Parallel()
4469+
4470+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
4471+
np := fmt.Sprintf("tf-test-cluster-nodepool-%s", acctest.RandString(t, 10))
4472+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
4473+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
4474+
4475+
acctest.VcrTest(t, resource.TestCase{
4476+
PreCheck: func() { acctest.AccTestPreCheck(t) },
4477+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
4478+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
4479+
Steps: []resource.TestStep{
4480+
{
4481+
Config: testAccContainerNodePool_withFlexStart(clusterName, np, networkName, subnetworkName),
4482+
Check: resource.ComposeTestCheckFunc(
4483+
resource.TestCheckResourceAttr("google_container_node_pool.np", "node_config.0.machine_type", "n1-standard-1"),
4484+
resource.TestCheckResourceAttr("google_container_node_pool.np",
4485+
"node_config.0.reservation_affinity.0.consume_reservation_type", "NO_RESERVATION"),
4486+
resource.TestCheckResourceAttr("google_container_node_pool.np", "node_config.0.flex_start", "true"),
4487+
),
4488+
},
4489+
{
4490+
ResourceName: "google_container_node_pool.np",
4491+
ImportState: true,
4492+
ImportStateVerify: true,
4493+
ImportStateVerifyIgnore: []string{"node_config.0.taint"},
4494+
},
4495+
},
4496+
})
4497+
}
4498+
4499+
func testAccContainerNodePool_withFlexStart(clusterName, np, networkName, subnetworkName string) string {
4500+
return fmt.Sprintf(`
4501+
data "google_container_engine_versions" "central1a" {
4502+
location = "us-central1-a"
4503+
}
4504+
4505+
resource "google_container_cluster" "cluster" {
4506+
name = "%s"
4507+
location = "us-central1-a"
4508+
initial_node_count = 1
4509+
deletion_protection = false
4510+
4511+
min_master_version = data.google_container_engine_versions.central1a.release_channel_latest_version["RAPID"]
4512+
release_channel {
4513+
channel = "RAPID"
4514+
}
4515+
network = "%s"
4516+
subnetwork = "%s"
4517+
}
4518+
4519+
resource "google_container_node_pool" "np" {
4520+
name = "%s"
4521+
location = "us-central1-a"
4522+
cluster = google_container_cluster.cluster.name
4523+
initial_node_count = 0
4524+
autoscaling {
4525+
total_min_node_count = 0
4526+
total_max_node_count = 1
4527+
}
4528+
4529+
node_config {
4530+
machine_type = "n1-standard-1"
4531+
flex_start = true
4532+
max_run_duration = "604800s"
4533+
4534+
reservation_affinity {
4535+
consume_reservation_type = "NO_RESERVATION"
4536+
}
4537+
4538+
taint {
4539+
key = "taint_key"
4540+
value = "taint_value"
4541+
effect = "NO_SCHEDULE"
4542+
}
4543+
}
4544+
}
4545+
`, clusterName, networkName, subnetworkName, np)
4546+
}
4547+
44674548
func TestAccContainerNodePool_tpuTopology(t *testing.T) {
44684549
t.Parallel()
44694550
t.Skip("https://github.com/hashicorp/terraform-provider-google/issues/15254#issuecomment-1646277473")

website/docs/r/container_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ gvnic {
950950

951951
* `max_run_duration` - (Optional) The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s".
952952

953-
* `flex_start` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))) Enables Flex Start provisioning model for the node pool.
953+
* `flex_start` - (Optional) Enables Flex Start provisioning model for the node pool.
954954

955955
* `local_ssd_count` - (Optional) The amount of local SSD disks that will be
956956
attached to each cluster node. Defaults to 0.

0 commit comments

Comments
 (0)