Added Hetzner firewall and fixed addresses
This commit is contained in:
23
master.tf
23
master.tf
@@ -1,17 +1,17 @@
|
||||
resource "hcloud_server" "first_control_plane" {
|
||||
name = "k3s-control-plane-0"
|
||||
|
||||
image = data.hcloud_image.linux.name
|
||||
server_type = local.control_plane_server_type
|
||||
location = local.server_locations[0][1]
|
||||
image = data.hcloud_image.linux.name
|
||||
server_type = var.control_plane_server_type
|
||||
location = var.location
|
||||
ssh_keys = [hcloud_ssh_key.default.id]
|
||||
firewall_ids = [hcloud_firewall.k3s.id]
|
||||
|
||||
ssh_keys = [hcloud_ssh_key.default.id]
|
||||
|
||||
labels = {
|
||||
provisioner = "terraform",
|
||||
engine = "k3s",
|
||||
node_type = "control-plane"
|
||||
k3s_upgrade = "true"
|
||||
"provisioner" = "terraform",
|
||||
"engine" = "k3s",
|
||||
"k3s_upgrade" = "true"
|
||||
}
|
||||
|
||||
user_data = data.template_cloudinit_config.init_cfg.rendered
|
||||
@@ -28,7 +28,7 @@ resource "hcloud_server" "first_control_plane" {
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"curl -sfL https://get.k3s.io | K3S_TOKEN=${random_password.k3s_cluster_secret.result} sh -s - server --cluster-init ${var.k3s_extra_args}",
|
||||
"curl -sfL https://get.k3s.io | K3S_TOKEN=${random_password.k3s_cluster_secret.result} sh -s - server --cluster-init --node-ip=${local.first_control_plane_network_ip} --advertise-address=${local.first_control_plane_network_ip} --tls-san=${local.first_control_plane_network_ip} ${var.k3s_server_flags}",
|
||||
"until systemctl is-active --quiet k3s.service; do sleep 1; done",
|
||||
"until kubectl get node ${self.name}; do sleep 1; done",
|
||||
"kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${hcloud_network.k3s.name}",
|
||||
@@ -62,10 +62,11 @@ resource "hcloud_server" "first_control_plane" {
|
||||
|
||||
network {
|
||||
network_id = hcloud_network.k3s.id
|
||||
ip = local.first_control_plane_ip
|
||||
ip = local.first_control_plane_network_ip
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
hcloud_network_subnet.k3s
|
||||
hcloud_network_subnet.k3s,
|
||||
hcloud_firewall.k3s
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user