76 lines
1.8 KiB
HCL
76 lines
1.8 KiB
HCL
resource "hcloud_server" "k8s-control" {
|
|
count = var.node_count
|
|
name = "k8s-control-${count.index}"
|
|
image = var.os_type
|
|
server_type = var.server_type
|
|
location = var.location
|
|
labels = {
|
|
type = "control"
|
|
}
|
|
ssh_keys = [hcloud_ssh_key.default.id]
|
|
user_data = templatefile(
|
|
"user-data.yaml.tpl",
|
|
{
|
|
ssh_pubkey = file("../ssh-terraform-hetzner.pub")
|
|
containerd_version = var.containerd_version
|
|
docker_version = var.docker_version
|
|
}
|
|
)
|
|
firewall_ids = [hcloud_firewall.k8s-node.id]
|
|
|
|
network {
|
|
network_id = hcloud_network.k8s-nodes.id
|
|
}
|
|
|
|
connection {
|
|
type = "ssh"
|
|
user = "root"
|
|
host = self.ipv6_address # or ipv4_address if your ISP sucks
|
|
private_key = file("../ssh-terraform-hetzner")
|
|
}
|
|
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"cloud-init status --wait"
|
|
]
|
|
}
|
|
}
|
|
|
|
resource "hcloud_server" "k8s-worker" {
|
|
count = var.node_count
|
|
name = "k8s-worker-${count.index}"
|
|
image = var.os_type
|
|
server_type = var.server_type
|
|
location = var.location
|
|
labels = {
|
|
type = "worker"
|
|
}
|
|
ssh_keys = [hcloud_ssh_key.default.id]
|
|
user_data = templatefile(
|
|
"user-data.yaml.tpl",
|
|
{
|
|
ssh_pubkey = file("../ssh-terraform-hetzner.pub")
|
|
containerd_version = var.containerd_version
|
|
docker_version = var.docker_version
|
|
}
|
|
)
|
|
firewall_ids = [hcloud_firewall.k8s-node.id]
|
|
|
|
network {
|
|
network_id = hcloud_network.k8s-nodes.id
|
|
}
|
|
|
|
connection {
|
|
type = "ssh"
|
|
user = "root"
|
|
host = self.ipv6_address # or ipv4_address if your ISP sucks
|
|
private_key = file("../ssh-terraform-hetzner")
|
|
}
|
|
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"cloud-init status --wait"
|
|
]
|
|
}
|
|
}
|