Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Wilson 779e4fe6b2 use snapshots instead of hetzner images 3 years ago
Michael Wilson b65658d120 make image name configurable 3 years ago
Michael Wilson 039042b608 disable rescue mode 3 years ago
Michael Wilson 2d62bf5e94 fix dependencies 3 years ago
Michael Wilson cc54d6bd0e add placement group 3 years ago
  1. 22
      hcloud-k3s-cluster/main.tf
  2. 6
      hcloud-k3s-cluster/vars.tf

@ -31,15 +31,16 @@ resource "hcloud_ssh_key" "pubkey" {
resource "hcloud_server" "k3s-node" {
count = var.node_count
name = "k3s-node-${count.index + 1}"
image = "ubuntu-22.04"
image = data.hcloud_image.packer_snapshot.id
server_type = var.server_type
ssh_keys = [ "${hcloud_ssh_key.pubkey.id}" ]
location = var.server_location
rescue = "linux64"
firewall_ids = [ hcloud_firewall.fw.id ]
placement_group_id = hcloud_placement_group.k3s-cluster-nodes.id
depends_on = [
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
}

@ -14,6 +14,12 @@ variable "hetznerdns_token" {
description = "hetznerdns API token"
}
variable "snapshot_selector" {
type = string
description = "snapshot selector for server creation"
default = "os-flavor=debian"
}
variable "node_count" {
type = number
default = 3

Loading…
Cancel
Save