【发布时间】:2021-08-18 17:30:03
【问题描述】:
我们在 terraform 与 Rancher2 和 AKS 的组合中遇到了问题。我们正在使用 terraform 部署具有 aks 配置的 rancher2_cluster,同时创建一个新子网。
在尝试销毁所有内容时,我们遇到了一个问题,即 azurerm_subnet 仍被 azure 中的集群节点使用。因此无法删除。
Message="Subnet subnet_name is in use by /subscriptions/xxx-xx-xx-xx-xxx/resourceGroups/MC_cluster-resource-group-name_location/providers/Microsoft.Network/networkInterfaces/aks-node-id-nic-0/ipConfigurations/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet." Details=[]
如果我们运行 terraform destroy,在我们检查与 aks 集群相关的所有内容都在 azure 端销毁后,子网将被删除。
我们尝试使用 rancher2_sync。但到目前为止还没有效果。有没有其他方法可以实现平滑删除我们使用过的每一个资源?
作为最后的手段,我看到了在销毁之前实现睡眠的方式,在我看来这不是很好
# This resource will destroy (at least) 30 seconds after null_resource.next
resource "null_resource" "previous" {}
resource "time_sleep" "wait_30_seconds" {
depends_on = [null_resource.previous]
destroy_duration = "30s"
}
# This resource will create (potentially immediately) after null_resource.previous
resource "null_resource" "next" {
depends_on = [time_sleep.wait_30_seconds]
}
【问题讨论】:
-
对于观看此内容的任何人,解决方法都适用于卧铺 [设置为 5 分钟]。但是,使用 azurerm_kubernetes_cluster 资源时会更加顺畅。无论如何,与使用 rancher2_cluster 资源相比,这使您可以更好地控制集群本身。 Tbh,我现在已经试用了新的 v2 资源。
标签: terraform azure-aks terraform-provider-azure rancher azure-application-gateway