︿
Top

 



Question: The term kubectl is not recognized as the name of a cmdlet

在 Windows Server 2022 建立 AKSEE (Azure Kubernetes Service Edge Essentials) 環境後,嘗試執行 kubectl get nodes -o wide 指令時,系統卻顯示 The term kubectl is not recognized as the name of a cmdlet 訊息,表示找不到 kubectl 指令?






Answer:

簡單來說,kubectl 指令沒有加入到系統環境變數中,或因為什麼緣故被拿掉後沒有加回去。所以,只要把 kubectl 指令路徑加回系統環境變數中即可。

方法 1,直接使用 PowerShell 指令的方式,將 kubectl 指令路徑加回系統環境變數中。首先,執行「$Env:Path += ";C:\Program Files\AksEdge\kubectl\"」指令,接著執行「Get-ChildItem Env: | Where-Object {$_.name -eq "Path"} | Format-Table -Wrap」指令進行確認。


方法 2,使用 GUI 圖形操作的方式,將 kubectl 指令路徑加回系統環境變數中。


現在,應該可以順利執行 kubectl get nodes -o wide 指令。


文章標籤: ,