在 AKS 上使用 Helm 時 Kubernetes NGINX 入口控制器發生故障

在 AKS 上使用 Helm 時 Kubernetes NGINX 入口控制器發生故障

在進行 K8 入口控制器的設定時(記錄在案)這裡

我無法跳過“創建入口控制器”步驟在 Helm 命令步驟並將命令置於調試模式期間,我發現其中一個步驟超時:

預安裝失敗:等待條件逾時

查看K8 POD日誌後,我發現K8系統由於身份驗證錯誤而無法連接到註冊表。出於安全原因,以下輸出已被修改,但顯示錯誤

Failed to pull image "myregistry.azurecr.io/jettech/kube-webhook-certgen:v1.5.1@sha256:...90bd8068": [rpc error: code = NotFound desc = failed to pull and unpack image "....azurecr.io/jettech/kube-webhook-certgen@sha256:....9b9e90bd8068": failed to resolve reference "myregistry.azurecr.io/jettech/kube-webhook-certgen@sha256:...190b1dcbcb9b9e90bd8068": ....azurecr.io/jettech/kube-webhook-certgen@sha256:...9b9e90bd8068: not found, rpc error: code = Unknown desc = failed to pull and unpack image "myregistry.azurecr.io/jettech/kube-webhook-certgen@sha256:...dcbcb9b9e90bd8068": failed to resolve reference "myregistry.azurecr.io/jettech/kube-webhook-certgen@sha256:...b9b9e90bd8068": failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized]

我已經根據“az acr import”命令驗證了這些映像位於容器註冊表中,並且如果我使用“kubectl”進行標準 K8 部署,k8 就能夠連接到 acr。我還使用以下命令驗證了叢集和註冊表之間的連接,它按預期工作:

az aks check-acr -n <cluster> -g <rg>  --acr <acr>

僅當使用 helm 指令時才會出現此故障。

編輯

經過更多研究後,我發現了以下文章

https://stackoverflow.com/questions/68949434/installing-nginx-ingress-controller-into-aks-cluster-cant-pull-image-from-azu

看來摘要有問題。我在 helm 命令中新增/取代了以下內容:

--set controller.image.digest="sha256:e9fb216ace49dfa4a5983b183067e97496e7a8b307d2093f4278cd550c303899" \
--set controller.admissionWebhooks.patch.image.digest="sha256:950833e19ade18cd389d647efb88992a7cc077abedef343fa59e012d376d79b7" \

但是,當執行修改後的 helm 命令時,POD 處於錯誤狀態,並出現以下錯誤

unknown flag: --controller-class

我嘗試設定環境變數 CONTROLLER_TAG=v1.0.0,如文章所述,但這沒有幫助

另一個解決方法是在命令中設定版本號:3.36.0。這是成功的,但需要降級版本

答案1

在聯繫 MS 文檔站點反饋後,他們為我提供了該文檔的以下修復程序

https://github.com/MicrosoftDocs/azure-docs/issues/80321

回滾並重新套用修改後的變更後,該指令成功。關鍵是使用 helm uninstall 指令刪除 pod:

helm uninstall nginx-ingress --namespace ingress-basic

然後從 ACR 中刪除 ACR 儲存庫:

jettech/kube-webhook-certgen
defaultbackend-amd64
jetstack/cert-manager-controller
jetstack/cert-manager-webhook
jetstack/cert-manager-cainjector

它們是使用“az acr import”命令創建的,然後重新運行修改後的命令。

希望有人發現這個有價值

答案2

在 ACR 容器註冊表中停用身份驗證一段時間:

az acr update --name my-acr-registry-name --anonymous-pull-enabled true

建立控制器時,重新執行 Helm Chart 並在登錄中重新啟用身份驗證

az acr update --name my-acr-registry-name --anonymous-pull-enabled false

無需更改版本或其他。這會拯救你的一天。對於那些認為將acr 容器註冊表公開暴露9 秒(執行入口控制器的時間)會導致核戰爭的人,您可以僅將acr 的網絡部分中的已知網絡列入白名單,以防止不需要的訪問

相關內容