2022-12-16 17:42:21 +00:00
|
|
|
resource "hcloud_network" "kube-network" {
|
|
|
|
name = "kube-network"
|
2022-12-17 19:22:47 +00:00
|
|
|
ip_range = "10.0.0.0/16"
|
2022-12-17 00:24:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_network_subnet" "kube-subnet" {
|
2023-02-05 20:57:17 +00:00
|
|
|
network_id = hcloud_network.kube-network.id
|
|
|
|
type = "cloud"
|
2022-12-17 00:24:27 +00:00
|
|
|
network_zone = "eu-central"
|
2023-02-05 20:57:17 +00:00
|
|
|
ip_range = "10.0.1.0/24"
|
2022-12-16 17:42:21 +00:00
|
|
|
}
|
2022-12-17 00:24:27 +00:00
|
|
|
|
2022-12-17 19:22:47 +00:00
|
|
|
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", {
|
2023-02-05 20:57:17 +00:00
|
|
|
tailscale_key = var.tailscale_key
|
2022-12-17 19:22:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
ssh_keys = [hcloud_ssh_key.default.id]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_server" "worker-node" {
|
|
|
|
count = 0
|
2023-02-05 20:57:17 +00:00
|
|
|
name = "worker-node-${count.index + 1}"
|
2022-12-17 19:22:47 +00:00
|
|
|
server_type = "cx21"
|
|
|
|
image = "ubuntu-22.04"
|
|
|
|
location = "nbg1"
|
|
|
|
|
|
|
|
network {
|
2023-02-05 20:57:17 +00:00
|
|
|
network_id = hcloud_network.kube-network.id
|
|
|
|
ip = "10.0.1.${count.index + 2}"
|
2022-12-17 19:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
hcloud_network_subnet.kube-subnet
|
|
|
|
]
|
|
|
|
|
|
|
|
user_data = templatefile("${path.module}/templates/tailscale-kube-worker.yaml.tpl", {
|
2023-02-05 20:57:17 +00:00
|
|
|
tailscale_key = var.tailscale_key
|
2022-12-17 19:22:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
ssh_keys = [hcloud_ssh_key.default.id]
|
|
|
|
}
|