1
0
Fork 0

feat: add terraform

This commit is contained in:
Vojtěch Mareš 2024-05-13 09:46:54 +02:00
parent 1614412d2a
commit 43708777b4
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
10 changed files with 379 additions and 1 deletions

80
machines.tf Normal file
View file

@ -0,0 +1,80 @@
resource "hcloud_server" "cthulhu_control_plane" {
count = 1
name = "control-plane-${count.index}"
image = "rocky-9"
server_type = "cax11"
location = "fsn1"
backups = true
shutdown_before_deletion = true
placement_group_id = hcloud_placement_group.cthulhu_control_plane.id
# 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.control_plane.ip_range, count.index + 1)
}
}
resource "random_string" "workers_suffix" {
length = 4
special = false
upper = false
}
resource "hcloud_server" "cthulhu_workers" {
count = 3
name = "worker-${random_string.workers_suffix.result}-${count.index}"
image = "rocky-9"
server_type = "cax21"
location = "fsn1"
backups = false
shutdown_before_deletion = true
placement_group_id = hcloud_placement_group.cthulhu_workers.id
# 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)
}
}