Azure 容器应用环境工作负载配置文件中的湿作业问题

问题描述 投票:0回答:1

我在将 Azure 容器应用程序环境从“仅使用”迁移到“工作负载配置文件”时遇到问题。 我的设置是中心辐射方案,其中辐射包含连接到 10.70.10.0/23 范围内的 VNET/子网的容器应用程序环境。 “仅消费”场景中的所有容器也获得了该范围内的IP。有一个连接到子网的路由表,它将所有流量路由到对等中心 VNET 中的防火墙。这一切都运行良好。见下图。 enter image description here 迁移到“工作负载配置文件”后,所有容器都会获得 100.100.x.x IP。似乎不再有流量通过路由表路由。我无法再访问任何本地服务,似乎防火墙上也有流量进入。 enter image description here

azure azure-virtual-network azure-container-apps
1个回答
0
投票

这是您所做的一个很好的故障排除,我正在将我们的对话转换为在 SO 中遇到类似问题的人的答案。请随时添加您的积分。

根本原因是 VPN 连接中的自定义流量选择器未转发容器应用程序的新

100.100.0.0/16
范围。

要解决这个问题

# Create VNet Hub
az network vnet create \
  --name VNetHub \
  --resource-group arkorg \
  --address-prefixes 10.70.0.0/23 \
  --subnet-name GatewaySubnet \
  --subnet-prefixes 10.70.0.0/24

# Create VNet Spoke
az network vnet create \
  --name VNetSpoke \
  --resource-group arkorg \
  --address-prefixes 10.70.10.0/23 \
  --subnet-name SpokeSubnet \
  --subnet-prefixes 10.70.10.0/24

enter image description here

enter image description here

# Create Static Public IP for the VPN Gateway
az network public-ip create \
  --resource-group arkorg \
  --name myVpnGatewayIP \
  --allocation-method Static \
  --sku Standard

# Create the VPN Gateway
az network vnet-gateway create \
  --resource-group arkorg \
  --name VNetGateway \
  --public-ip-address myVpnGatewayIP \
  --vnet VNetHub \
  --gateway-type Vpn \
  --vpn-type RouteBased \
  --sku VpnGw1 \
  --no-wait

enter image description here

enter image description here

# Peer VNetHub to VNetSpoke
az network vnet peering create \
  --name HubToSpoke \
  --resource-group arkorg \
  --vnet-name VNetHub \
  --remote-vnet VNetSpoke \
  --allow-vnet-access

# Peer VNetSpoke to VNetHub
az network vnet peering create \
  --name SpokeToHub \
  --resource-group arkorg \
  --vnet-name VNetSpoke \
  --remote-vnet VNetHub \
  --allow-vnet-access

enter image description here

enter image description here

# Create Route Table
az network route-table create \
  --name SpokeRouteTable \
  --resource-group arkorg \
  --location eastus

# Add Route to VPN Gateway
az network route-table route create \
  --resource-group arkorg \
  --route-table-name SpokeRouteTable \
  --name RouteToVPN \
  --address-prefix 0.0.0.0/0 \
  --next-hop-type VirtualAppliance \
  --next-hop-ip-address 10.70.1.4  # Replace with your actual VPN gateway private IP

# Associate Route Table with Spoke Subnet
az network vnet subnet update \
  --vnet-name VNetSpoke \
  --name SpokeSubnet \
  --resource-group arkorg \
  --route-table SpokeRouteTable

enter image description here enter image description here

将子网委托给 Microsoft.App/Environments(这将允许 Azure 容器应用程序管理子网)

az network vnet subnet update \
  --name SpokeSubnet \
  --resource-group arkorg \
  --vnet-name VNetSpoke \
  --delegations Microsoft.App/environments

enter image description here

创建容器应用程序环境

az containerapp env create \
  --name arkoContainerEnv \
  --resource-group arkorg \
  --location eastus \
  --infrastructure-subnet "/subscriptions/abcd-efgh-ijk-lmnop-9d23123dfc7d/resourceGroups/arkorg/providers/Microsoft.Network/virtualNetworks/VNetSpoke/subnets/SpokeSubnet"

enter image description here

部署容器应用程序,注意 - VPN 连接可以删除并使用正确的流量选择器重新创建。

az containerapp create \
  --name arkocontainerapp \
  --resource-group arkorg \
  --environment arkoContainerEnv \
  --image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest \
  --cpu 0.5 \
  --memory 1.0Gi \
  --target-port 80 \
  --ingress 'external' \
  --query properties.configuration.ingress.fqdn

enter image description here

enter image description here

这应该可以解决流量未从新的

100.100.x.x
IP 范围路由到您的 VPN 的问题。此配置可确保 ICMP 和 HTTP(S) 流量通过 VPN 连接正确路由和转发。

© www.soinside.com 2019 - 2024. All rights reserved.