microOS eth1 still down
This commit is contained in:
63
temp/agents.tf
Normal file
63
temp/agents.tf
Normal file
@@ -0,0 +1,63 @@
|
||||
resource "hcloud_server" "agents" {
|
||||
count = var.agents_num
|
||||
name = "k3s-agent-${count.index}"
|
||||
|
||||
image = data.hcloud_image.linux.name
|
||||
rescue = "linux64"
|
||||
server_type = var.agent_server_type
|
||||
location = var.location
|
||||
ssh_keys = [hcloud_ssh_key.k3s.id]
|
||||
firewall_ids = [hcloud_firewall.k3s.id]
|
||||
placement_group_id = hcloud_placement_group.k3s_placement_group.id
|
||||
|
||||
|
||||
labels = {
|
||||
"provisioner" = "terraform",
|
||||
"engine" = "k3s",
|
||||
"k3s_upgrade" = "true"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
content = templatefile("${path.module}/templates/agent.tpl", {
|
||||
name = self.name
|
||||
ssh_public_key = local.ssh_public_key
|
||||
k3s_token = random_password.k3s_token.result
|
||||
master_ip = local.first_control_plane_network_ip
|
||||
node_ip = cidrhost(hcloud_network.k3s.ip_range, 2 + var.servers_num + count.index)
|
||||
})
|
||||
destination = "/tmp/config.yaml"
|
||||
|
||||
connection {
|
||||
user = "root"
|
||||
private_key = local.ssh_private_key
|
||||
agent_identity = local.ssh_identity
|
||||
host = self.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = local.microOS_install_commands
|
||||
|
||||
connection {
|
||||
user = "root"
|
||||
private_key = local.ssh_private_key
|
||||
agent_identity = local.ssh_identity
|
||||
host = self.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "sleep 60 && ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 100"
|
||||
}
|
||||
|
||||
network {
|
||||
network_id = hcloud_network.k3s.id
|
||||
ip = cidrhost(hcloud_network.k3s.ip_range, 2 + var.servers_num + count.index)
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
hcloud_server.first_control_plane,
|
||||
hcloud_network_subnet.k3s
|
||||
]
|
||||
}
|
9
temp/output.tf
Normal file
9
temp/output.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
output "controlplanes_public_ip" {
|
||||
value = concat([hcloud_server.first_control_plane.ipv4_address], hcloud_server.control_planes.*.ipv4_address)
|
||||
description = "The public IP addresses of the controlplane server."
|
||||
}
|
||||
|
||||
output "agents_public_ip" {
|
||||
value = hcloud_server.agents.*.ipv4_address
|
||||
description = "The public IP addresses of the agent server."
|
||||
}
|
62
temp/servers.tf
Normal file
62
temp/servers.tf
Normal file
@@ -0,0 +1,62 @@
|
||||
resource "hcloud_server" "control_planes" {
|
||||
count = var.servers_num - 1
|
||||
name = "k3s-control-plane-${count.index + 1}"
|
||||
|
||||
image = data.hcloud_image.linux.name
|
||||
rescue = "linux64"
|
||||
server_type = var.control_plane_server_type
|
||||
location = var.location
|
||||
ssh_keys = [hcloud_ssh_key.k3s.id]
|
||||
firewall_ids = [hcloud_firewall.k3s.id]
|
||||
placement_group_id = hcloud_placement_group.k3s_placement_group.id
|
||||
|
||||
labels = {
|
||||
"provisioner" = "terraform",
|
||||
"engine" = "k3s",
|
||||
"k3s_upgrade" = "true"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
content = templatefile("${path.module}/templates/server.tpl", {
|
||||
name = self.name
|
||||
ssh_public_key = local.ssh_public_key
|
||||
k3s_token = random_password.k3s_token.result
|
||||
master_ip = local.first_control_plane_network_ip
|
||||
node_ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
||||
})
|
||||
destination = "/tmp/config.yaml"
|
||||
|
||||
connection {
|
||||
user = "root"
|
||||
private_key = local.ssh_private_key
|
||||
agent_identity = local.ssh_identity
|
||||
host = self.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = local.microOS_install_commands
|
||||
|
||||
connection {
|
||||
user = "root"
|
||||
private_key = local.ssh_private_key
|
||||
agent_identity = local.ssh_identity
|
||||
host = self.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "sleep 60 && ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 100"
|
||||
}
|
||||
|
||||
network {
|
||||
network_id = hcloud_network.k3s.id
|
||||
ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
hcloud_server.first_control_plane,
|
||||
hcloud_network_subnet.k3s
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user