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

vshn-lbaas-cloudscale: Add variables to control which cloudscale floating IPs to allocate #55

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/vshn-lbaas-cloudscale/hiera.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions modules/vshn-lbaas-cloudscale/main.tf
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down
18 changes: 18 additions & 0 deletions modules/vshn-lbaas-cloudscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions modules/vshn-lbaas-hieradata/templates/hieradata.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading