Kubernetes@1在azure设备操作管道中失败

u3r8eeie  于 2023-02-07  发布在  Kubernetes
关注(0)|答案(1)|浏览(155)

我已经创建了构建和发布管道,它是基于azure devops服务的yaml。
我使用self host linux vm作为代理来运行我的管道。
当管道运行时,它完成所有阶段,但它一直在等待部署到k8s步骤。
请查找k8部署的Yaml

- task: Kubernetes@1
  displayName: 'Deploy App in Development Environment'
  inputs:
    connectionType: 'Azure Resource Manager'
    azureSubscriptionEndpoint: ''
    azureResourceGroup: ''
    kubernetesCluster: ''
    command: 'apply'
    arguments: '-f $(System.DefaultWorkingDirectory)dev.yaml'

管道在此阶段等待60分钟,通过以下错误

Deploy App in Development Enviroment

View raw log
Starting: Deploy App in Development Enviroment
==============================================================================
Task         : Kubectl
Description  : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands
Version      : 1.181.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-kubectl-tsg
==============================================================================
Prepending PATH environment variable with directory: /usr/local/bin
==============================================================================
            Kubectl Client Version: v1.20.4
    Kubectl Server Version: Could not find kubectl server version
==============================================================================
/usr/local/bin/kubectl apply -f /home/-agent/_work/1/s/kubernetes/dev.yaml -o json
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code CPDSWFNHR to authenticate.
Unable to connect to the server: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
##[error]To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code CPDSWFNHR to authenticate.
##[error]Unable to connect to the server: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
commandOutput
##[error]The process '/usr/local/bin/kubectl' failed with exit code 1
Finishing: Deploy App in Development Enviroment
bejyjqdl

bejyjqdl1#

不妨试试以下方法:

    • 1)**您应该修改Azure应用程序用户角色json文件,将allowPublicClient设置为true,将oauth2AllowIdTokenImplicitFlow设置为true
"allowPublicClient": true,
"oauth2AllowIdTokenImplicitFlow": true

这里是a similar issue

    • 2)**您可以尝试在azure cli任务下使用az aks获取凭据。
    • 或者**您可以尝试删除~/.kube/config下的accessTokenrefreshToken

相关问题