Skip to content

Commit

Permalink
adjust load balancer module
Browse files Browse the repository at this point in the history
  • Loading branch information
aimee-889 committed Oct 16, 2023
1 parent 6175a76 commit d8d3d3f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 47 deletions.
45 changes: 8 additions & 37 deletions modules/ionos-application-loadbalancer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ resource "ionoscloud_ipblock" "alb" {

resource "ionoscloud_application_loadbalancer" "alb" {
datacenter_id = var.datacenter_id
name = "ALB Kubernetes"
name = "${module.conventions_coordinates.global_identifier}-alb"
listener_lan = ionoscloud_lan.alb_listener_lan.id
ips = [ionoscloud_ipblock.alb.ips[0]]
target_lan = var.alb_target_lan_id
lb_private_ips = [ "${local.node_ip_part}.225/24" ]

}

resource "ionoscloud_application_loadbalancer_forwardingrule" "forwoard_k8s" {
resource "ionoscloud_application_loadbalancer_forwardingrule" "forward_k8s" {
datacenter_id = var.datacenter_id
application_loadbalancer_id = ionoscloud_application_loadbalancer.alb.id
name = "ALB FR"
name = "forward-k8s"
protocol = "HTTP"
listener_ip = ionoscloud_ipblock.alb.ips[0]
listener_port = 443
client_timeout = 1000
listener_port = var.alb_listener_port
client_timeout = var.alb_client_timeout
http_rules {
name = "FORWARD_K8S"
type = "FORWARD"
Expand All @@ -47,14 +47,14 @@ resource "ionoscloud_application_loadbalancer_forwardingrule" "forwoard_k8s" {


resource "ionoscloud_target_group" "k8s_node_pools" {
name = "TG K8s Node Pools"
name = "${module.conventions_coordinates.global_identifier}-k8s"
algorithm = "ROUND_ROBIN"
protocol = "HTTP"
dynamic "targets" {
for_each = var.node_alb_lan_ips
content {
ip = "${targets.value}"
port = "30080"
port = var.alb_tg_target_port
weight = "1"
health_check_enabled = false
maintenance_enabled = false
Expand All @@ -71,33 +71,4 @@ resource "ionoscloud_target_group" "k8s_node_pools" {
match_type = "STATUS_CODE"
response = "200"
}
}

resource "opentelekomcloud_dns_recordset_v2" "dnsentry" {
count = 1
zone_id = data.opentelekomcloud_dns_zone_v2.dns_zone.id
name = lower("${var.dns_record_name}.")
ttl = 300
type = "A"
records = [ionoscloud_ipblock.alb.ips[0]]
depends_on = [
ionoscloud_ipblock.alb
]
lifecycle {
ignore_changes = [zone_id]
}
}

resource "opentelekomcloud_dns_recordset_v2" "wildcardentry" {
count = 1
zone_id = data.opentelekomcloud_dns_zone_v2.dns_zone.id
name = lower("*.${var.dns_record_name}")
ttl = 300
type = "CNAME"
records = ["${module.conventions_coordinates.cluster_dns}."]

lifecycle {
ignore_changes = [zone_id]
}
}

}
4 changes: 0 additions & 4 deletions modules/ionos-application-loadbalancer/output.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
output "alb_ip" {
value = ionoscloud_ipblock.alb.ips[0]
}

output "loadbalancer_ip" {
value = trim(join("", opentelekomcloud_dns_recordset_v2.dnsentry.*.name), ".")
}
25 changes: 19 additions & 6 deletions modules/ionos-application-loadbalancer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ variable "alb_target_lan_id" {
description = "The LAN to connect your Application Loadbalancer to"
}

variable "dns_record_name" {
type = string
description = "DNS record name that points to Application Loadbalancer"
}

variable "coordinates" {
type = map(any)
}
Expand All @@ -44,5 +39,23 @@ variable "node_alb_lan_ips" {

variable "ssl_cert_ids" {
type = list
description = "List of cert ids of wildcard certificates"
description = "Array of certificate ids. You can create certificates with the certificate resource"
}

variable "alb_client_timeout" {
type = number
description = "The maximum time in milliseconds to wait for the client to acknowledge or send data; default is 50,000 (50 seconds)"
default = 60000
}

variable "alb_listener_port" {
type = number
description = "Listening (inbound) port number; valid range is 1 to 65535"
default = 443
}

variable "alb_tg_target_port" {
type = string
description = "The port of the balanced target service; valid range is 1 to 65535 used in target group"
default = 30080
}

0 comments on commit d8d3d3f

Please sign in to comment.