Skip to content

Commit 994bc20

Browse files
committed
Add support for floating IPv6 addresses for Control Plane nodes
Signed-off-by: Mateusz Paluszkiewicz <theaifam5@gmail.com>
1 parent 3af89e1 commit 994bc20

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

floating_ip.tf

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ locals {
55
var.control_plane_public_vip_ipv4_enabled
66
)
77
)
8+
control_plane_public_vip_ipv6_enabled = (
9+
local.network_public_ipv6_enabled && (
10+
var.control_plane_public_vip_ipv6_id != null ||
11+
var.control_plane_public_vip_ipv6_enabled
12+
)
13+
)
814
}
915

1016
resource "hcloud_floating_ip" "control_plane_ipv4" {
@@ -13,7 +19,22 @@ resource "hcloud_floating_ip" "control_plane_ipv4" {
1319
name = "${var.cluster_name}-control-plane-ipv4"
1420
type = "ipv4"
1521
home_location = hcloud_server.control_plane[local.talos_primary_node_name].location
16-
description = "Control Plane Public VIP"
22+
description = "Control Plane Public VIPv4"
23+
delete_protection = var.cluster_delete_protection
24+
25+
labels = {
26+
cluster = var.cluster_name,
27+
role = "control-plane"
28+
}
29+
}
30+
31+
resource "hcloud_floating_ip" "control_plane_ipv6" {
32+
count = local.control_plane_public_vip_ipv6_enabled && var.control_plane_public_vip_ipv6_id == null ? 1 : 0
33+
34+
name = "${var.cluster_name}-control-plane-ipv6"
35+
type = "ipv6"
36+
home_location = hcloud_server.control_plane[local.talos_primary_node_name].location
37+
description = "Control Plane Public VIPv6"
1738
delete_protection = var.cluster_delete_protection
1839

1940
labels = {
@@ -30,3 +51,12 @@ data "hcloud_floating_ip" "control_plane_ipv4" {
3051
local.control_plane_public_vip_ipv4_enabled ? try(hcloud_floating_ip.control_plane_ipv4[0].id, null) : null
3152
)
3253
}
54+
55+
data "hcloud_floating_ip" "control_plane_ipv6" {
56+
count = local.control_plane_public_vip_ipv6_enabled ? 1 : 0
57+
58+
id = coalesce(
59+
can(var.control_plane_public_vip_ipv6_id) ? var.control_plane_public_vip_ipv6_id : null,
60+
local.control_plane_public_vip_ipv6_enabled ? try(hcloud_floating_ip.control_plane_ipv6[0].id, null) : null
61+
)
62+
}

talos_config.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ locals {
170170
dhcp = true
171171
dhcpOptions = {
172172
ipv4 = var.talos_public_ipv4_enabled
173-
ipv6 = false
173+
ipv6 = var.talos_public_ipv6_enabled
174174
}
175175
vip = local.control_plane_public_vip_ipv4_enabled ? {
176176
ip = local.control_plane_public_vip_ipv4

variables.tf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,31 @@ variable "firewall_talos_api_source" {
230230
variable "control_plane_public_vip_ipv4_enabled" {
231231
type = bool
232232
default = false
233-
description = "If true, a floating IP will be created and assigned to the Control Plane nodes."
233+
description = "If true, a floating IPv4 will be created and assigned to the Control Plane nodes."
234+
}
235+
236+
variable "control_plane_private_vip_ipv4_enabled" {
237+
type = bool
238+
default = true
239+
description = "If true, an alias IPv4 will be created and assigned to the Control Plane nodes."
234240
}
235241

236242
variable "control_plane_public_vip_ipv4_id" {
237243
type = number
238244
default = null
239-
description = "Specifies the Floating IP ID for the Control Plane nodes. A new floating IP will be created if this is set to null."
245+
description = "Specifies the Floating IPv4 ID for the Control Plane nodes. A new floating IPv4 will be created if this is set to null."
240246
}
241247

242-
variable "control_plane_private_vip_ipv4_enabled" {
248+
variable "control_plane_public_vip_ipv6_enabled" {
243249
type = bool
244-
default = true
245-
description = "If true, an alias IP will be created and assigned to the Control Plane nodes."
250+
default = false
251+
description = "If true, a floating IPv6 will be created and assigned to the Control Plane nodes."
252+
}
253+
254+
variable "control_plane_public_vip_ipv6_id" {
255+
type = number
256+
default = null
257+
description = "Specifies the Floating IPv6 ID for the Control Plane nodes. A new floating IPv6 will be created if this is set to null."
246258
}
247259

248260
variable "kube_api_admission_control" {

0 commit comments

Comments
 (0)