terraform-google-kubernetes-engine icon indicating copy to clipboard operation
terraform-google-kubernetes-engine copied to clipboard

google_container_node_pool create before destroy issue

Open dyu-bot opened this issue 3 years ago • 2 comments

TL;DR

When trying to change a machine type for a nodepool, using create_before_destroy to upgrade, getting error that the default nodepool already exists.

Expected behavior

Expect a new nodepool with the new machine type to be created (with a new name), old nodepool to be cordoned, drained, and deleted

Observed behavior

│ Error: resource - ***/default-node-pool-7d4f - already exists
│
│   with module.***.google_container_node_pool.pools["default-node-pool"],

Terraform Configuration

Only setting changed was machine-type

Terraform Version

Terraform v1.1.7
+ provider registry.terraform.io/hashicorp/google v3.90.1
+ provider registry.terraform.io/hashicorp/google-beta v3.90.1

Additional information

No response

dyu-bot avatar Oct 05 '22 16:10 dyu-bot

Hi @dyu-bot Could you post a sample configuration so we can try to repro?

bharathkkb avatar Oct 06 '22 18:10 bharathkkb

I have been looking into this as well.

I believe this is because we are setting name in the google_container_node_pool instead of name_prefix, and hence, since the node pool already exists, tf throws an error about it. I believe if we switch to using name_prefix instead of name, this should get sorted.

Using beta-private-cluster as an example https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/master/modules/beta-private-cluster/cluster.tf#L421 <-- where name gets set instead of name_prefix

ee07dazn avatar Oct 14 '22 04:10 ee07dazn

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Dec 13 '22 23:12 github-actions[bot]