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

Move to using for_each for node pools #257

Merged
merged 9 commits into from
Jan 22, 2020

Conversation

Dev25
Copy link
Contributor

@Dev25 Dev25 commented Sep 5, 2019

Use for_each instead of count/index for managing node pools. This is going to be a breaking change for users and they will need to manually edit the state to migrate node pools over.

State Migration:

  • Remove existing state: terraform state rm module.<name>.google_container_node_pool.pools
  • Import each node pool: terraform import 'module.<name>.google_container_node_pool.pools["name"]' {region}/{cluster}{name}
    • Example: terraform import 'module.gke.google_container_node_pool.pools["spot-pool"]' europe-west1/dev-cluster/spot-pool

Fixes #128

autogen/main.tf Outdated Show resolved Hide resolved
@Dev25 Dev25 marked this pull request as ready for review September 6, 2019 17:31
@aaron-lane aaron-lane added the enhancement New feature or request label Sep 6, 2019
Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delayed response here: some basic feedback and also we'll need to rebase.

autogen/variables.tf Outdated Show resolved Hide resolved
autogen/variables.tf Outdated Show resolved Hide resolved
autogen/cluster.tf Outdated Show resolved Hide resolved
@@ -225,62 +225,63 @@ resource "google_container_node_pool" "pools" {
{% else %}
provider = google
{% endif %}
count = length(var.node_pools)
name = var.node_pools[count.index]["name"]
for_each = var.node_pools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the external interface as list but build the map internally within the module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will keep the existing interface via having this in locals:

node_pool_names = [for np in toset(var.node_pools) : np.name]
node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools)))

@morgante
Copy link
Contributor

morgante commented Dec 1, 2019

@Dev25 Just checking if you think you'll be able to make the requested changes (and rebase)?

@Dev25
Copy link
Contributor Author

Dev25 commented Dec 1, 2019

Yep, hopefully within the next week or 2 @morgante

@Dev25
Copy link
Contributor Author

Dev25 commented Dec 9, 2019

Rebased and kept the same external interface @morgante

Will be porting over my existing clusters to this rebased version this week which should further test it, PTAL

@Dev25
Copy link
Contributor Author

Dev25 commented Dec 29, 2019

@morgante Can you take another look now? CI is passing after the recent master fixes.

@morgante morgante merged commit 7d0c9aa into terraform-google-modules:master Jan 22, 2020
kri5 pushed a commit to kri5/terraform-google-kubernetes-engine that referenced this pull request Jan 27, 2020
…#257)

BREAKING CHANGE: moves node pool state location to allow using for_each on them
viglesiasce pushed a commit to GoogleCloudPlatform/solutions-modern-cicd-anthos that referenced this pull request May 5, 2020
Also:
* Pinning the terraform-google-kubernetes-engine module to 6.2.0
  due to breaking change: terraform-google-modules/terraform-google-kubernetes-engine#257
* Cleaning buckets before removing them (TF fails otherwise)

Fixes: http://b/148036307

Change-Id: Icde3335ee8690190ac87c46a9cbde265f263e84c
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
…#257)

BREAKING CHANGE: moves node pool state location to allow using for_each on them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change node pool resources to use for_each
3 participants