added a default subnet for the lb to use and not usurp node subnets

This commit is contained in:
Karim Naufal 2022-03-05 06:04:08 +01:00
parent ed23ba3735
commit 7f11b21d46

10
main.tf
View File

@ -13,12 +13,22 @@ resource "hcloud_network" "k3s" {
ip_range = var.network_ipv4_range
}
# This is the default subnet to be used by the load balancer.
resource "hcloud_network_subnet" "default" {
network_id = hcloud_network.k3s.id
type = "cloud"
network_zone = var.network_region
ip_range = "10.0.0.0/16"
}
resource "hcloud_network_subnet" "subnet" {
for_each = var.network_ipv4_subnets
network_id = hcloud_network.k3s.id
type = "cloud"
network_zone = var.network_region
ip_range = each.value
depends_on = [hcloud_network_subnet.default]
}
resource "hcloud_firewall" "k3s" {