【问题标题】:Azure Devops kubernetes service connection for "kubeconfig" option does not appear to work against an AAD openidconnect integrated AKS cluster“kubeconfig”选项的 Azure Devops kubernetes 服务连接似乎不适用于 AAD openidconnect 集成 AKS 群集
【发布时间】:2019-10-29 20:05:21
【问题描述】:

当使用“kubeconfig”选项时,当我点击“验证连接”时出现错误

Error: TFS.WebApi.Exception: No user credentials found for cluster in KubeConfig content. Make sure that the credentials exist and try again.

我粘贴的 kubeconfig 并从中选择了正确的上下文,是我的 ~/.kube./config 文件中内容的直接复制粘贴,使用 kubectl 可以正常工作

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: xxxxx
    server: https://aks-my-stage-cluster-xxxxx.hcp.eastus.azmk8s.io:443
  name: aks-my-stage-cluster-xxxxx
contexts:
- context:
    cluster: aks-my-stage-cluster-xxxxx
    user: clusterUser_aks-my-stage-cluster-xxxxx_aks-my-stage-cluster-xxxxx
  name: aks-my-stage-cluster-xxxxx
current-context: aks-my-stage-cluster-xxxxx
kind: Config
preferences: {}
users:
- name: clusterUser_aks-my-stage-cluster-xxxxx_aks-my-stage-cluster-xxxxx
  user:
    auth-provider:
      config:
        access-token: xxxxx.xxx.xx-xx-xx-xx-xx
        apiserver-id: xxxx
        client-id: xxxxx
        environment: AzurePublicCloud
        expires-in: "3599"
        expires-on: "1572377338"
        refresh-token: xxxx
        tenant-id: xxxxx
      name: azure

【问题讨论】:

    标签: azure-devops azure-aks


    【解决方案1】:

    Azure DevOps 可以选择保存服务连接而不进行验证:

    即使在编辑服务连接时验证失败,但在我的情况下使用服务连接的管道确实可以工作。


    根据粘贴的 KubeConfig,您可能会遇到第二个问题,即服务连接的 Azure DevOps GUI 没有保存或关闭,但也没有给您任何错误消息。通过检查网络流量,例如Firefox 的开发者工具,我发现问题是 KubeConfig 值太长了。只允许使用 ~ 20.000 个字符。从配置中删除不相关的条目后,它起作用了。


    PS:另一种解决方法是在管道中的脚本步骤中运行 kubelogin

    【讨论】:

      【解决方案2】:

      您可以尝试运行以下命令来获取 KubeConfig。然后将~/.kube/config文件的内容复制到服务连接中再试一次。

      az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
      

      运行上面的命令并从我的本地机器上的 ~/.kube/config 复制配置。我使用 kubeconfig 选项成功添加了我的 kubernetes 连接

      也可以参考here的步骤。

      【讨论】:

      • 这对我不起作用。我得到与 OP 相同的 TFS 错误。
      • 我认为当您使用带有 aks 的 azure ad connect auth 选项(即基于 openidconnect jwt 令牌的身份验证)时,服务连接根本不起作用
      猜你喜欢
      • 2020-02-25
      • 1970-01-01
      • 1970-01-01
      • 2021-11-17
      • 2019-08-15
      • 2021-12-08
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多