azure-devops - "kubeconfig"选项的 Azure Devops kubern

使用“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 有一个选项可以在不验证的情况下保存服务连接:

即使在编辑服务连接时验证失败,使用服务连接的管道在我的情况下也能正常工作。


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


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

关于azure-devops - "kubeconfig"选项的 Azure Devops kubernetes 服务连接似乎不适用于 AAD openidconnect 集成 AKS 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58614625/

相关文章:

python - 在 Python 中打印大型 JSON 文件的前几行

c# - .Net Core Linux 不支持 SecurityIdentifier?

reactjs - react Apollo 测试 : MockProvider takes a l

amazon-web-services - Cloudwatch 中未显示 Cognito 的指标

python - Jupyterhub-错误 :asyncio:Task exception was

django - 重定向到 Django Admin 中的过滤列表

python - Jupyter 循环播放声音

postgresql - 通过 EC2 从 sqlalchemy 连接 AWS RDS

python-3.x - 模块错误 : Rasterio has no attribute open

java - 如何禁用 Spring Actuators 的内容协商?