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

Cannot import GKE without nodepool block definition #9427

Closed
puzzloholic opened this issue Jun 24, 2021 · 3 comments
Closed

Cannot import GKE without nodepool block definition #9427

puzzloholic opened this issue Jun 24, 2021 · 3 comments
Assignees
Labels

Comments

@puzzloholic
Copy link

Hi,

Currently I have live production GKE cluster, and I want to manage it with Terraform. Is there any way to separate nodepool resource management, so the nodepool block is not imported within google_container_cluster resource?

Right now I have multiple google_container_node_pool resource from importing each nodepool, but multiple nodepool blocks also exists in google_container_cluster resource. If I want to remove those nodepool blocks, google_container_cluster must be force replaced .

@venkykuberan venkykuberan self-assigned this Jun 24, 2021
@venkykuberan
Copy link
Contributor

@puzzloholic so you imported both the cluster and node_pool resources, right ?. You should be able to remove it from the cluster without recreating the cluster. Can you share both the cluster & node_pool config.

@puzzloholic
Copy link
Author

@venkykuberan, I manage to switch nodepool management to google_container_node_pool resource using this step on my own. This is my findings.

This is my resource config after importing the cluster and each of the nodepool.

resource "google_container_cluster" "k8s_cluster" {
  # other configs

  node_pool {
    # node_pool 1 config
  }

  node_pool {
    # node_pool 2 config
  }

  node_pool {
    # node_pool 3 config
  }

  # other configs
}

resource "google_container_node_pool" "pool_1" {
  # node_pool 1 config
}

resource "google_container_node_pool" "pool_2" {
  # node_pool 2 config
}

resource "google_container_node_pool" "pool_3" {
  # node_pool 3 config
}

What I want to remove is all node_pool block inside resource google_container_cluster.k8s_prod.
First I try to remove 1 node_pool block, and terraform indicates that google_container_cluster.k8s_prod must be replaced because node_pool block

But, when I try removing all node_pool blocks, surpisingly, terraform did not detect any changes on the state.

So, that's it, I manage to move node pool management to resource google_container_node_pool by removing all node_pool blocks in resource google_container_cluster

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants