tweak to cluster provisioning null ressource, destroy, and moved lb waiting to master.tf
This commit is contained in:
parent
133ca38d22
commit
9380b70bbe
33
main.tf
33
main.tf
@ -162,34 +162,13 @@ data "hcloud_load_balancer" "traefik" {
|
||||
|
||||
resource "null_resource" "cluster_provisioning" {
|
||||
|
||||
triggers = {
|
||||
agent_ids = "${join(",", module.agents.*.id)}"
|
||||
control_plane_ids = "${join(",", concat([module.first_control_plane.id], module.control_planes.*.id))}"
|
||||
}
|
||||
|
||||
depends_on = [null_resource.first_control_plane, null_resource.control_planes, null_resource.agents]
|
||||
|
||||
provisioner "remote-exec" {
|
||||
connection {
|
||||
user = "root"
|
||||
private_key = local.ssh_private_key
|
||||
agent_identity = local.ssh_identity
|
||||
host = module.first_control_plane.ipv4_address
|
||||
}
|
||||
|
||||
inline = [
|
||||
<<-EOT
|
||||
timeout 120 bash <<EOF
|
||||
until [ -n "\$(kubectl get -n kube-system service/traefik --output=jsonpath='{.status.loadBalancer.ingress[0].ip}')" ]; do
|
||||
echo "Waiting for load-balancer to get an IP..."
|
||||
done
|
||||
EOF
|
||||
EOT
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
when = destroy
|
||||
command = "hcloud load-balancer delete traefik"
|
||||
command = <<-EOT
|
||||
hcloud load-balancer delete traefik
|
||||
hcloud network delete k3s
|
||||
EOT
|
||||
}
|
||||
|
||||
depends_on = [null_resource.first_control_plane]
|
||||
}
|
||||
|
10
master.tf
10
master.tf
@ -157,7 +157,15 @@ resource "null_resource" "first_control_plane" {
|
||||
"kubectl apply -k /tmp/post_install",
|
||||
"echo 'Waiting for the system-upgrade-controller deployment to become available...'",
|
||||
"kubectl -n system-upgrade wait --for=condition=available --timeout=120s deployment/system-upgrade-controller",
|
||||
"kubectl -n system-upgrade apply -f /tmp/post_install/plans.yaml"
|
||||
"kubectl -n system-upgrade apply -f /tmp/post_install/plans.yaml",
|
||||
<<-EOT
|
||||
timeout 120 bash <<EOF
|
||||
until [ -n "\$(kubectl get -n kube-system service/traefik --output=jsonpath='{.status.loadBalancer.ingress[0].ip}' 2> /dev/null)" ]; do
|
||||
echo "Waiting for load-balancer to get an IP..."
|
||||
sleep 2
|
||||
done
|
||||
EOF
|
||||
EOT
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user