Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ func schemaNodeConfig() *schema.Schema {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `The name of the image to use for this node.`,
Description: `The Operating System image for the node pool. This is a private feature, please contact your Google account team for allowlisting this feature.`,
},
"image_project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `The project containing the image to use for this node.`,
Description: `The GCP project storing the Operating System image for the node pool. This is a private feature, please contact your Google account team for allowlisting this feature.`,
},
},
},
Expand Down Expand Up @@ -4231,7 +4231,7 @@ func nodePoolNodeConfigUpdate(d *schema.ResourceData, config *transport_tpg.Conf
log.Printf("[INFO] Updated labels for node pool %s", name)
}

if d.HasChange(prefix + "node_config.0.image_type") {
if d.HasChange(prefix + "node_config.0.image_type") && !d.HasChange(prefix + "node_config.0.node_image_config") {
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredNodePoolId: name,
Expand Down Expand Up @@ -4472,6 +4472,9 @@ func nodePoolNodeConfigUpdate(d *schema.ResourceData, config *transport_tpg.Conf
Image: imageConfig.Image,
ImageProject: imageConfig.ImageProject,
}
if d.HasChange(prefix + "node_config.0.image_type") {
req.ImageType = d.Get(prefix + "node_config.0.image_type").(string)
}

updateF := func() error {
clusterNodePoolsUpdateCall := NewClient(config, userAgent).Projects.Locations.Clusters.NodePools.Update(nodePoolInfo.fullyQualifiedName(name), req)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,14 @@ func TestAccContainerNodePool_withNodeImageConfig(t *testing.T) {
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerNodePool_withNodeImageConfigBase(cluster, np),
},
{
ResourceName: "google_container_node_pool.with_node_image_config",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerNodePool_withNodeImageConfig(cluster, np, "test-cos-images", "test-image-project"),
ExpectError: regexp.MustCompile(`image 'test-cos-images' is not available in project 'test-image-project'`),
Expand Down Expand Up @@ -4357,6 +4365,38 @@ resource "google_container_node_pool" "with_windows_node_config" {
`, cluster, np, osversion)
}

func testAccContainerNodePool_withNodeImageConfigBase(cluster, np string) 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
networking_mode = "VPC_NATIVE"
ip_allocation_policy {}
}

resource "google_container_node_pool" "with_node_image_config" {
name = "%s"
location = "us-central1-a"
cluster = google_container_cluster.cluster.name
initial_node_count = 1
node_config {
image_type = "COS_CONTAINERD"
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
}
}
`, cluster, np)
}

func testAccContainerNodePool_withNodeImageConfig(cluster, np, imageName, imageProject string) string {
return fmt.Sprintf(`
data "google_container_engine_versions" "central1a" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,9 @@ sole_tenant_config {

<a name="nested_node_image_config"></a>The `node_image_config` block supports:

* `image` (Optional) - The name of the image to use for this node.
* `image` (Optional) - The GCP project storing the Operating System image for the node pool. This is a private feature, please contact your Google account team for allowlisting this feature.

* `image_project` (Optional) - The project containing the image to use for this node.
* `image_project` (Optional) - The GCP project storing the Operating System image for the node pool. This is a private feature, please contact your Google account team for allowlisting this feature.

<a name="nested_advanced_machine_features"></a>The `advanced_machine_features` block supports:

Expand Down