From d8d3d3fc2aff97734c6dab996ccd3063a195f81a Mon Sep 17 00:00:00 2001 From: aimee-889 Date: Mon, 16 Oct 2023 09:43:52 +0000 Subject: [PATCH] adjust load balancer module --- .../ionos-application-loadbalancer/main.tf | 45 ++++--------------- .../ionos-application-loadbalancer/output.tf | 4 -- .../variables.tf | 25 ++++++++--- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/modules/ionos-application-loadbalancer/main.tf b/modules/ionos-application-loadbalancer/main.tf index b493fc1..6a1b16a 100644 --- a/modules/ionos-application-loadbalancer/main.tf +++ b/modules/ionos-application-loadbalancer/main.tf @@ -19,7 +19,7 @@ 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 @@ -27,14 +27,14 @@ resource "ionoscloud_application_loadbalancer" "alb" { } -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" @@ -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 @@ -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] - } -} - +} \ No newline at end of file diff --git a/modules/ionos-application-loadbalancer/output.tf b/modules/ionos-application-loadbalancer/output.tf index 95be54f..26c3fd8 100644 --- a/modules/ionos-application-loadbalancer/output.tf +++ b/modules/ionos-application-loadbalancer/output.tf @@ -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), ".") -} \ No newline at end of file diff --git a/modules/ionos-application-loadbalancer/variables.tf b/modules/ionos-application-loadbalancer/variables.tf index f7f1cf4..246a845 100644 --- a/modules/ionos-application-loadbalancer/variables.tf +++ b/modules/ionos-application-loadbalancer/variables.tf @@ -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) } @@ -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 } \ No newline at end of file