I have created DigitalOcean Kubernetes cluster with additional node pull. Everything works great.
resource "digitalocean_kubernetes_cluster" "k8s_cluster" {
depends_on = [digitalocean_container_registry.docker_registry]
name = "dev"
region = var.region
version = "1.30.2-do.0"
registry_integration = true
node_pool {
name = "dev-pool"
size = "s-2vcpu-2gb"
auto_scale = true
min_nodes = 2
max_nodes = 4
}
}
resource "digitalocean_kubernetes_node_pool" "new_k8s_node_pool" {
cluster_id = digitalocean_kubernetes_cluster.k8s_cluster.id
name = "dev-pool-new"
size = "s-2vcpu-4gb"
auto_scale = true
min_nodes = 2
max_nodes = 4
}
But now I want to delete old node pull (dev-pool
) and keep the cluster working with the new node pool (dev-pool-new
). But when I do terraform plan
I can see that terraform is going to recreate cluster with the new node pull. I don't want to recreate cluster, I just want to delete default node pool and keep only new node pull. How can I do that? Is it available to delete default node pull without cluster recreating?
resource "digitalocean_kubernetes_cluster" "k8s_cluster" {
depends_on = [digitalocean_container_registry.docker_registry]
name = "dev"
region = var.region
version = "1.30.2-do.0"
registry_integration = true
node_pool {
name = "dev-pool-new"
size = "s-2vcpu-4gb"
auto_scale = true
min_nodes = 2
max_nodes = 4
}
}
terraform plan
output samples:
digitalocean_kubernetes_cluster.k8s_cluster must be replaced
digitalocean_kubernetes_node_pool.new_k8s_node_pool will be destroyed
The cluster must be re-created if the default node pool (the block node_pool
within digitalocean_kubernetes_cluster
) is modified for certain parameters. This is a requirement enforced by the Digital Ocean API.
If you want to modify a node pool without cluster re-creation, then you must use the additional node pool resource instead.
resource "digitalocean_kubernetes_node_pool" "new" {
cluster_id = digitalocean_kubernetes_cluster.k8s_cluster.id
name = "dev-pool-new"
size = "s-2vcpu-4gb"
auto_scale = true
min_nodes = 2
max_nodes = 4
}
Note that for your current cluster you cannot remove the default node pool without causing a cluster re-creation, but can add the new node pool.