49 lines
1.1 KiB
HCL
49 lines
1.1 KiB
HCL
resource "hcloud_network" "k8s_net" {
|
|
name = "k8s-net"
|
|
ip_range = "172.16.0.0/12"
|
|
}
|
|
|
|
resource "hcloud_network_subnet" "k8s_internal" {
|
|
network_id = hcloud_network.k8s_net.id
|
|
type = "cloud"
|
|
network_zone = "eu-central"
|
|
ip_range = "172.23.2.0/23"
|
|
}
|
|
|
|
resource "hcloud_ssh_key" "default" {
|
|
name = "Default Management"
|
|
public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKfHZaI0F5GjAcrM8hjWqwMfULDkAZ2TOIBTQtRocg1F id_ed25519"
|
|
}
|
|
|
|
resource "hcloud_server" "nodes" {
|
|
for_each = var.vms
|
|
|
|
name = each.key
|
|
server_type = each.value.server_type
|
|
datacenter = "hel1-dc2"
|
|
image = "ubuntu-22.04"
|
|
|
|
backups = each.value.backups
|
|
|
|
ssh_keys = [
|
|
hcloud_ssh_key.default.id
|
|
]
|
|
|
|
labels = {
|
|
"node_type" = each.value.node_type
|
|
"cluster" = "icb4dc0.de"
|
|
}
|
|
|
|
public_net {
|
|
ipv4_enabled = true
|
|
ipv6_enabled = true
|
|
}
|
|
}
|
|
|
|
resource "hcloud_server_network" "k8s_internal" {
|
|
for_each = var.vms
|
|
|
|
server_id = hcloud_server.nodes[each.key].id
|
|
network_id = hcloud_network.k8s_net.id
|
|
ip = each.value.private_ip
|
|
}
|