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

Ops 4221 change node names #19

Merged
merged 11 commits into from
Dec 19, 2023
8 changes: 4 additions & 4 deletions modules/ionos-k8s-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "ionoscloud_k8s_cluster" "cluster" {
#----

resource "ionoscloud_k8s_node_pool" "nodepool_scaling" {
for_each = {for np in local.nodepool_per_zone_creator : "${np.availability_zone}-${np.purpose}-${np.nodepool_index}" => np if np.auto_scaling == true}
for_each = {for np in local.nodepool_per_zone_creator : lower("${local.cluster_name}-${replace(np.availability_zone, "_", "")}-${length(np.purpose) > 0 ? "${np.purpose}-" : ""}nodepool-${np.nodepool_index}") => np if np.auto_scaling == true}
aimee-889 marked this conversation as resolved.
Show resolved Hide resolved
availability_zone = each.value.availability_zone
name = each.key
k8s_version = ionoscloud_k8s_cluster.cluster.k8s_version
Expand Down Expand Up @@ -73,10 +73,10 @@ resource "ionoscloud_k8s_node_pool" "nodepool_scaling" {
#----

resource "ionoscloud_k8s_node_pool" "nodepool_legacy" {
for_each = {for np in local.nodepool_per_zone_creator : "${np.availability_zone}-${np.purpose}-${np.nodepool_index}" => np if np.auto_scaling == false}
for_each = {for np in local.nodepool_per_zone_creator : lower("${local.cluster_name}-${replace(np.availability_zone, "_", "")}-${length(np.purpose) > 0 ? "${np.purpose}-" : ""}nodepool-${np.nodepool_index}") => np if np.auto_scaling == false}
aimee-889 marked this conversation as resolved.
Show resolved Hide resolved
availability_zone = each.value.availability_zone
#The name needs to be changed, not only legacy pools have auto_scaling= false and thus we need an additional check
name = each.value.purpose != "legacy" ? each.key : each.value.availability_zone == "ZONE_1" ? "${local.cluster_name}-zone1-nodepool-${each.value.nodepool_index}":"${local.cluster_name}-zone2-nodepool-${each.value.nodepool_index}"
name = each.value.purpose != "legacy" ? each.key : lower("${local.cluster_name}-${replace(each.value.availability_zone, "_", "")}-nodepool-${each.value.nodepool_index}")
k8s_version = ionoscloud_k8s_cluster.cluster.k8s_version
allow_replace = each.value.allow_node_pool_replacement
# the lans are created as a dynamic block - they help to dynamically construct repeatable nested blocks
Expand Down Expand Up @@ -117,7 +117,7 @@ resource "ionoscloud_k8s_node_pool" "nodepool_legacy" {
}

resource "ionoscloud_ipblock" "ippools" {
for_each = {for np in local.nodepool_per_zone_creator : "${np.availability_zone}-${np.purpose}-${np.nodepool_index}" => np if np.create_public_ip_pools == true}
for_each = {for np in local.nodepool_per_zone_creator : lower("${local.cluster_name}-${replace(np.availability_zone, "_", "")}-${length(np.purpose) > 0 ? "${np.purpose}-" : ""}nodepool-${np.nodepool_index}") => np if np.create_public_ip_pools == true}
name = each.key
location = var.datacenter_location
size = each.value.auto_scaling ? each.value.max_node_count + 1 : each.value.node_count + 1
Expand Down
Loading