Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduate support of GKE Queued Provisioning to GA #17549

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/10053.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
container: promoted `google_container_node_pool.queued_provisioning` to GA (ga)
```
35 changes: 35 additions & 0 deletions google/services/container/resource_container_node_pool.go
Expand Up @@ -204,6 +204,24 @@ var schemaNodePool = map[string]*schema.Schema{
},
},

"queued_provisioning": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: `Specifies the configuration of queued provisioning`,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
ForceNew: true,
Description: `Whether nodes in this node pool are obtainable solely through the ProvisioningRequest API`,
},
},
},
},

"max_pods_per_node": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -911,6 +929,15 @@ func expandNodePool(d *schema.ResourceData, prefix string) (*container.NodePool,
}
}

if v, ok := d.GetOk(prefix + "queued_provisioning"); ok {
if v.([]interface{}) != nil && v.([]interface{})[0] != nil {
queued_provisioning := v.([]interface{})[0].(map[string]interface{})
np.QueuedProvisioning = &container.QueuedProvisioning{
Enabled: queued_provisioning["enabled"].(bool),
}
}
}

if v, ok := d.GetOk(prefix + "max_pods_per_node"); ok {
np.MaxPodsConstraint = &container.MaxPodsConstraint{
MaxPodsPerNode: int64(v.(int)),
Expand Down Expand Up @@ -1104,6 +1131,14 @@ func flattenNodePool(d *schema.ResourceData, config *transport_tpg.Config, np *c
}
}

if np.QueuedProvisioning != nil {
nodePool["queued_provisioning"] = []map[string]interface{}{
{
"enabled": np.QueuedProvisioning.Enabled,
},
}
}

if np.MaxPodsConstraint != nil {
nodePool["max_pods_per_node"] = np.MaxPodsConstraint.MaxPodsPerNode
}
Expand Down
72 changes: 72 additions & 0 deletions google/services/container/resource_container_node_pool_test.go
Expand Up @@ -1801,6 +1801,78 @@ resource "google_container_node_pool" "np" {
`, cluster, networkName, subnetworkName, policyName, np)
}

func TestAccContainerNodePool_enableQueuedProvisioning(t *testing.T) {
t.Parallel()

cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
np := fmt.Sprintf("tf-test-nodepool-%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: testAccCheckContainerNodePoolDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerNodePool_enableQueuedProvisioning(cluster, np, networkName, subnetworkName, true),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_container_node_pool.np", "node_config.0.machine_type", "n1-standard-2"),
resource.TestCheckResourceAttr("google_container_node_pool.np",
"node_config.0.reservation_affinity.0.consume_reservation_type", "NO_RESERVATION"),
resource.TestCheckResourceAttr("google_container_node_pool.np", "queued_provisioning.0.enabled", "true"),
),
},
{
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccContainerNodePool_enableQueuedProvisioning(cluster, np, networkName, subnetworkName string, enabled bool) string {
return fmt.Sprintf(`
resource "google_container_cluster" "cluster" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1
min_master_version = "1.28"
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
autoscaling {
total_min_node_count = 0
total_max_node_count = 1
}

node_config {
machine_type = "n1-standard-2"
guest_accelerator {
type = "nvidia-tesla-t4"
count = 1
gpu_driver_installation_config {
gpu_driver_version = "LATEST"
}
}
reservation_affinity {
consume_reservation_type = "NO_RESERVATION"
}
}
queued_provisioning {
enabled = %t
}
}
`, cluster, networkName, subnetworkName, np, enabled)
}

func TestAccContainerNodePool_threadsPerCore(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/container_node_pool.html.markdown
Expand Up @@ -172,7 +172,7 @@ cluster.
* `placement_policy` - (Optional) Specifies a custom placement policy for the
nodes.

* `queued_provisioning` - (Optional, Beta) Specifies node pool-level settings of queued provisioning.
* `queued_provisioning` - (Optional) Specifies node pool-level settings of queued provisioning.
Structure is [documented below](#nested_queued_provisioning).

<a name="nested_autoscaling"></a>The `autoscaling` block supports (either total or per zone limits are required):
Expand Down