1
0
Fork 0

feat: add all of the terraform files

Signed-off-by: Vojtech Mares <iam@vojtechmares.com>
This commit is contained in:
Vojtěch Mareš 2024-01-22 15:03:40 +01:00
parent 4dff9a8639
commit 3a2ac8bc50
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
9 changed files with 453 additions and 0 deletions

76
terraform/machines.tf Normal file
View file

@ -0,0 +1,76 @@
resource "hcloud_server" "cthulhu_masters" {
count = 1
name = "master-${count.index}"
image = "rocky-9"
server_type = "cax11"
location = "fsn1"
backups = true
shutdown_before_deletion = true
firewall_ids = [
hcloud_firewall.cthulhu_nodes_public.id,
hcloud_firewall.cthulhu_nodes_private.id,
]
ssh_keys = [data.hcloud_ssh_key.vojtechmares.id]
labels = {
"k8s.node.role" = "master"
"k8s.node.name" = "master-${count.index}"
"k8s.cluster.name" = "cthulhu"
}
public_net {
ipv4_enabled = true
ipv6_enabled = true
}
network {
network_id = hcloud_network.cthulhu.id
ip = cidrhost(hcloud_network_subnet.masters.ip_range, count.index + 1)
}
}
resource "random_string" "workers_suffix" {
length = 4
special = false
upper = false
}
resource "hcloud_server" "cthulhu_workers" {
count = 1
name = "worker-${random_string.workers_suffix.result}-${count.index}"
image = "rocky-9"
server_type = "cpx31"
location = "fsn1"
backups = true
shutdown_before_deletion = true
firewall_ids = [
hcloud_firewall.cthulhu_nodes_public.id,
hcloud_firewall.cthulhu_nodes_private.id,
]
ssh_keys = [data.hcloud_ssh_key.vojtechmares.id]
labels = {
"k8s.node.role" = "worker"
"k8s.node.name" = "worker-${random_string.workers_suffix.result}-${count.index}"
"k8s.cluster.name" = "cthulhu"
"k8s.node.pool" = random_string.workers_suffix.result
}
public_net {
ipv4_enabled = true
ipv6_enabled = true
}
network {
network_id = hcloud_network.cthulhu.id
ip = cidrhost(hcloud_network_subnet.workers.ip_range, count.index + 1)
}
}