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 @@ -15,7 +15,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}
availability_zone = each.value.availability_zone
name = each.key
name = lower("${local.cluster_name}-${replace(each.value.availability_zone, "_", "")}-${length(each.value.purpose) > 0 ? "${each.value.purpose}-" : ""}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 @@ -76,7 +76,7 @@ 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}
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,8 +117,8 @@ 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}
name = each.key
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}
name = lower("${local.cluster_name}-${replace(each.value.availability_zone, "_", "")}-${length(each.value.purpose) > 0 ? "${each.value.purpose}-" : ""}nodepool-${each.value.nodepool_index}")
location = var.datacenter_location
size = each.value.auto_scaling ? each.value.max_node_count + 1 : each.value.node_count + 1
}
Loading