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

Add variables to control which cloudscale floating IPs to allocate #85

Merged
merged 3 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
7 changes: 5 additions & 2 deletions lb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ module "lb" {
team = var.team
additional_networks = var.additional_lb_networks
use_existing_vips = var.use_existing_vips
enable_api_vip = var.enable_api_vip
enable_router_vip = var.enable_router_vip
enable_nat_vip = var.enable_nat_vip

router_backends = var.infra_count > 0 ? module.infra.ip_addresses[*] : module.worker.ip_addresses[*]
bootstrap_node = var.bootstrap_count > 0 ? cidrhost(var.privnet_cidr, 10) : ""
bootstrap_node = var.bootstrap_count > 0 ? cidrhost(local.privnet_cidr, 10) : ""
lb_cloudscale_api_secret = var.lb_cloudscale_api_secret
hieradata_repo_user = var.hieradata_repo_user
internal_vip = cidrhost(var.privnet_cidr, 100)
internal_vip = cidrhost(local.privnet_cidr, 100)
enable_proxy_protocol = var.lb_enable_proxy_protocol
}
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
output "dns_entries" {
value = templatefile("${path.module}/templates/dns.zone", {
"node_name_suffix" = local.node_name_suffix,
"api_vip" = var.lb_count != 0 ? split("/", module.lb.api_vip[0].network)[0] : ""
"router_vip" = var.lb_count != 0 ? split("/", module.lb.router_vip[0].network)[0] : ""
"egress_vip" = var.lb_count != 0 ? split("/", module.lb.nat_vip[0].network)[0] : ""
"api_vip" = var.enable_api_vip && var.lb_count != 0 ? split("/", module.lb.api_vip[0].network)[0] : ""
"router_vip" = var.enable_router_vip && var.lb_count != 0 ? split("/", module.lb.router_vip[0].network)[0] : ""
"egress_vip" = var.enable_nat_vip && var.lb_count != 0 ? split("/", module.lb.nat_vip[0].network)[0] : ""
"internal_vip" = cidrhost(local.privnet_cidr, 100),
"masters" = module.master.ip_addresses,
"cluster_id" = var.cluster_id,
Expand Down
14 changes: 10 additions & 4 deletions templates/dns.zone
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
; Cluster ${cluster_id}
$ORIGIN ${node_name_suffix}.

api IN A ${api_vip}
api-int IN A ${internal_vip}
ingress IN A ${router_vip}
egress IN A ${egress_vip}
%{ if api_vip != "" ~}
api IN A ${api_vip}
%{ endif ~}
api-int IN A ${internal_vip}
%{ if router_vip != "" ~}
ingress IN A ${router_vip}
%{ endif ~}
%{ if egress_vip != "" ~}
egress IN A ${egress_vip}
%{ endif ~}

*.apps IN CNAME ingress.${node_name_suffix}.

Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,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
}