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
|
|
@ -1,5 +1,13 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.7.0] - 2024-11-23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add node pool module
|
||||||
|
- Add new node pool using the new module
|
||||||
|
- Using Intel-based instead of ARM-based CPUs
|
||||||
|
|
||||||
## [0.6.0] - 2024-11-23
|
## [0.6.0] - 2024-11-23
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
17
machines.tf
17
machines.tf
|
|
@ -94,3 +94,20 @@ resource "hcloud_server" "cthulhu_workers" {
|
||||||
ip = cidrhost(hcloud_network_subnet.workers.ip_range, count.index + 1)
|
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"
|
||||||
|
}
|
||||||
|
|
|
||||||
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
40
modules/node-pool/v1/variables.tf
Normal file
40
modules/node-pool/v1/variables.tf
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
variable "network_id" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "placement_group_id" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "size" {
|
||||||
|
type = number
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "server_type" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "location" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "image" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "cluster_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ssh_key_ids" {
|
||||||
|
type = list(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "subnet_cidr" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "primary_ip_auto_delete" {
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
8
modules/node-pool/v1/versions.tf
Normal file
8
modules/node-pool/v1/versions.tf
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
hcloud = {
|
||||||
|
source = "hetznercloud/hcloud"
|
||||||
|
version = ">=1.47.0, <2.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue