Azure Devops 管道无法连接到 AKS 集群
Azure Devops pipeline unable to connect to AKS cluster
我在 Azure Devops 中使用 ARM 服务连接,使用下面的 Devops 管道将 helm chart 部署到 AKS。
- stage: Dev_Deployment
displayName: "Deploy to Dev"
jobs:
- job: Deploy_to_AKS
displayName: "Build, scan, and push the Docker image"
steps:
- task: HelmDeploy@0
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: 'xxxxxxxxxxxxxxx'
azureResourceGroup: 'xxxxxxxxxxx'
kubernetesCluster: 'aks-cluster'
useClusterAdmin: true
namespace: 'dev'
command: 'upgrade'
chartType: 'Name'
chartName: 'xxxx/xxxxxx'
valueFile: 'devops/helmvalues.yaml'
arguments: '--debug'
但是当管道试图部署到集群时,出现如下错误:
2021-09-23T06:06:33.2448376Z ##[section]Starting: HelmDeploy
2021-09-23T06:06:33.2461242Z
============================================================================== 2021-09-23T06:06:33.2461562Z Task : Package and deploy Helm
charts 2021-09-23T06:06:33.2461921Z Description : Deploy, configure,
update a Kubernetes cluster in Azure Container Service by running helm
commands 2021-09-23T06:06:33.2462221Z Version : 0.183.0
2021-09-23T06:06:33.2462445Z Author : Microsoft Corporation
2021-09-23T06:06:33.2462691Z Help :
https://aka.ms/azpipes-helm-tsg 2021-09-23T06:06:33.2462992Z
============================================================================== 2021-09-23T06:06:34.0152308Z [command]/usr/local/bin/helm upgrade
--namespace dev --install --values /home/vsts/work/1/s/devops/helmvalues.yaml --wait --debug 20210923.3
xxxxxxx 2021-09-23T06:06:38.3572124Z Error: Kubernetes cluster
unreachable: Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no
such host 2021-09-23T06:06:38.3585227Z helm.go:81: [debug] Get
"xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no such host
2021-09-23T06:06:38.3586699Z Kubernetes cluster unreachable
2021-09-23T06:06:38.3587230Z
helm.sh/helm/v3/pkg/kube.(*Client).IsReachable
2021-09-23T06:06:38.3587833Z helm.sh/helm/v3/pkg/kube/client.go:115
2021-09-23T06:06:38.3588341Z helm.sh/helm/v3/pkg/action.(*History).Run
2021-09-23T06:06:38.3588862Z helm.sh/helm/v3/pkg/action/history.go:48
2021-09-23T06:06:38.3589375Z main.newUpgradeCmd.func2
2021-09-23T06:06:38.3589878Z helm.sh/helm/v3/cmd/helm/upgrade.go:93
2021-09-23T06:06:38.3590399Z github.com/spf13/cobra.(*Command).execute
2021-09-23T06:06:38.3591896Z
github.com/spf13/cobra@v1.1.3/command.go:852
2021-09-23T06:06:38.3592781Z
github.com/spf13/cobra.(*Command).ExecuteC
2021-09-23T06:06:38.3611885Z
github.com/spf13/cobra@v1.1.3/command.go:960
2021-09-23T06:06:38.3614477Z github.com/spf13/cobra.(*Command).Execute
2021-09-23T06:06:38.3616752Z
github.com/spf13/cobra@v1.1.3/command.go:897
2021-09-23T06:06:38.3617159Z main.main 2021-09-23T06:06:38.3617522Z
helm.sh/helm/v3/cmd/helm/helm.go:80 2021-09-23T06:06:38.3617900Z
runtime.main 2021-09-23T06:06:38.3618254Z runtime/proc.go:225
2021-09-23T06:06:38.3618598Z runtime.goexit
2021-09-23T06:06:38.3618966Z runtime/asm_amd64.s:1371
2021-09-23T06:06:38.3676299Z ##[error]Error: Kubernetes cluster
unreachable: Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no
such host helm.go:81: [debug] Get "xxxxxxx": dial tcp: lookup xxxxxxx
on xxxxxxx: no such host Kubernetes cluster unreachable
helm.sh/helm/v3/pkg/kube.(*Client).IsReachable
helm.sh/helm/v3/pkg/kube/client.go:115
helm.sh/helm/v3/pkg/action.(*History).Run
helm.sh/helm/v3/pkg/action/history.go:48 main.newUpgradeCmd.func2
helm.sh/helm/v3/cmd/helm/upgrade.go:93
github.com/spf13/cobra.(*Command).execute
github.com/spf13/cobra@v1.1.3/command.go:852
github.com/spf13/cobra.(*Command).ExecuteC
github.com/spf13/cobra@v1.1.3/command.go:960
github.com/spf13/cobra.(*Command).Execute
github.com/spf13/cobra@v1.1.3/command.go:897 main.main
helm.sh/helm/v3/cmd/helm/helm.go:80 runtime.main runtime/proc.go:225
runtime.goexit runtime/asm_amd64.s:1371
2021-09-23T06:06:38.3696886Z ##[section]Finishing: HelmDeploy
如何解决这个问题?
编辑:更新了错误
所以我和 Azure 谈了这件事。看起来 Devops 代理无法访问我们的集群。
我们将需要设置另一个代理,该代理将与集群位于同一 Vnet 中,并且可以访问 AKS 和 Azure Pipelines。
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops
我在 Azure Devops 中使用 ARM 服务连接,使用下面的 Devops 管道将 helm chart 部署到 AKS。
- stage: Dev_Deployment
displayName: "Deploy to Dev"
jobs:
- job: Deploy_to_AKS
displayName: "Build, scan, and push the Docker image"
steps:
- task: HelmDeploy@0
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: 'xxxxxxxxxxxxxxx'
azureResourceGroup: 'xxxxxxxxxxx'
kubernetesCluster: 'aks-cluster'
useClusterAdmin: true
namespace: 'dev'
command: 'upgrade'
chartType: 'Name'
chartName: 'xxxx/xxxxxx'
valueFile: 'devops/helmvalues.yaml'
arguments: '--debug'
但是当管道试图部署到集群时,出现如下错误:
2021-09-23T06:06:33.2448376Z ##[section]Starting: HelmDeploy 2021-09-23T06:06:33.2461242Z ============================================================================== 2021-09-23T06:06:33.2461562Z Task : Package and deploy Helm charts 2021-09-23T06:06:33.2461921Z Description : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running helm commands 2021-09-23T06:06:33.2462221Z Version : 0.183.0 2021-09-23T06:06:33.2462445Z Author : Microsoft Corporation 2021-09-23T06:06:33.2462691Z Help : https://aka.ms/azpipes-helm-tsg 2021-09-23T06:06:33.2462992Z ============================================================================== 2021-09-23T06:06:34.0152308Z [command]/usr/local/bin/helm upgrade --namespace dev --install --values /home/vsts/work/1/s/devops/helmvalues.yaml --wait --debug 20210923.3 xxxxxxx 2021-09-23T06:06:38.3572124Z Error: Kubernetes cluster unreachable: Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no such host 2021-09-23T06:06:38.3585227Z helm.go:81: [debug] Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no such host 2021-09-23T06:06:38.3586699Z Kubernetes cluster unreachable 2021-09-23T06:06:38.3587230Z helm.sh/helm/v3/pkg/kube.(*Client).IsReachable 2021-09-23T06:06:38.3587833Z helm.sh/helm/v3/pkg/kube/client.go:115 2021-09-23T06:06:38.3588341Z helm.sh/helm/v3/pkg/action.(*History).Run 2021-09-23T06:06:38.3588862Z helm.sh/helm/v3/pkg/action/history.go:48 2021-09-23T06:06:38.3589375Z main.newUpgradeCmd.func2 2021-09-23T06:06:38.3589878Z helm.sh/helm/v3/cmd/helm/upgrade.go:93 2021-09-23T06:06:38.3590399Z github.com/spf13/cobra.(*Command).execute 2021-09-23T06:06:38.3591896Z github.com/spf13/cobra@v1.1.3/command.go:852 2021-09-23T06:06:38.3592781Z github.com/spf13/cobra.(*Command).ExecuteC 2021-09-23T06:06:38.3611885Z github.com/spf13/cobra@v1.1.3/command.go:960 2021-09-23T06:06:38.3614477Z github.com/spf13/cobra.(*Command).Execute 2021-09-23T06:06:38.3616752Z github.com/spf13/cobra@v1.1.3/command.go:897 2021-09-23T06:06:38.3617159Z main.main 2021-09-23T06:06:38.3617522Z helm.sh/helm/v3/cmd/helm/helm.go:80 2021-09-23T06:06:38.3617900Z runtime.main 2021-09-23T06:06:38.3618254Z runtime/proc.go:225 2021-09-23T06:06:38.3618598Z runtime.goexit 2021-09-23T06:06:38.3618966Z runtime/asm_amd64.s:1371 2021-09-23T06:06:38.3676299Z ##[error]Error: Kubernetes cluster unreachable: Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no such host helm.go:81: [debug] Get "xxxxxxx": dial tcp: lookup xxxxxxx on xxxxxxx: no such host Kubernetes cluster unreachable helm.sh/helm/v3/pkg/kube.(*Client).IsReachable helm.sh/helm/v3/pkg/kube/client.go:115 helm.sh/helm/v3/pkg/action.(*History).Run helm.sh/helm/v3/pkg/action/history.go:48 main.newUpgradeCmd.func2 helm.sh/helm/v3/cmd/helm/upgrade.go:93 github.com/spf13/cobra.(*Command).execute github.com/spf13/cobra@v1.1.3/command.go:852 github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra@v1.1.3/command.go:960 github.com/spf13/cobra.(*Command).Execute github.com/spf13/cobra@v1.1.3/command.go:897 main.main helm.sh/helm/v3/cmd/helm/helm.go:80 runtime.main runtime/proc.go:225 runtime.goexit runtime/asm_amd64.s:1371
2021-09-23T06:06:38.3696886Z ##[section]Finishing: HelmDeploy
如何解决这个问题? 编辑:更新了错误
所以我和 Azure 谈了这件事。看起来 Devops 代理无法访问我们的集群。
我们将需要设置另一个代理,该代理将与集群位于同一 Vnet 中,并且可以访问 AKS 和 Azure Pipelines。
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops