gpt4 book ai didi

azure - 当前映射子网创建中的 CIDR 值错误

转载 作者:行者123 更新时间:2023-12-03 05:20:28 27 4
gpt4 key购买 nike

我有一个 Azure 问题。我在 Azure 云服务中使用 terraform。我尝试在那里启动 2 个 AKS 集群。但我总是收到一个错误,说我的 CIDR 设置错误。

我在集群一中使用:

resource "azurerm_subnet" "cluster1-node-pool-subnet" {

name = "cluster1-node-pool-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.1.0/19"]

}

resource "azurerm_subnet" "cluster1-execution-nodes-subnet" {

name = "cluster1-execution-nodes-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.33.0/19"]

}

resource "azurerm_subnet" "cluster1-gpu-nodes-subnet" {
count = var.gpuNodePool ? 1 : 0
name = "execution-nodes-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.48.0/20"]

}

network_profile {
network_plugin = "azure"
service_cidr = "10.0.65.0/19"
dns_service_ip = "10.0.65.10"
docker_bridge_cidr = "172.17.0.1/16"
}

在集群二中:

resource "azurerm_subnet" "default-node-pool-subnet" {

name = "default-node-pool-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.0.0/19"]

}

resource "azurerm_subnet" "execution-nodes-subnet" {

name = "execution-nodes-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.32.0/19"]

}

resource "azurerm_subnet" "gpu-nodes-subnet" {
count = var.gpuNodePool ? 1 : 0
name = "execution-nodes-subnet"
resource_group_name = azurerm_virtual_network.cluster-vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.cluster-vnet.name
address_prefixes = ["10.0.48.0/20"]
}

network_profile {
network_plugin = "azure"
service_cidr = "10.0.64.0/19"
dns_service_ip = "10.0.64.10"
docker_bridge_cidr = "172.17.0.1/16"
}

Azur 现在告诉我前缀错误。

│ Error: creating Subnet: (Name "cluster1-node-pool-subnet" / Virtual Network Name "cluster-vnet" / Resource Group "cluster-infra-network"): network.SubnetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidCIDRNotation" Message="The address prefix 10.0.1.0/19 in resource /subscriptions/xxx/resourceGroupscluster-infra-network/providers/Microsoft.Network/virtualNetworks/cluster-vnet/subnets/cluster1-node-pool-subnet has an invalid CIDR notation. For the given prefix length, the address prefix should be 10.0.0.0/19." Details=[]

│ with azurerm_subnet.cluster1-node-pool-subnet,
│ on k8s-rtc.tf line 7, in resource "azurerm_subnet" "cluster1-node-pool-subnet":
│ 7: resource "azurerm_subnet" "cluster1-node-pool-subnet" {



│ Error: creating Subnet: (Name "cluster1-execution-nodes-subnet" / Virtual Network Name "cluster-vnet" / Resource Group "cluster-infra-network"): network.SubnetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidCIDRNotation" Message="The address prefix 10.0.33.0/19 in resource /subscriptions/xxx/resourceGroups/cluster-infra-network/providers/Microsoft.Network/virtualNetworks/cluster-vnet/subnets/cluster1-execution-nodes-subnet has an invalid CIDR notation. For the given prefix length, the address prefix should be 10.0.32.0/19." Details=[]

│ with azurerm_subnet.cluster1-execution-nodes-subnet,
│ on k8s-rtc.tf line 14, in resource "azurerm_subnet" "cluster1-execution-nodes-subnet":
│ 14: resource "azurerm_subnet" "cluster1-execution-nodes-subnet" {

在我看来,CIDR 和前缀是有效的。知道出了什么问题吗?

最佳答案

您的子网定义基本上存在两个问题:

  1. Azure 告诉您您正在使用无效的 CIDR 表示法。例如。如果是 cluster1-node-pool-subnet,则在地址前缀 ["10.0.1.0/19"] 中指定。虽然 10.0.1.0/19 是有效的 IP 地址,但它属于子网 10.0.0.0/19,并且 Azure 坚持要求您需要根据子网的网络地址。

    这同样适用于例如10.0.33.0/19 属于子网 10.0.32.0/19

  2. 这揭示了第二个问题,第一个问题解决后,Azure 将向您报告:在两个子网中,您在定义的子网中使用相同的地址前缀。为了克服这个问题,你可以使用例如["10.0.0.0/19"] 用于 cluster1-node-pool-subnet["10.1.0.0/19"] 用于 default-node-pool-subnet等等。

关于azure - 当前映射子网创建中的 CIDR 值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72721290/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com