feat: compute subnet
This commit is contained in:
@@ -12,7 +12,7 @@ resource "hcloud_ssh_key" "main" {
|
|||||||
|
|
||||||
// The Jumphost/NAT, to interact and provide internet access to the cluster.
|
// The Jumphost/NAT, to interact and provide internet access to the cluster.
|
||||||
resource "hcloud_server" "nat" {
|
resource "hcloud_server" "nat" {
|
||||||
name = "Cluster NAT"
|
name = "nat"
|
||||||
image = "debian-12"
|
image = "debian-12"
|
||||||
server_type = "cx23"
|
server_type = "cx23"
|
||||||
placement_group_id = hcloud_placement_group.group.id
|
placement_group_id = hcloud_placement_group.group.id
|
||||||
@@ -25,7 +25,10 @@ resource "hcloud_server" "nat" {
|
|||||||
|
|
||||||
public_net {
|
public_net {
|
||||||
ipv4_enabled = true
|
ipv4_enabled = true
|
||||||
|
ipv6_enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
depends_on = [hcloud_network_subnet.subnet]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private compute instances.
|
// Private compute instances.
|
||||||
@@ -41,4 +44,10 @@ resource "hcloud_server" "server" {
|
|||||||
network_id = hcloud_network.net.id
|
network_id = hcloud_network.net.id
|
||||||
ip = each.value
|
ip = each.value
|
||||||
}
|
}
|
||||||
|
public_net {
|
||||||
|
ipv4_enabled = false
|
||||||
|
ipv6_enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
depends_on = [hcloud_network_subnet.subnet]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,14 @@ resource "hcloud_network" "net" {
|
|||||||
ip_range = local.net-cidr
|
ip_range = local.net-cidr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up private subnet, for compute.
|
||||||
|
resource "hcloud_network_subnet" "subnet" {
|
||||||
|
network_id = hcloud_network.net.id
|
||||||
|
type = "cloud"
|
||||||
|
network_zone = "eu-central"
|
||||||
|
ip_range = local.subnet-cidr
|
||||||
|
}
|
||||||
|
|
||||||
// Provide internet to the private servers, by sending all internet traffic to
|
// Provide internet to the private servers, by sending all internet traffic to
|
||||||
// the NAT.
|
// the NAT.
|
||||||
resource "hcloud_network_route" "gateway" {
|
resource "hcloud_network_route" "gateway" {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
locals {
|
locals {
|
||||||
net-cidr = "10.0.0.0/8"
|
net-cidr = "10.0.0.0/8"
|
||||||
|
subnet-cidr = "10.0.2.0/24"
|
||||||
|
|
||||||
nat-private-ip = "10.0.1.5"
|
nat-private-ip = "10.0.1.5"
|
||||||
servers = {
|
servers = {
|
||||||
Node0 = "10.0.2.0"
|
node-0 = "10.0.2.0"
|
||||||
Node1 = "10.0.2.1"
|
node-1 = "10.0.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user