resource "hcloud_network" "kube-network" { name = "kube-network" ip_range = "10.0.0.0/16" } resource "hcloud_network_subnet" "kube-subnet" { network_id = hcloud_network.kube-network.id type = "cloud" network_zone = "eu-central" ip_range = "10.0.1.0/24" } resource "hcloud_ssh_key" "default" { name = "YubiKey" public_key = file("~/.ssh/id_ed25519_sk.pub") } resource "hcloud_server" "control-plane" { count = 0 name = "control-plane" server_type = "cx21" image = "ubuntu-22.04" location = "nbg1" network { network_id = hcloud_network.kube-network.id ip = "10.0.1.1" } depends_on = [ hcloud_network_subnet.kube-subnet ] user_data = templatefile("${path.module}/templates/tailscale-kube-control-plane.yaml.tpl", { tailscale_key = var.tailscale_key }) ssh_keys = [hcloud_ssh_key.default.id] } resource "hcloud_server" "worker-node" { count = 0 name = "worker-node-${count.index + 1}" server_type = "cx21" image = "ubuntu-22.04" location = "nbg1" network { network_id = hcloud_network.kube-network.id ip = "10.0.1.${count.index + 2}" } depends_on = [ hcloud_network_subnet.kube-subnet ] user_data = templatefile("${path.module}/templates/tailscale-kube-worker.yaml.tpl", { tailscale_key = var.tailscale_key }) ssh_keys = [hcloud_ssh_key.default.id] }