简体   繁体   English

azure 使用自托管代理的 devops:无法部署到 aks 集群

[英]azure devops with self Hosted agent : can't deploy to aks cluster

i want to create azure devops release pipeline that build a docker image and deploy it to aks cluster.我想创建 azure devops 发布管道,构建 docker 图像并将其部署到 aks 集群。

the build and deployment to acr work well but the deployment to aks doesn't work.对 acr 的构建和部署运行良好,但对 aks 的部署不起作用。

this is the results after runing the pipeline:这是运行管道后的结果:

在此处输入图像描述

and this is the error logs:这是错误日志:

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

this is my service connection:这是我的服务连接:

在此处输入图像描述

Unable to connect to the server: dial tcp: lookup xxxx on 192.168.1.1:53: no such host无法连接到服务器:拨打 tcp: lookup xxxx on 192.168.1.1:53: no such host

It appears that you are using a private cluster (The Private Cluster option is enabled while creating the AKS cluster).您似乎正在使用私有集群(创建 AKS 集群时启用了私有集群选项)。

在此处输入图像描述

Kubectl is a kube.netes control client. Kubectl是一个 kube.netes 控制客户端。 It is an external connectivity provider to connect with kube.netes cluster.它是连接 kube.netes 集群的外部连接提供者。 We can't connect with the private cluster externally.我们无法从外部连接到私有集群。

However, we can't disable this option after the cluster creation.但是,我们无法在集群创建后禁用此选项。 We need to delete the cluster and create a new one with the option " Private Cluster " disabled.我们需要删除集群并创建一个禁用“ Private Cluster ”选项的新集群。

Alternately, you can set up another self-hosted agent which will be in the same .net as the cluster and have access to AKS and the Azure Pipelines.或者,您可以设置另一个自托管代理,该代理与集群位于同一 .net 中,并且可以访问 AKS 和 Azure 管道。

See Options for connecting to the private cluster请参阅连接到私有集群的选项

The API server endpoint has no public IP address. API 服务器端点没有公共 IP 地址。 To manage the API server, you'll need to use a VM that has access to the AKS cluster's Azure Virtual Network (VNet).若要管理 API 服务器,你需要使用可以访问 AKS 群集的 Azure 虚拟网络 (VNet) 的 VM。 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.在与 AKS 群集相同的 Azure 虚拟网络 (VNet) 中创建 VM。
  • 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.使用 Express Route 或 VPN 连接。
  • Use the AKS command invoke feature.使用 AKS 命令调用功能。
  • Use a private endpoint connection.使用专用端点连接。

Creating a VM in the same .NET as the AKS cluster is the easiest option.在与 AKS 群集相同的 .NET 中创建 VM 是最简单的选项。 Express Route and VPNs add costs and require additional.networking complexity. Express Route 和 VPN 会增加成本并需要额外的网络复杂性。 Virtual.network peering requires you to plan your.network CIDR ranges to ensure there are no overlapping ranges. Virtual.network peering 要求您规划您的 .network CIDR 范围以确保没有重叠范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM