commit
b45d7a468c
@ -12,7 +12,6 @@ module "agents" {
|
|||||||
placement_group_id = hcloud_placement_group.k3s.id
|
placement_group_id = hcloud_placement_group.k3s.id
|
||||||
location = var.location
|
location = var.location
|
||||||
network_id = hcloud_network.k3s.id
|
network_id = hcloud_network.k3s.id
|
||||||
ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 513 + each.value.index)
|
|
||||||
server_type = each.value.server_type
|
server_type = each.value.server_type
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
@ -45,7 +44,7 @@ resource "null_resource" "agents" {
|
|||||||
token = random_password.k3s_token.result
|
token = random_password.k3s_token.result
|
||||||
kubelet-arg = "cloud-provider=external"
|
kubelet-arg = "cloud-provider=external"
|
||||||
flannel-iface = "eth1"
|
flannel-iface = "eth1"
|
||||||
node-ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 513 + each.value.index)
|
node-ip = module.agents[each.key].ipv4_address
|
||||||
node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : []
|
node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : []
|
||||||
})
|
})
|
||||||
destination = "/tmp/config.yaml"
|
destination = "/tmp/config.yaml"
|
||||||
|
@ -33,7 +33,7 @@ locals {
|
|||||||
|
|
||||||
agent_nodepools = merge([
|
agent_nodepools = merge([
|
||||||
for nodepool_name, nodepool_obj in var.agent_nodepools : {
|
for nodepool_name, nodepool_obj in var.agent_nodepools : {
|
||||||
for index in range(nodepool_obj.count) :
|
for index in range(lookup(nodepool_obj, "count", var.agents_num)) :
|
||||||
format("%s-%s", nodepool_name, index) => {
|
format("%s-%s", nodepool_name, index) => {
|
||||||
index : index, # just for the compatibility with previous structure
|
index : index, # just for the compatibility with previous structure
|
||||||
server_type : nodepool_obj.server_type
|
server_type : nodepool_obj.server_type
|
||||||
|
@ -14,7 +14,7 @@ resource "hcloud_server" "server" {
|
|||||||
|
|
||||||
network {
|
network {
|
||||||
network_id = var.network_id
|
network_id = var.network_id
|
||||||
ip = var.ip
|
ip = try(var.ip, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
connection {
|
connection {
|
||||||
|
@ -60,6 +60,7 @@ variable "network_id" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable "ip" {
|
variable "ip" {
|
||||||
|
default = null
|
||||||
description = "The IP"
|
description = "The IP"
|
||||||
type = string
|
type = string
|
||||||
nullable = true
|
nullable = true
|
||||||
|
@ -12,7 +12,6 @@ module "control_planes" {
|
|||||||
placement_group_id = hcloud_placement_group.k3s.id
|
placement_group_id = hcloud_placement_group.k3s.id
|
||||||
location = var.location
|
location = var.location
|
||||||
network_id = hcloud_network.k3s.id
|
network_id = hcloud_network.k3s.id
|
||||||
ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 257 + count.index)
|
|
||||||
server_type = var.control_plane_server_type
|
server_type = var.control_plane_server_type
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
|
@ -16,16 +16,16 @@ lb_server_type = "lb11"
|
|||||||
servers_num = 3
|
servers_num = 3
|
||||||
|
|
||||||
# For agent nodes, at least 2 is recommended for HA, but you can keep automatic upgrades.
|
# For agent nodes, at least 2 is recommended for HA, but you can keep automatic upgrades.
|
||||||
|
agents_num = 2
|
||||||
|
|
||||||
agent_nodepools = {
|
agent_nodepools = {
|
||||||
big = {
|
big = {
|
||||||
server_type = "cpx31",
|
server_type = "cpx31",
|
||||||
count = 3
|
count = 1
|
||||||
|
}
|
||||||
|
small = {
|
||||||
|
server_type = "cpx21",
|
||||||
}
|
}
|
||||||
# Will fail because of the ip address collision (we use index number)
|
|
||||||
# small = {
|
|
||||||
# server_type = "cpx31",
|
|
||||||
# count = 3
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# If you want to use a specific Hetzner CCM and CSI version, set them below, otherwise leave as is for the latest versions
|
# If you want to use a specific Hetzner CCM and CSI version, set them below, otherwise leave as is for the latest versions
|
||||||
|
10
variables.tf
10
variables.tf
@ -52,12 +52,14 @@ variable "servers_num" {
|
|||||||
type = number
|
type = number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "agents_num" {
|
||||||
|
description = "Default agent server type"
|
||||||
|
type = number
|
||||||
|
}
|
||||||
|
|
||||||
variable "agent_nodepools" {
|
variable "agent_nodepools" {
|
||||||
description = "Number of agent nodes."
|
description = "Number of agent nodes."
|
||||||
type = map(object({
|
type = map(any)
|
||||||
server_type = string
|
|
||||||
count = number
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "hetzner_ccm_version" {
|
variable "hetzner_ccm_version" {
|
||||||
|
Loading…
Reference in New Issue
Block a user