用戶端 IP 位址無法存取 API 伺服器

本文說明如何修正因為用戶端 IP 位址無法存取 AKS API 伺服器而無法連線到 Azure Kubernetes Service (AKS) 叢集時所發生的問題。

必要條件

徵狀

您可能會看到下列錯誤:

Unable to connect to the server: dial tcp <API-SERVER-IP>:443: i/o timeout

Unable to connect to the server: dial tcp <API-SERVER-IP>:443: connectex: A connection attempt failed because the connected party did not properly respond after a period, or established connection failed because connected host has failed to respond.

原因

API 伺服器授權的IP範圍 可能已在叢集的 API 伺服器上啟用,但用戶端的IP位址未包含在IP範圍中。 若要檢查此功能是否已啟用,請查看 Azure CLI 中的下列 az aks show 命令是否產生 IP 範圍清單:

az aks show --resource-group <cluster-resource-group> \
    --name <cluster-name> \
    --query apiServerAccessProfile.authorizedIpRanges

解決方案

查看叢集的 API 伺服器授權範圍,並使用下列步驟在該範圍內新增用戶端的 IP 位址:

注意事項

  1. 您是否從透過 Proxy 伺服器或防火牆路由傳送流量的公司網路存取 API 伺服器? 然後,請先詢問網路管理員,再將用戶端IP位址新增至API伺服器的授權範圍清單。

  2. 此外,在您新增用戶端 IP 位址之前,請先詢問叢集管理員,因為將暫時 IP 位址新增至授權範圍清單可能會有安全性考慮。

  1. 執行此 curl 命令以取得您的用戶端 IP 位址:

    $ curl --silent checkip.dyndns.org
    <html><head><title>Current IP Check</title></head><body>Current IP Address: 0.255.127.63</body></html>
    
  2. 使用您的用戶端 IP 位址,在 Azure CLI 中使用 az aks update 命令更新 API 伺服器授權的範圍:

    az aks update --resource-group <cluster-resource-group> \
        --name <cluster-name> \
        --api-server-authorized-ip-ranges <ip-ranges-that-include-your-client-ip-address>
    

與我們連絡,以取得說明

如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以將產品意見反應提交給 Azure 意應見反社群