feat: add node pool module and use it for new node pool
This commit is contained in:
parent
f916e715e5
commit
b8b0a7ce22
5 changed files with 118 additions and 0 deletions
45
modules/node-pool/v1/main.tf
Normal file
45
modules/node-pool/v1/main.tf
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
resource "random_string" "suffix" {
|
||||
length = 4
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "hcloud_network_subnet" "pool" {
|
||||
network_id = var.network_id
|
||||
type = "cloud"
|
||||
network_zone = "eu-central"
|
||||
ip_range = var.subnet_cidr
|
||||
}
|
||||
|
||||
resource "hcloud_server" "pool" {
|
||||
count = var.size
|
||||
|
||||
name = "pool-${random_string.suffix.result}-${count.index + 1}"
|
||||
image = var.image
|
||||
server_type = var.server_type
|
||||
location = var.location
|
||||
|
||||
backups = false
|
||||
shutdown_before_deletion = true
|
||||
|
||||
placement_group_id = var.placement_group_id
|
||||
|
||||
ssh_keys = var.ssh_key_ids
|
||||
|
||||
labels = {
|
||||
"k8s.node.role" = "worker"
|
||||
"k8s.node.name" = "pool-${random_string.suffix.result}-${count.index}"
|
||||
"k8s.cluster.name" = var.cluster_name
|
||||
"k8s.node.pool" = random_string.suffix.result
|
||||
}
|
||||
|
||||
public_net {
|
||||
ipv4_enabled = true
|
||||
ipv6_enabled = false
|
||||
}
|
||||
|
||||
network {
|
||||
network_id = var.network_id
|
||||
ip = cidrhost(hcloud_network_subnet.pool.ip_range, count.index + 1)
|
||||
}
|
||||
}
|
||||
Reference in a new issue