From fd0e9018f2baa71402e79e6df1cf690e3708ba16 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Tue, 16 Jul 2024 13:38:30 +0200 Subject: [PATCH 1/2] vshn-lbaas-hieradata: Make `api` and `router` fields in `floating_addresses` optional --- modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl b/modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl index 7356dca..3372ab1 100644 --- a/modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl +++ b/modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl @@ -15,11 +15,15 @@ profile_openshift4_gateway::private_interfaces: - ${if} %{ endfor ~} profile_openshift4_gateway::floating_addresses: +%{ if api_vip != "" ~} api: ${api_vip} +%{ endif ~} %{ if nat_vip != "" ~} nat: ${nat_vip} %{ endif ~} +%{ if router_vip != "" ~} router: ${router_vip} +%{ endif ~} profile_openshift4_gateway::floating_address_provider: ${cloud_provider} %{ if internal_vip != "" ~} profile_openshift4_gateway::internal_vip: ${internal_vip} From 1dab34417cd419bbc5f3ff0614841232f8b87cb0 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Tue, 16 Jul 2024 13:39:05 +0200 Subject: [PATCH 2/2] vshn-lbaas-cloudscale: Add variables to control which cloudscale floating IPs are allocated --- modules/vshn-lbaas-cloudscale/hiera.tf | 6 +++--- modules/vshn-lbaas-cloudscale/main.tf | 6 +++--- modules/vshn-lbaas-cloudscale/variables.tf | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/vshn-lbaas-cloudscale/hiera.tf b/modules/vshn-lbaas-cloudscale/hiera.tf index 389b7ab..42ba9ad 100644 --- a/modules/vshn-lbaas-cloudscale/hiera.tf +++ b/modules/vshn-lbaas-cloudscale/hiera.tf @@ -17,10 +17,10 @@ module "hiera" { ingress_controller = var.ingress_controller lb_names = random_id.lb[*].hex hieradata_repo_user = var.hieradata_repo_user - api_vip = cidrhost(local.api_vip[0].network, 0) + api_vip = var.enable_api_vip ? cidrhost(local.api_vip[0].network, 0) : "" internal_vip = var.internal_vip - nat_vip = cidrhost(local.nat_vip[0].network, 0) - router_vip = cidrhost(local.router_vip[0].network, 0) + nat_vip = var.enable_nat_vip ? cidrhost(local.nat_vip[0].network, 0) : "" + router_vip = var.enable_router_vip ? cidrhost(local.router_vip[0].network, 0) : "" team = var.team enable_proxy_protocol = var.enable_proxy_protocol diff --git a/modules/vshn-lbaas-cloudscale/main.tf b/modules/vshn-lbaas-cloudscale/main.tf index 5d5a6f8..890057b 100644 --- a/modules/vshn-lbaas-cloudscale/main.tf +++ b/modules/vshn-lbaas-cloudscale/main.tf @@ -1,5 +1,5 @@ resource "cloudscale_floating_ip" "api_vip" { - count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0 + count = var.lb_count != 0 && !var.use_existing_vips && var.enable_api_vip ? 1 : 0 ip_version = 4 region_slug = var.region reverse_ptr = "api.${var.node_name_suffix}" @@ -20,7 +20,7 @@ data "cloudscale_floating_ip" "api_vip" { } resource "cloudscale_floating_ip" "router_vip" { - count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0 + count = var.lb_count != 0 && !var.use_existing_vips && var.enable_router_vip ? 1 : 0 ip_version = 4 region_slug = var.region reverse_ptr = "ingress.${var.node_name_suffix}" @@ -41,7 +41,7 @@ data "cloudscale_floating_ip" "router_vip" { } resource "cloudscale_floating_ip" "nat_vip" { - count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0 + count = var.lb_count != 0 && !var.use_existing_vips && var.enable_nat_vip ? 1 : 0 ip_version = 4 region_slug = var.region reverse_ptr = "egress.${var.node_name_suffix}" diff --git a/modules/vshn-lbaas-cloudscale/variables.tf b/modules/vshn-lbaas-cloudscale/variables.tf index f74a645..80b70a1 100644 --- a/modules/vshn-lbaas-cloudscale/variables.tf +++ b/modules/vshn-lbaas-cloudscale/variables.tf @@ -112,3 +112,21 @@ variable "use_existing_vips" { description = "Use existing floating IPs for api_vip, router_vip and nat_vip. Manually set the reverse DNS info, so the correct data source is found." default = false } + +variable "enable_api_vip" { + type = bool + description = "Whether to configure a cloudscale floating IP for the API" + default = true +} + +variable "enable_router_vip" { + type = bool + description = "Whether to configure a cloudscale floating IP for the router" + default = true +} + +variable "enable_nat_vip" { + type = bool + description = "Whether to configure a cloudscale floating IP for the default gateway NAT" + default = true +}