Skip to content

Commit 1d60270

Browse files
authored
Support attaching FIPs to login nodes (#572)
1 parent 74ddc28 commit 1d60270

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

environments/skeleton/{{cookiecutter.environment}}/tofu/login.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module "login" {
2323
# optionally set for group
2424
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
2525
extra_volumes = lookup(each.value, "extra_volumes", {})
26+
fip_addresses = lookup(each.value, "fip_addresses", [])
27+
fip_network = lookup(each.value, "fip_network", "")
2628

2729
# can't be set for login
2830
compute_init_enable = []

environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/nodes.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ resource "openstack_compute_instance_v2" "compute" {
151151

152152
}
153153

154+
resource "openstack_networking_floatingip_associate_v2" "fip" {
155+
for_each = {for idx in range(length(var.fip_addresses)): var.nodes[idx] => var.fip_addresses[idx]} # zip, fip_addresses can be shorter
156+
157+
floating_ip = each.value
158+
port_id = openstack_networking_port_v2.compute["${each.key}-${length(var.networks) == 1 ? var.networks[0].network : var.fip_network}"].id
159+
160+
}
161+
154162
output "compute_instances" {
155163
value = local.compute_instances
156164
}

environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,22 @@ variable "networks" {
9595
type = list(map(string))
9696
default = []
9797
}
98+
99+
variable "fip_addresses" {
100+
type = list(string)
101+
description = <<-EOT
102+
List of addresses of floating IPs to associate with nodes,
103+
in same order as nodes parameter. The floating IPs must already be
104+
allocated to the project.
105+
EOT
106+
default = []
107+
}
108+
109+
variable "fip_network" {
110+
type = string
111+
description = <<-EOT
112+
Name of network containing ports to attach FIPs to. Only required if multiple
113+
networks are defined.
114+
EOT
115+
default = ""
116+
}

environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ variable "login" {
5353
Values are a mapping with:
5454
size: Size of volume in GB
5555
**NB**: The order in /dev is not guaranteed to match the mapping
56+
fip_addresses: List of addresses of floating IPs to associate with nodes,
57+
in the same order as nodes parameter. The floating IPs
58+
must already be allocated to the project.
59+
fip_network: Name of network containing ports to attach FIPs to. Only
60+
required if multiple networks are defined.
61+
5662
EOF
5763
}
5864

0 commit comments

Comments
 (0)