changed the agent_nodepools to be a list
This commit is contained in:
parent
f825142720
commit
2b7d2722c5
@ -12,11 +12,11 @@ module "agents" {
|
||||
placement_group_id = hcloud_placement_group.k3s.id
|
||||
location = var.location
|
||||
server_type = each.value.server_type
|
||||
ipv4_subnet_id = hcloud_network_subnet.subnet[index(keys(var.agent_nodepools), each.value.nodepool_name) + 2].id
|
||||
ipv4_subnet_id = hcloud_network_subnet.subnet[[for i, v in var.agent_nodepools : i if v.name == each.value.nodepool_name][0] + 2].id
|
||||
|
||||
# We leave some room so 100 eventual Hetzner LBs that can be created perfectly safely
|
||||
# It leaves the subnet with 254 x 254 - 100 = 64416 IPs to use, so probably enough.
|
||||
private_ipv4 = cidrhost(local.network_ipv4_subnets[index(keys(var.agent_nodepools), each.value.nodepool_name) + 2], each.value.index + 101)
|
||||
private_ipv4 = cidrhost(local.network_ipv4_subnets[[for i, v in var.agent_nodepools : i if v.name == each.value.nodepool_name][0] + 2], each.value.index + 101)
|
||||
|
||||
labels = {
|
||||
"provisioner" = "terraform",
|
||||
|
@ -1,6 +1,6 @@
|
||||
locals {
|
||||
# if we are in a single cluster config, we use the default klipper lb instead of Hetzner LB
|
||||
is_single_node_cluster = var.control_plane_count + length(keys(var.agent_nodepools)) == 1
|
||||
is_single_node_cluster = var.control_plane_count + length(var.agent_nodepools) == 1
|
||||
ssh_public_key = trimspace(file(var.public_key))
|
||||
# ssh_private_key is either the contents of var.private_key or null to use a ssh agent.
|
||||
ssh_private_key = var.private_key == null ? null : trimspace(file(var.private_key))
|
||||
@ -170,10 +170,10 @@ locals {
|
||||
install_k3s_agent = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_START=true INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_CHANNEL=${var.initial_k3s_channel} INSTALL_K3S_EXEC=agent sh -"], local.apply_k3s_selinux)
|
||||
|
||||
agent_nodepools = merge([
|
||||
for nodepool_name, nodepool_obj in var.agent_nodepools : {
|
||||
for nodepool_obj in var.agent_nodepools : {
|
||||
for index in range(nodepool_obj.count) :
|
||||
format("%s-%s", nodepool_name, index) => {
|
||||
nodepool_name : nodepool_name,
|
||||
format("%s-%s", nodepool_obj.name, index) => {
|
||||
nodepool_name : nodepool_obj.name,
|
||||
server_type : nodepool_obj.server_type,
|
||||
index : index
|
||||
}
|
||||
|
@ -28,17 +28,21 @@ control_plane_server_type = "cpx11"
|
||||
|
||||
# As for the agent nodepools, below is just an example, if you do not want nodepools, just use one,
|
||||
# and change the name to what you want, it need not be "agent-big" or "agent-small", also give them the subnet prefer.
|
||||
# For single node clusters set this equal to {}
|
||||
agent_nodepools = {
|
||||
agent-big = {
|
||||
# For single node clusters set this equal to [] or just set the counts to 0
|
||||
# IMPORTANT: Once the cluster is created, you can change the count, and even set it to 0, but do not remove a nodepool from the list.
|
||||
# You can add others at the end of the list if you want.
|
||||
agent_nodepools = [
|
||||
{
|
||||
name = "agent-small",
|
||||
server_type = "cpx11",
|
||||
count = 2
|
||||
},
|
||||
{
|
||||
name = "agent-large",
|
||||
server_type = "cpx21",
|
||||
count = 1
|
||||
}
|
||||
agent-small = {
|
||||
server_type = "cpx11",
|
||||
count = 2
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
# That will depend on how much load you want it to handle, see https://www.hetzner.com/cloud/load-balancer
|
||||
load_balancer_type = "lb11"
|
||||
|
@ -53,8 +53,8 @@ variable "load_balancer_disable_ipv6" {
|
||||
|
||||
variable "agent_nodepools" {
|
||||
description = "Number of agent nodes."
|
||||
type = map(any)
|
||||
default = {}
|
||||
type = list(any)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "hetzner_ccm_version" {
|
||||
|
Loading…
Reference in New Issue
Block a user