1
0
Fork 0
This repository has been archived on 2025-08-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mareshq-cthulhunetes-infras.../machines.tf

113 lines
2.7 KiB
HCL

locals {
control_plane_nodes = 1
}
# 58639934
resource "hcloud_primary_ip" "cthulhu_control_plane" {
count = local.control_plane_nodes
name = "control-plane-${count.index}"
type = "ipv4"
assignee_type = "server"
assignee_id = hcloud_server.cthulhu_control_plane[count.index].id
auto_delete = false
delete_protection = true
}
resource "hcloud_server" "cthulhu_control_plane" {
count = local.control_plane_nodes
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 = false
}
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)
}
}
module "workers_v2" {
source = "./modules/node-pool/v1"
network_id = hcloud_network.cthulhu.id
placement_group_id = hcloud_placement_group.cthulhu_workers.id
ssh_key_ids = [data.hcloud_ssh_key.vojtechmares.id]
size = 3
server_type = "cx32"
image = "rocky-9"
location = "fsn1"
subnet_cidr = "172.16.11.0/24"
cluster_name = "cthulhu"
}