|
|
|
@ -31,15 +31,16 @@ resource "hcloud_ssh_key" "pubkey" { |
|
|
|
resource "hcloud_server" "k3s-node" { |
|
|
|
resource "hcloud_server" "k3s-node" { |
|
|
|
count = var.node_count |
|
|
|
count = var.node_count |
|
|
|
name = "k3s-node-${count.index + 1}" |
|
|
|
name = "k3s-node-${count.index + 1}" |
|
|
|
image = "ubuntu-22.04" |
|
|
|
image = data.hcloud_image.packer_snapshot.id |
|
|
|
server_type = var.server_type |
|
|
|
server_type = var.server_type |
|
|
|
ssh_keys = [ "${hcloud_ssh_key.pubkey.id}" ] |
|
|
|
ssh_keys = [ "${hcloud_ssh_key.pubkey.id}" ] |
|
|
|
location = var.server_location |
|
|
|
location = var.server_location |
|
|
|
rescue = "linux64" |
|
|
|
|
|
|
|
firewall_ids = [ hcloud_firewall.fw.id ] |
|
|
|
firewall_ids = [ hcloud_firewall.fw.id ] |
|
|
|
|
|
|
|
placement_group_id = hcloud_placement_group.k3s-cluster-nodes.id |
|
|
|
depends_on = [ |
|
|
|
depends_on = [ |
|
|
|
hcloud_network_subnet.k3s-net, |
|
|
|
hcloud_network_subnet.k3s-net, |
|
|
|
hcloud_firewall.fw |
|
|
|
hcloud_firewall.fw, |
|
|
|
|
|
|
|
hcloud_placement_group.k3s-cluster-nodes |
|
|
|
] |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -159,3 +160,18 @@ resource "hcloud_firewall" "fw" { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# placement group |
|
|
|
|
|
|
|
resource "hcloud_placement_group" "k3s-cluster-nodes" { |
|
|
|
|
|
|
|
name = "k3s-cluster-nodes" |
|
|
|
|
|
|
|
type = "spread" |
|
|
|
|
|
|
|
labels = { |
|
|
|
|
|
|
|
key = "value" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# packer snapshot |
|
|
|
|
|
|
|
data "hcloud_image" "packer_snapshot" { |
|
|
|
|
|
|
|
with_selector = var.snapshot_selector |
|
|
|
|
|
|
|
most_recent = true |
|
|
|
|
|
|
|
} |
|
|
|
|