【问题标题】:Terraform Create Ingress Application Gateway in AKS Node Resource GroupTerraform 在 AKS 节点资源组中创建入口应用程序网关
【发布时间】:2022-01-21 15:39:52
【问题描述】:

AKS节点资源组在创建AKS集群之前不能已经存在,所以在同一个节点资源组中创建应用网关意味着需要在AKS集群之后创建应用网关。但是在 AKS 集群中指定了 ingress 应用程序网关插件,这使得循环依赖:

resource "azurerm_kubernetes_cluster" "example" {
    ...
    ingress_application_gateway {
      enabled    = true
      gateway_id = azurerm_application_gateway.example.id
    }
}

resource "azurerm_application_gateway" "example" {
    ...
    resource_group_name = azurerm_kubernetes_cluster.example.node_resource_group
}

谁能告诉我如何在 AKS 节点资源组中创建入口应用程序网关?非常感谢

【问题讨论】:

    标签: terraform azure-aks terraform-provider-azure azure-application-gateway


    【解决方案1】:

    无法在 AKS 节点资源组中部署应用网关,因为您需要在 AKS 之前创建应用网关,并且 AKS 节点资源组不能是现有资源组。

    我在我的环境中使用 AKS 资源块 中的 可选参数 进行了相同的测试,您可以提及node_resource_group 的名称。


    我创建了一个资源组并在那里部署了应用程序网关,然后在AKS资源块中提到使用 same rg 作为 节点资源组,如下所示:

    data "azurerm_resource_group" "example" { #existing resource group where the AKS is being deployed
      name="ansumantest"
    }
    resource "azurerm_resource_group" "noderg" {#new resource group where app gateway will be deployed and used as node resource group for AKS
      name     = "AKS_MG-ansumanaks-eastus"
      location = "East US"
    }
    resource "azurerm_application_gateway" "network" {
      name                = "ansuman-appgw"
      resource_group_name = azurerm_resource_group.noderg.name
      location            = azurerm_resource_group.noderg.location
    .....
    }
    resource "azurerm_kubernetes_cluster" "example" {
      name                = "ansuman-aks1"
      location            = data.azurerm_resource_group.example.location
      resource_group_name = data.azurerm_resource_group.example.name
      dns_prefix          = "ansumanaks1"
      node_resource_group = azurerm_application_gateway.network.resource_group_name ##uses the appgw rg as Node rsource group
    
    addon_profile {
      ingress_application_gateway {
        enabled    = true
        gateway_id = azurerm_application_gateway.network.id
      }
    }
    ....
    }
    

    输出:

    因此,您可以在 同一资源组中创建 应用程序网关,其中 正在创建网络组件AKS

    【讨论】:

      猜你喜欢
      • 2020-12-20
      • 2020-06-17
      • 1970-01-01
      • 2018-09-27
      • 2020-11-18
      • 2019-05-19
      • 2023-01-03
      • 1970-01-01
      • 2019-01-26
      相关资源
      最近更新 更多