You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装kubelogin的client-go credential(exec)插件时卡在下载环节求助

解决kubectl Azure认证插件报错及kubelogin安装卡住问题

一、kubectl认证报错原因

执行kubectl get pods时出现的错误是因为旧版Azure认证插件已被官方移除,必须使用kubelogin作为credential插件替代。

二、解决brew安装kubelogin卡住的问题

卡在==> Downloading https://ghcr.io/v2/homebrew/core/linux-headers/5.15/manifests/5.15.102步骤,通常是网络或brew源的问题,可尝试以下方案:

方案1:切换brew国内镜像源

  • 替换homebrew-core源:
    cd "$(brew --repo homebrew/core)"
    git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
    
  • 替换homebrew-cask源(按需操作):
    cd "$(brew --repo homebrew/cask)"
    git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
    
  • 更新brew后重新安装:
    brew update
    brew install Azure/kubelogin/kubelogin
    

方案2:手动安装kubelogin(绕过brew依赖问题)

如果brew的依赖下载始终卡住,可以直接使用预编译二进制文件:

  • 下载对应系统的kubelogin二进制包
  • 解压后移动至系统PATH目录(如/usr/local/bin)
  • 添加执行权限:
    chmod +x kubelogin
    sudo mv kubelogin /usr/local/bin/
    

三、配置kubectl使用kubelogin

安装完成后,需更新kubeconfig配置以使用kubelogin:

  • 自动转换kubeconfig(推荐):
    kubelogin convert-kubeconfig -l azurecli
    
  • 手动修改kubeconfig:找到对应user节点,替换为以下exec配置(需替换占位符为你的Azure信息):
    users:
    - name: <集群用户名>
      user:
        exec:
          apiVersion: client.authentication.k8s.io/v1beta1
          command: kubelogin
          args:
          - get-token
          - --environment
          - AzurePublicCloud
          - --server-id
          - <服务器ID>
          - --client-id
          - <客户端ID>
          - --tenant-id
          - <租户ID>
    

内容的提问来源于stack exchange,提问作者plutomonk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 10:20:06