带有自托管代理的azure devops : can't deploy to aks cluster

标签 azure azure-devops azure-active-directory azure-pipelines azure-aks

我想创建 azure devops 发布管道来构建 docker 镜像并将其部署到 aks 集群。

对 acr 的构建和部署运行良好,但对 aks 的部署不起作用。

这是运行管道后的结果:

enter image description here

这是错误日志:

2023-01-08T22:20:48.7666031Z ##[section]Starting: deploy
2023-01-08T22:20:48.7737773Z ==============================================================================
2023-01-08T22:20:48.7741356Z Task         : Deploy to Kubernetes
2023-01-08T22:20:48.7745738Z Description  : Use Kubernetes manifest files to deploy to clusters or even bake the manifest files to be used for deployments using Helm charts
2023-01-08T22:20:48.7750005Z Version      : 0.212.0
2023-01-08T22:20:48.7752721Z Author       : Microsoft Corporation
2023-01-08T22:20:48.7755489Z Help         : https://aka.ms/azpipes-k8s-manifest-tsg
2023-01-08T22:20:48.7757618Z ==============================================================================
2023-01-08T22:20:49.2976400Z Downloading: https://storage.googleapis.com/kubernetes-release/release/stable.txt
2023-01-08T22:20:49.8627101Z Found tool in cache: kubectl 1.26.0 x64
2023-01-08T22:20:50.6940515Z ==============================================================================
2023-01-08T22:20:50.6942077Z            Kubectl Client Version: v1.26.0
2023-01-08T22:20:50.6943172Z            Kubectl Server Version: v1.23.12
2023-01-08T22:20:50.6944430Z ==============================================================================
2023-01-08T22:20:50.7161602Z [command]/azp/_work/_tool/kubectl/1.26.0/x64/kubectl apply -f /azp/_work/_temp/Deployment_acrdemo2ss-deployment_1673216450713,/azp/_work/_temp/Service_acrdemo2ss-loadbalancer-service_1673216450713 --namespace dev
2023-01-08T22:20:50.9679948Z Unable to connect to the server: dial tcp: lookup tfkcluster-dns-074e9373.hcp.canadacentral.azmk8s.io on 192.168.1.1:53: no such host
2023-01-08T22:20:50.9771688Z ##[error]Unable to connect to the server: dial tcp: lookup tfkcluster-dns-074e9373.hcp.canadacentral.azmk8s.io on 192.168.1.1:53: no such host
2023-01-08T22:20:50.9809463Z ##[section]Finishing: deploy

这是我的服务连接:

enter image description here

最佳答案

Unable to connect to the server: dial tcp: lookup xxxx on 192.168.1.1:53: no such host

您似乎正在使用私有(private)群集(创建 AKS 群集时启用了“私有(private)群集”选项)。

enter image description here

Kubectl 是一个 kubernetes 控制客户端。它是与 kubernetes 集群连接的外部连接提供程序。我们无法从外部连接私有(private)集群。

但是,在创建集群后我们无法禁用此选项。我们需要删除集群并创建一个新集群,并禁用“私有(private)集群”选项。

或者,您可以设置另一个自托管代理,该代理将与群集位于同一 Vnet 中,并有权访问 AKS 和 Azure Pipelines。

参见Options for connecting to the private cluster

The API server endpoint has no public IP address. To manage the API server, you'll need to use a VM that has access to the AKS cluster's Azure Virtual Network (VNet). There are several options for establishing network connectivity to the private cluster.

  • Create a VM in the same Azure Virtual Network (VNet) as the AKS cluster.
  • Use a VM in a separate network and set up Virtual network peering. See the section below for more information on this option.
  • Use an Express Route or VPN connection.
  • Use the AKS command invoke feature.
  • Use a private endpoint connection.

Creating a VM in the same VNET as the AKS cluster is the easiest option. Express Route and VPNs add costs and require additional networking complexity. Virtual network peering requires you to plan your network CIDR ranges to ensure there are no overlapping ranges.

关于带有自托管代理的azure devops : can't deploy to aks cluster,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75051731/

相关文章:

Azure DevOps 发布管道权限

python - 如何使用 python 将混淆矩阵记录到 azureml 平台

java - 使用 Spring OAuth 支持多个资源 ID

azure - 如何使用 Azure CLI 访问 AAD B2C 租户

azure - 导出多个 Azure AD 组成员

azure - 如何在 Azure AD B2C 租户中获取具有相关 ID 的错误日志?

azure - 在Azure门户中,我在添加添加角色分配->分配访问权限-> "Azure AD user, group, or service principle"时没有找到此选项

azure-devops - 如何在 Azure Pipelines 中缓存目录内容,并在 package.json 文件更改等条件下失效?

python - 使用 WIQL 从 Azure Devops 检索链接的工作项

azure-devops - 在 azure devops 中,我们如何知道发布候选中有哪些故事?