排查 OutboundConnFailVMExtensionError 错误代码 (50) 的问题

本文介绍如何识别和解决OutboundConnFailVMExtensionError在尝试启动或部署Microsoft Azure Kubernetes 服务(AKS)群集时可能发生的错误(也称为错误代码ERR_OUTBOUND_CONN_FAIL、错误号 50)。

先决条件

  • Netcat (nc) 命令行工具

  • 挖掘命令行工具

  • 客户端 URL (cURL) 工具

现象

尝试启动或创建 AKS 群集时,接收到以下错误消息:

无法从代理建立出站连接,有关详细信息,请参阅 https://aka.ms/aks-required-ports-and-addresses

详细信息:Code=“VMExtensionProvisioningError”

Message=“VM 在处理扩展”vmssCSE“时报告了失败。

错误消息:“启用失败:无法执行命令:以退出状态终止的命令=50\n[stdout]\n\n[stderr]\nnc: 连接到 mcr.microsoft.com 端口 443 (tcp) 失败:连接超时\nCommand 以非零状态退出

错误详细信息:“vmssCSE 错误消息: {vmssCSE exit status=50, output=pt/apt.conf.d/95proxy...}

原因

用于下载预配节点所需组件的自定义脚本扩展无法建立必要的出站连接来获取包。 对于公共群集,节点尝试在端口 443 上与Microsoft容器注册表(MCR)终结点(mcr.microsoft.comMCR)通信。

有许多原因会导致流量被阻止。 在上述任何情况下,测试连接的最佳方式是使用安全外壳协议(SSH)连接到节点。 若要建立连接,请按照连接到 Azure Kubernetes 服务 (AKS) 群集节点中的说明进行维护或故障排除。 然后,按照以下步骤测试群集上的连接:

  1. 连接到节点后,运行nc命令:dig

    nc -vz mcr.microsoft.com 443 
    dig mcr.microsoft.com 443
    

    备注

    如果无法通过 SSH 访问节点,可以通过针对虚拟机规模集实例运行 az vmss run-command invoke 命令来测试出站连接:

    # Get the VMSS instance IDs.
    az vmss list-instances --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --output table
    
    # Use an instance ID to test outbound connectivity.
    az vmss run-command invoke --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --command-id RunShellScript \
        --instance-id <vmss-instance-id> \
        --output json \
        --scripts "nc -vz mcr.microsoft.com 443"
    
  2. 如果尝试使用 HTTP 代理创建 AKS 群集,请在连接到节点后运行nccurldig命令:

    # Test connectivity to the HTTP proxy server from the AKS node.
    nc -vz <http-s-proxy-address> <port>
    
    # Test traffic from the HTTP proxy server to HTTPS.
    curl --proxy http://<http-proxy-address>:<port>/ --head https://mcr.microsoft.com
    
    # Test traffic from the HTTPS proxy server to HTTPS.
    curl --proxy https://<https-proxy-address>:<port>/ --head https://mcr.microsoft.com
    
    # Test DNS functionality.
    dig mcr.microsoft.com 443
    

    备注

    如果无法通过 SSH 访问节点,可以通过对虚拟机规模集实例运行 az vmss run-command invoke 命令来测试出站连接:

    # Get the VMSS instance IDs.
    az vmss list-instances --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --output table
    
    # Use an instance ID to test connectivity from the HTTP proxy server to HTTPS.
    az vmss run-command invoke --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --command-id RunShellScript \
        --instance-id <vmss-instance-id> \
        --output json \
        --scripts "curl --proxy http://<http-proxy-address>:<port>/ --head https://mcr.microsoft.com"
    
    # Use an instance ID to test connectivity from the HTTPS proxy server to HTTPS.
    az vmss run-command invoke --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --command-id RunShellScript \
        --instance-id <vmss-instance-id> \
        --output json \
        --scripts "curl --proxy https://<https-proxy-address>:<port>/ --head https://mcr.microsoft.com"
    
    # Use an instance ID to test DNS functionality.
    az vmss run-command invoke --resource-group <mc-resource-group-name> \
        --name <vmss-name> \
        --command-id RunShellScript \
        --instance-id <vmss-instance-id> \
        --output json \
        --scripts "dig mcr.microsoft.com 443"
    

解决方案

下表列出了可能阻止流量的具体原因,以及每个原因对应的解决方案:

问题 解决方案
防火墙规则、代理服务器或网络安全组(NSG)阻止流量 当防火墙、代理服务器或 NSG 阻止 AKS 所需的端口或完全限定的域名(FQDN)时,会出现此问题。 确保允许这些端口和 FQDN。 若要确定阻止的内容,请检查上一 “原因 ”部分中提供的连接。 有关 AKS 所需端口和 FQDN 的详细信息,请参阅 Azure Kubernetes 服务 (AKS) 群集的出站网络和 FQDN 规则。
AAAA (IPv6) 记录在防火墙上被阻止 在防火墙上,验证是否存在任何阻止终结点在 Azure DNS 中解析的问题。
专用群集无法解析内部 Azure 资源 在专用群集中,如果使用自定义 DNS,则必须将 Azure DNS IP 地址 (168.63.129.16) 添加为上游 DNS 服务器。 验证是否已在 DNS 服务器上设置地址。 有关详细信息,请参阅 创建专用 AKS 群集什么是 IP 地址 168.63.129.16?

详细信息

第三方联系人免责声明

Microsoft 会提供第三方联系信息来帮助你查找有关本主题的其他信息。 此联系信息可能会更改,恕不另行通知。 Microsoft 不保证第三方联系信息的准确性。

联系我们寻求帮助

如果你有任何疑问或需要帮助,请创建支持请求联系 Azure 社区支持。 你还可以将产品反馈提交到 Azure 反馈社区