Joe*_*oel 10 azure-cli windows-subsystem-for-linux azure-aks windows-terminal
在 WSL2(当前文件夹)中运行/home/my-linux-user/:
az aks get-credentials --resource-group my-resource-group --name cluster-name
输出:
Merged "cluster-name" as current context in C:\Users\my-windows-user\.kube\config
我需要做什么才能让 Azure CLI 将 kube 配置放入 WSL 中的 Linux 主文件夹中?
Bre*_*obi 13
我认为问题的根源在于正在运行的 Azure CLI 实际上是 Windows 版本。我一直在努力解决同样的问题,直到我发现我运行的是 Windows 版本的 AZ,因此它采用了 Windows 路径。这是微软希望通过在 WSL 中运行 Windows 应用程序来让人们变得超级简单的领域之一,但它却让你痛不欲生。
解决方案:安装 Linux 版本的 Azure CLI。此处找到的说明:https ://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux
在 Ubuntu 上,这很简单:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Run Code Online (Sandbox Code Playgroud)
然后一切都会按照您的预期“正常工作”。超级干净、简单,也很容易被忽视。
您在 WSL 中使用什么 Linux 发行版?另一个相关问题来自@Philippe
\n\n\n您使用的 kubectl 是 WSL 还是 Windows 版本?
\n
您是否正在运行 WSL Linux 发行版中 az aks install-cli 提供的 kubectl 客户端?C: 只能从 WSL Linux shell 中以 /mnt/c/ 形式获取,因此您不应该收到任何带有C:\\Users\\my-windows-user\\.kube\\config. 请确保您正在使用 WSL shell 中的 linux kubectl 可执行文件。
就我而言,我使用 Ubuntu 20.04 LTS [如何安装] 和 WSL。以下是一个示例:
\nWindows PowerShell\nCopyright (C) Microsoft Corporation. All rights reserved.\n\nInstall the latest PowerShell for new features and improvements! https://aka.ms/PSWindows\n\nLoading personal and system profiles took 1725ms.\n\xe2\x9d\xaf srbose@xxxxxxx \xe2\x9d\xaf ~ \xe2\x9d\xaf\n\xe2\x9d\xaf bash\nsrbose@xxxxxxx:/mnt/c/Users/srbose$ cat /etc/os-release\nNAME="Ubuntu"\nVERSION="20.04.2 LTS (Focal Fossa)"\nID=ubuntu\nID_LIKE=debian\nPRETTY_NAME="Ubuntu 20.04.2 LTS"\nVERSION_ID="20.04"\nHOME_URL="https://www.ubuntu.com/"\nSUPPORT_URL="https://help.ubuntu.com/"\nBUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"\nPRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"\nVERSION_CODENAME=focal\nUBUNTU_CODENAME=focal\nsrbose@xxxxxxx:/mnt/c/Users/srbose$ az aks get-credentials -g $RG -n akstest\nThe behavior of this command has been altered by the following extension: aks-preview\n/home/srbose/.kube/config has permissions "644".\nIt should be readable and writable only by its owner.\nMerged "akstest" as current context in /home/srbose/.kube/config\nsrbose@xxxxxxx:/mnt/c/Users/srbose$\nRun Code Online (Sandbox Code Playgroud)\n默认行为如下:
\n如果--kubeconfig设置了该标志,则仅使用指定的文件。不要合并。只允许出现此标志的一个实例。
否则,如果KUBECONFIG设置了环境变量,请将其用作应合并的文件列表。KUBECONFIG根据以下规则合并环境变量中列出的文件:
current-context。示例:如果两个文件指定了red-user,则仅使用第一个文件中的值red-user。即使第二个文件在 下有不冲突的条目red-user,也将丢弃它们。有关设置环境变量的示例KUBECONFIG,请参阅设置 KUBECONFIG 环境变量。
否则,使用默认的 kubeconfig 文件,$HOME/.kube/config不合并。欲了解更多信息,请查看这篇文章。
您可以使用以下命令检查 KUBECONFIG 环境变量是否已设置
\necho $KUBECONFIG\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
4175 次 |
| 最近记录: |