Skip to content

Commit

Permalink
feat: create before destroy for pool
Browse files Browse the repository at this point in the history
BREAKING CHANGE : use random pet to be able to create before destroy
node pool

use `wait_for_pool_ready` by default

Signed-off-by: Kevin Lefevre <[email protected]>
  • Loading branch information
ArchiFleKs committed Dec 28, 2021
1 parent 1a18d6b commit 6ea851b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ locals {
placement_group_id = null
container_runtime = "containerd"
tags = []
wait_for_pool_ready = false
wait_for_pool_ready = true
kubelet_args = null
zone = null
upgrade_policy = {
Expand Down
16 changes: 12 additions & 4 deletions node-pools.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "scaleway_k8s_pool" "this" {
region = var.region
zone = lookup(each.value, "zone", local.node_pools_defaults["zone"])
cluster_id = scaleway_k8s_cluster.this.id
name = each.key
name = "${each.key}-${random_pet.this[each.key].id}"
node_type = lookup(each.value, "node_type", local.node_pools_defaults["node_type"])
size = lookup(each.value, "size", local.node_pools_defaults["size"])
min_size = lookup(each.value, "min_size", local.node_pools_defaults["min_size"])
Expand All @@ -21,8 +21,16 @@ resource "scaleway_k8s_pool" "this" {
tags = distinct(compact(concat(lookup(each.value, "tags", local.node_pools_defaults["tags"]), var.tags)))

lifecycle {
ignore_changes = [
size
]
create_before_destroy = true
}
}

resource "random_pet" "this" {
for_each = local.node_pools
keepers = {
placement_group_id = lookup(each.value, "placement_group_id", "")
zone = lookup(each.value, "zone", "")
container_runtime = lookup(each.value, "container_runtime", "")
node_type = lookup(each.value, "node_type", "")
}
}

0 comments on commit 6ea851b

Please sign in to comment.