Agents IP should not depend on servers_num

This commit is contained in:
Marco Nenciarini 2022-02-09 13:03:31 +01:00
parent 43de74b887
commit 0b13f900e1
No known key found for this signature in database
GPG Key ID: 589F03F01BA55038
3 changed files with 8 additions and 8 deletions

View File

@ -76,13 +76,13 @@ resource "hcloud_server" "agents" {
} }
} }
# Generating k3s agent config file # Generating k3s agent config file
provisioner "file" { provisioner "file" {
content = yamlencode({ content = yamlencode({
node-name = self.name node-name = self.name
kubelet-arg = "cloud-provider=external" kubelet-arg = "cloud-provider=external"
flannel-iface = "eth1" flannel-iface = "eth1"
node-ip = cidrhost(hcloud_network.k3s.ip_range, 2 + var.servers_num + count.index) node-ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 257 + count.index)
}) })
destination = "/etc/rancher/k3s/config.yaml" destination = "/etc/rancher/k3s/config.yaml"
@ -114,7 +114,7 @@ resource "hcloud_server" "agents" {
network { network {
network_id = hcloud_network.k3s.id network_id = hcloud_network.k3s.id
ip = cidrhost(hcloud_network.k3s.ip_range, 2 + var.servers_num + count.index) ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 257 + count.index)
} }
depends_on = [ depends_on = [

View File

@ -1,5 +1,5 @@
locals { locals {
first_control_plane_network_ip = cidrhost(hcloud_network.k3s.ip_range, 2) first_control_plane_network_ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 2)
hcloud_image_name = "ubuntu-20.04" hcloud_image_name = "ubuntu-20.04"
ssh_public_key = trimspace(file(var.public_key)) 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 is either the contents of var.private_key or null to use a ssh agent.

View File

@ -68,9 +68,9 @@ resource "hcloud_server" "control_planes" {
disable = "servicelb, local-storage" disable = "servicelb, local-storage"
flannel-iface = "eth1" flannel-iface = "eth1"
kubelet-arg = "cloud-provider=external" kubelet-arg = "cloud-provider=external"
node-ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index) node-ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 3 + count.index)
advertise-address = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index) advertise-address = cidrhost(hcloud_network_subnet.k3s.ip_range, 3 + count.index)
tls-san = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index) tls-san = cidrhost(hcloud_network_subnet.k3s.ip_range, 3 + count.index)
token = random_password.k3s_token.result token = random_password.k3s_token.result
node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"]
}) })
@ -104,7 +104,7 @@ resource "hcloud_server" "control_planes" {
network { network {
network_id = hcloud_network.k3s.id network_id = hcloud_network.k3s.id
ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index) ip = cidrhost(hcloud_network_subnet.k3s.ip_range, 3 + count.index)
} }
depends_on = [ depends_on = [