traefik deletes successfully
This commit is contained in:
parent
6739b4a493
commit
115163b8be
20
main.tf
20
main.tf
@ -159,19 +159,29 @@ data "hcloud_load_balancer" "traefik" {
|
|||||||
depends_on = [null_resource.kustomization]
|
depends_on = [null_resource.kustomization]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "null_resource" "destroy_lb" {
|
|
||||||
|
resource "null_resource" "destroy_traefik_loadbalancer" {
|
||||||
|
# this only gets triggered before total destruction of the cluster, but when the necessary elements to run the commands are still available
|
||||||
triggers = {
|
triggers = {
|
||||||
token = random_password.k3s_token.result
|
kustomization_id = null_resource.kustomization.id
|
||||||
}
|
}
|
||||||
|
|
||||||
# Important when issuing terraform destroy, otherwise the LB will not let the network get deleted
|
# Important when issuing terraform destroy, otherwise the LB will not let the network get deleted
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
when = destroy
|
when = destroy
|
||||||
command = <<-EOT
|
command = <<-EOT
|
||||||
hcloud load-balancer delete traefik
|
kubectl -n kube-system delete service traefik --kubeconfig ${path.module}/kubeconfig.yaml
|
||||||
hcloud network delete k3s
|
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
on_failure = continue
|
on_failure = continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
local_file.kubeconfig,
|
||||||
|
null_resource.control_planes[0],
|
||||||
|
hcloud_network_subnet.k3s,
|
||||||
|
hcloud_network.k3s,
|
||||||
|
hcloud_firewall.k3s,
|
||||||
|
hcloud_placement_group.k3s,
|
||||||
|
hcloud_ssh_key.k3s
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user