@@ -1861,6 +1861,7 @@ func TestAccContainerCluster_withInsecureKubeletReadonlyPortEnabledInNodePool(t
1861
1861
})
1862
1862
}
1863
1863
1864
+
1864
1865
// This is for `node_pool_defaults.node_config_defaults` - the default settings
1865
1866
// for newly created nodepools
1866
1867
func TestAccContainerCluster_withInsecureKubeletReadonlyPortEnabledDefaultsUpdates(t *testing.T) {
@@ -3574,7 +3575,36 @@ func TestAccContainerCluster_withAutopilotKubeletConfig(t *testing.T) {
3574
3575
})
3575
3576
}
3576
3577
3577
- func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
3578
+ // func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
3579
+ // nodePoolDefaults is not allowed on GKE Autopilot clusters, error from GKE is:
3580
+ // `Setting node_pool_defaults.node_config_defaults.node_kubelet_config is not allowed on GKE Autopilot clusters.`
3581
+ func TestAccContainerCluster_withAutopilot_withNodePoolAutoConfig(t *testing.T) {
3582
+ t.Parallel()
3583
+
3584
+ randomSuffix := acctest.RandString(t, 10)
3585
+ clusterName := fmt.Sprintf("tf-test-cluster-%s", randomSuffix)
3586
+ networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
3587
+ subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
3588
+
3589
+ acctest.VcrTest(t, resource.TestCase{
3590
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
3591
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
3592
+ CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
3593
+ Steps: []resource.TestStep{
3594
+ {
3595
+ Config: testAccContainerCluster_withAutopilot_withNodePoolAutoConfig(clusterName, networkName, subnetworkName, "FALSE"),
3596
+ },
3597
+ {
3598
+ ResourceName: "google_container_cluster.primary",
3599
+ ImportState: true,
3600
+ ImportStateVerify: true,
3601
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
3602
+ },
3603
+ },
3604
+ })
3605
+ }
3606
+
3607
+ func TestAccContainerCluster_withStandard_withNodePoolDefaults(t *testing.T) {
3578
3608
t.Parallel()
3579
3609
3580
3610
randomSuffix := acctest.RandString(t, 10)
@@ -3588,7 +3618,7 @@ func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
3588
3618
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
3589
3619
Steps: []resource.TestStep{
3590
3620
{
3591
- Config: testAccContainerCluster_withAutopilot_withNodePoolDefaults (clusterName, networkName, subnetworkName),
3621
+ Config: testAccContainerCluster_withStandard_withNodePoolDefaults (clusterName, networkName, subnetworkName, "FALSE" ),
3592
3622
},
3593
3623
{
3594
3624
ResourceName: "google_container_cluster.primary",
@@ -3601,6 +3631,7 @@ func TestAccContainerCluster_withAutopilot_withNodePoolDefaults(t *testing.T) {
3601
3631
}
3602
3632
3603
3633
3634
+
3604
3635
func TestAccContainerCluster_withAutopilotResourceManagerTags(t *testing.T) {
3605
3636
t.Parallel()
3606
3637
@@ -11480,16 +11511,57 @@ resource "google_container_cluster" "primary" {
11480
11511
location = "us-central1"
11481
11512
enable_autopilot = true
11482
11513
11514
+ node_pool_defaults {
11515
+ node_kubelet_config {
11516
+ }
11517
+ }
11518
+
11519
+ deletion_protection = false
11520
+ network = "%s"
11521
+ subnetwork = "%s"
11522
+ }
11523
+ `, name, networkName, subnetworkName)
11524
+ }
11525
+
11526
+
11527
+ func testAccContainerCluster_withAutopilot_withNodePoolAutoConfig(name, networkName, subnetworkName string, insecureKubeletReadonlyPortEnabled string) string {
11528
+ return fmt.Sprintf(`
11529
+ resource "google_container_cluster" "primary" {
11530
+ name = "%s"
11531
+ location = "us-central1"
11532
+ enable_autopilot = true
11533
+
11534
+ node_pool_auto_config {
11535
+ node_kubelet_config {
11536
+ insecure_kubelet_readonly_port_enabled = "%s"
11537
+ }
11538
+ }
11539
+
11540
+ deletion_protection = false
11541
+ network = "%s"
11542
+ subnetwork = "%s"
11543
+ }
11544
+ `, name, insecureKubeletReadonlyPortEnabled, networkName, subnetworkName)
11545
+ }
11546
+
11547
+ func testAccContainerCluster_withStandard_withNodePoolDefaults(name, networkName, subnetworkName string, insecureKubeletReadonlyPortEnabled string) string {
11548
+ return fmt.Sprintf(`
11549
+ resource "google_container_cluster" "primary" {
11550
+ name = "%s"
11551
+ location = "us-central1-a"
11552
+ initial_node_count = 1
11553
+
11483
11554
node_pool_defaults {
11484
11555
node_config_defaults {
11556
+ insecure_kubelet_readonly_port_enabled = "%s"
11485
11557
}
11486
11558
}
11487
11559
11488
11560
deletion_protection = false
11489
11561
network = "%s"
11490
11562
subnetwork = "%s"
11491
11563
}
11492
- `, name, networkName, subnetworkName)
11564
+ `, name, insecureKubeletReadonlyPortEnabled, networkName, subnetworkName)
11493
11565
}
11494
11566
11495
11567
func testAccContainerCluster_resourceManagerTags(projectID, clusterName, networkName, subnetworkName, randomSuffix string, tagResourceNumber int) string {
@@ -12880,5 +12952,4 @@ resource "google_container_cluster" "with_enterprise_config" {
12880
12952
deletion_protection = false
12881
12953
}
12882
12954
`, projectID, clusterName, networkName, subnetworkName)
12883
- }
12884
-
12955
+ }
0 commit comments