

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将工作负载从 Azure DevOps 管道部署到私有的 Amazon EKS
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters"></a>

*Mahendra Revanasiddappa，Amazon Web Services*

## Summary
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-summary"></a>

此模式演示了如何实现从 Azure DevOps 管道到私有亚马逊 Elastic Kubernetes Service (Amazon EKS) 集群的持续集成和持续交付 (CI/CD)。此模式解决了组织在通过过渡至 Amazon EKS 集群的私有 API 服务器端点来增强其安全态势时所面临的一项关键挑战。

公有端点会直接向互联网公开 Kubernetes API 服务器，从而可能会扩大恶意行为者的攻击面。切换到私有端点后，仅限在客户的虚拟私有云（VPC）内访问集群的控制面板。

尽管将 Amazon EKS 集群过渡到私有 API 终端节点可以显著增强安全性，但它会给 Azure DevOps 等外部 CI/CD 平台带来连接挑战。只能从集群的 VPC 或对等网络中访问私有端点。因此，在 AWS 私有网络之外运行的标准微软托管的 Azure DevOps 代理无法直接访问 Kubernetes API 服务器。这就破坏了依赖于在这些代理上运行的工具（例如 kubectl 或 Helm）的典型部署工作流，因为它们无法与集群建立连接。

为了克服这个问题，这种模式展示了一种有效的方法，即在私有 Amazon EKS 集群中使用自托管 Azure DevOps 代理。该解决方案提供了卓越的成本优化、运营效率和可扩展性，同时保留了安全要求。这种方法特别有利于寻求在不影响性能或安全性的前提下简化多云 DevOps 流程的企业。

## 先决条件和限制
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-prereqs"></a>

**先决条件**
+ 活跃 AWS 账户的.
+ AWS Command Line Interface [(AWS CLI) 版本 2.13.17 或更高版本，已安装。](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
+ kubectl 版本 1.25.1 或更高版本，[已安装](https://kubernetes.io/docs/tasks/tools/)。
+ [已创建](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)私有 Amazon EKS 集群版本 1.24 或更高版本，具有创建命名空间、密钥和部署的权限[。](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)
+ Amazon EKS 集群中的工作节点具有互联网的出站连接，因此在其上运行的 Azure DevOps 代理可以连接到 Azure DevOps 代理池。
+ GitHub 账户[已创建](https://github.com/signup)。
+ [创建](https://learn.microsoft.com/en-us/azure/devops/user-guide/sign-up-invite-teammates?view=azure-devops&tabs=microsoft-account)了一个有权配置服务连接的 Azure DevOps 项目，这些连接是 Azure Pipelines 与外部或远程服务之间经过身份验证的连接。
+ 为上一点中描述的 Azure DevOps 项目安装的 1.15 或更高 AWS Toolkit for Azure DevOps 版本。有关安装说明，请参阅 Visual Studio Marketplace 中的 [AWS Toolkit for Azure DevOps](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-vsts-tools)。

**限制**
+ 有些 AWS 服务 并非全部可用 AWS 区域。有关区域可用性，请参阅[按区域划分的AWS 服务](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。有关特定端点，请参阅[服务端点和配额](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)，然后选择相应服务的链接。

## 架构
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-architecture"></a>

此模式会创建以下内容：
+ **亚马逊 ECR 存储库** ——亚马逊弹性容器注册表 (Amazon ECR) Registry 存储库将 Docker 映像与 Azure DevOps 代理和部署的示例应用程序一起存储。
+ **Azure DevOps 代理池**-Azure DevOps 自托管代理池注册在私有 Amazon EKS 集群上运行的代理。
+ **IAM 角色**-Azure 服务连接的 AWS Identity and Access Management (IAM) 角色，用于为在私有 Amazon EKS 集群上运行的代理提供所需的访问权限。
+ **Azure DevOps 服务连接**-Azure DevOps 账户中的服务连接，用于使用 IAM 角色，为管道作业提供访问所需的访问权限 AWS 服务。

下图显示了在私有 Amazon EKS 集群上部署自托管 Azure DevOps 代理并在同一集群上部署示例应用程序的架构。

![\[在私有 Amazon EKS 集群上部署自托管的 Azure DevOps 代理和示例应用程序。\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/a965834f-a1e2-4679-bd8c-15eed4f57b55/images/ee22bd3e-311c-46e0-8024-9b7e7752080a.png)


下图显示了如下工作流：

1. 将自托管的 Azure DevOps 代理部署为在 Amazon EKS 集群中的部署。

1. Azure DevOps 代理使用个人访问令牌 (PAT) 进行身份验证，连接到 Azure DevOps 帐户上的代理池。

1. Azure Pipelines 使用 GitHub 存储库中的代码配置要部署的管道。

1. 该管道可在代理池中的代理上运行，其中该代理池可管道配置中进行配置。Azure DevOps 代理通过不断轮询到 Azure DevOps 帐户来获取管道的作业信息。

1. Azure DevOps 代理在管道作业中构建 Docker 映像，并将该映像推送到 Amazon ECR 存储库。

1. Azure DevOps 代理将示例应用程序部署到名为的命名`webapp`空间中的私有 Amazon EKS 集群上。

## 工具
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-tools"></a>

**工具**
+ [Amazon Elastic Container Registry (Amazon ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html) 是一项安全、可扩展且可靠的托管容器映像注册表服务。
+ [亚马逊 Elastic Kubernetes Service（亚马逊](https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html) EKS）可帮助你在上面运行 AWS Kubernetes，而无需安装或维护自己的 Kubernetes 控制平面或节点。
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 通过控制谁经过身份验证并有权使用 AWS 资源，从而帮助您安全地管理对资源的访问权限。

**其他工具**
+ [Docker](https://www.docker.com/) 是一组平台即服务（PaaS）产品，它们使用操作系统级别的虚拟化技术在容器中交付软件。
+ [kubectl](https://kubernetes.io/docs/tasks/tools/)：针对 Kubernetes 集群运行命令的命令行界面。

**代码存储库**
+ 此模式的代码可在 GitHub [deploy-kubernetes-resources-to-amazon-eks-using-azure-devops](https://github.com/aws-samples/deploy-kubernetes-resources-to-amazon-eks-using-azure-devops) 存储库中找到。

## 最佳实践
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-best-practices"></a>
+ 有关 Amazon EKS 的信息，请参阅 [Amazon EKS 最佳实践指南](https://docs.aws.amazon.com/eks/latest/best-practices/introduction.html)。
+ 遵循最低权限原则，并授予执行任务所需的最低权限。有关详情，请参阅 IAM 文档中的[授予最低权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#grant-least-priv)和[安全最佳实践](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)。

## 操作说明
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-epics"></a>

### 创建服务连接
<a name="create-a-service-connection"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 查找 Azure DevOps 组织指南。 | 登录你的 Azure DevOps 帐户，然后使用以下 URL 查找组织 GUID：`https://dev.azure.com/{DevOps_Org_ID}/_apis/projectCollections?api-version=6.0`在网址中，`{DevOps_org_ID}`替换为你的 Azure DevOps 组织 ID。 | AWS DevOps | 
| 在 AWS 账户中配置 IdP。 | 要在中为 Azure 服务连接配置身份提供者 (IdP)，请使用以下步骤： AWS 账户 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)有关更多详细信息，请参阅[如何 DevOps 使用 OpenID Connect AWS 从 Azure 联合到](https://aws.amazon.com/blogs/modernizing-with-aws/how-to-federate-into-aws-from-azure-devops-using-openid-connect/)。 | AWS DevOps | 
| 在 AWS 账户中创建 IAM 策略。 | 要创建 IAM 策略以向 Azure DevOps 管道使用的 IAM 角色提供所需权限，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | AWS DevOps | 
| 在 AWS 账户中创建 IAM 角色。 | 要在中为 Azure 服务连接配置 IAM 角色，请使用以下步骤： AWS 账户 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)<pre>{<br />  "Version": "2012-10-17",		 	 	 <br />  "Statement": [<br />    {<br />      "Effect": "Allow",<br />      "Principal": {<br />        "Federated": "arn:aws:iam::{account_id}:oidc-provider/vstoken.dev.azure.com/{OrganizationGUID}"<br />      },<br />      "Action": "sts:AssumeRoleWithWebIdentity",<br />      "Condition": {<br />        "StringEquals": {<br />          "vstoken.dev.azure.com/{OrganizationGUID}:aud": "api://AzureADTokenExchange",<br />          "vstoken.dev.azure.com/{OrganizationGUID}:sub": "sc://{OrganizationName}/{ProjectName}/{ServiceConnectionName}"<br />        }<br />      }<br />    }<br />  ]<br />}</pre>在策略中，针对以下占位符提供您的信息：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | AWS DevOps | 
| 在 Azure DevOps 帐户中创建服务连接。 | 要配置 Azure 服务连接，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)有关更多详细信息，请参阅 Microsoft 文档中的[创建服务连接](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops#create-a-service-connection)。 | AWS DevOps | 
| 将 IAM 角色添加到 Amazon EKS 配置文件。 | IAM 角色必须具有在 Amazon EKS 集群上执行所需操作的必要权限。由于 IAM 角色是一个管道角色，因此该角色必须能够管理集群上几乎所有类型的资源。因此，`system:masters` 组权限适用于此角色。要将所需的配置添加到 Kubernetes 内的 `aws-auth ConfigMap` 中，请使用以下代码：<pre>- groups:<br />  - system:masters<br />  rolearn: arn:aws:iam::{account_id}:role/ADO-role<br />  username: ADO-role</pre>`{account_id}`用您的 AWS 账户 身份证替换。有关更多详细，请参阅 Amazon EKS 文档中的[Amazon EKS 如何与 IAM 配合使用](https://docs.aws.amazon.com/eks/latest/userguide/security-iam-service-with-iam.html#security-iam-service-with-iam-roles)。 | AWS DevOps | 

### 创建代理池
<a name="create-an-agent-pool"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建自托管代理池。 | 要在 Azure DevOps 帐户中配置自托管代理池，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)有关更多详细信息，请参阅 Microsoft 文档中的[创建和管理代理池](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues?view=azure-devops&tabs=yaml%2Cbrowser)。 |  | 

### 构建 Azure DevOps 代理镜像并推送到亚马逊 ECR
<a name="build-azure-devops-agent-image-and-push-to-ecr"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建 Amazon ECR 存储库。 | 用于在私有 Amazon EKS 集群上部署 Azure DevOps 代理和示例应用程序 (`webapp`) 的 Docker 映像必须存储在 Amazon ECR 存储库中。要创建 Amazon ECR 存储库，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)有关更多详细信息，请参阅 Amazon ECR 文档中的[创建 Amazon ECR 私有存储库来存储映像](https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-create.html)。 | AWS DevOps | 
| 创建一个 Dockerfile 来构建 Azure 代理 DevOps 。 | 创建一个 Dockerfile 来生成安装了 Azure DevOps 代理的 Docker 镜像。将以下内容存储在名为 `Dockerfile` 的文件中：<pre><br />FROM ubuntu:22.04 <br />ENV TARGETARCH="linux-x64"<br />RUN apt update && apt upgrade -y && apt install -y curl git jq libicu70 unzip wget<br /><br />RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"<br />RUN unzip awscliv2.zip<br />RUN ./aws/install<br />RUN rm -rf aws awscliv2.zip<br /><br />RUN curl -sSL https://get.docker.com/ | sh<br /><br />RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash<br />RUN mkdir -p azp <br />WORKDIR /azp/<br /><br />COPY ./start.sh ./ <br />RUN chmod +x ./start.sh<br /><br />RUN useradd -m -d /home/agent agent <br />RUN chown -R agent:agent /azp /home/agent<br />RUN groupadd -f docker <br />RUN usermod -aG docker agent<br />USER agent<br /><br />ENTRYPOINT [ "./start.sh" ]</pre> | AWS DevOps | 
| 为 Azure DevOps 代理创建脚本。 | 要创建 `start.sh` 脚本，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | AWS DevOps | 
| 使用 Azure DevOps 代理构建 Docker 镜像。 | 要创建 Docker 镜像来安装 Azure DevOps 代理，请使用你之前创建的 Dockerfile 来构建镜像。在存储 Dockerfile 的同一个目录中，运行以下命令：<pre>aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com<br /><br />docker build --platform linux/amd64 -t ado-agent:latest .<br /><br />docker tag ado-agent:latest aws_account_id.dkr.ecr.region.amazonaws.com/webapp:latest<br /><br />docker push aws_account_id.dkr.ecr.region.amazonaws.com/webapp:latest</pre>用您的 AWS 账户 ID 替换`aws_account_id`和`region`，然后 AWS 区域。 | AWS DevOps | 

### 将 Azure DevOps 代理部署到私有 Amazon EKS 集群
<a name="deploy-the-azure-devops-agent-to-a-private-eks-cluster"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 生成 Azure 个人访问令牌。 | 在私有 Amazon EKS 集群上运行的代理需要个人访问令牌 (PAT)，这样它才能使用 Azure DevOps 账户进行身份验证。要生成 PAT，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)<pre>apiVersion: v1<br />kind: Secret<br />metadata:<br />  name: azdevops-pat<br />  namespace: default<br />type: Opaque<br />stringData:<br />  AZP_TOKEN: <PAT Token></pre>[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)<pre>kubectl create -f ado-secret.yaml</pre>有关更多详细信息，请参阅 Microsoft 文档中的[使用个人访问令牌（PAT）注册代理](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/personal-access-token-agent-registration?view=azure-devops)。 | AWS DevOps | 
| 使用 Kubernetes 清单文件以进行代理部署。 | 要在私有 Amazon EKS 集群上部署 Azure DevOps 代理，请复制以下清单文件并将该文件存储为`agent-deployment.yaml`：<pre>apiVersion: apps/v1<br />kind: Deployment<br />metadata:<br />  name: azure-pipelines-agent-eks<br />  labels:<br />    app: azure-pipelines-agent<br />spec:<br />  replicas: 1<br />  selector:<br />    matchLabels:<br />      app: azure-pipelines-agent<br />  template:<br />    metadata:<br />      labels:<br />        app: azure-pipelines-agent<br />    spec:<br />      containers:<br />      - name: docker<br />        image: docker:dind<br />        securityContext: <br />          privileged: true<br />        volumeMounts:<br />        - name: shared-workspace<br />          mountPath: /workspace<br />        - name: dind-storage<br />          mountPath: /var/lib/docker<br />        env:<br />        - name: DOCKER_TLS_CERTDIR<br />          value: ""<br />      - name: azure-pipelines-agent<br />        image: aws_account_id.dkr.ecr.region.amazonaws.com/webapp:latest<br />        env:<br />        - name: AZP_URL<br />          value: "<Azure account URL>"<br />        - name: AZP_POOL<br />          value: "eks-agent"<br />        - name: AZP_TOKEN<br />          valueFrom:<br />            secretKeyRef:<br />              name: azdevops-pat<br />              key: AZP_TOKEN<br />        - name: AZP_AGENT_NAME<br />          valueFrom:<br />            fieldRef:<br />              fieldPath: metadata.name<br />        - name: DOCKER_HOST<br />          value: tcp://localhost:2375<br />        volumeMounts:<br />        - mountPath: /workspace<br />          name: shared-workspace<br />      volumes:<br />      - name: dind-storage<br />        emptyDir: {}<br />      - name: shared-workspace<br />        emptyDir: {}</pre>将`aws_account_id`和`<Azure account URL>`替换为你的 AWS 账户 ID 和 Azure DevOps 帐户网址。 | AWS DevOps | 
| 在私有 Amazon EKS 集群上部署代理。 | 要在私有 Amazon EKS 集群上部署 Azure DevOps 代理，请使用以下命令：<pre>kubectl create -f agent-deployment.tf</pre> | AWS DevOps | 
| 验证代理是否正在运行。 | 要验证 Azure DevOps 代理是否正在运行，请使用以下命令：<pre>kubectl get deploy azure-pipelines-agent-eks<br /></pre>该预期输出应该类似于以下所示：<pre><br />NAME                        READY   UP-TO-DATE   AVAILABLE   AGE<br />azure-pipelines-agent-eks   1/1     1            1           58s</pre>确认 `READY ` 列已显示 `1/1`。 | AWS DevOps | 
| 验证代理是否已在 Azure DevOps 代理池中注册。 | 要验证代理是否已部署在私有 Amazon EKS 集群上并已向代理池 `eks-agent` 中注册，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)您应该看到列出的代理的**状态为 “****在线**”，并且该代理的名称应以 **azure-pipelines-agent-eks-\$1** 开头。 | AWS DevOps | 

### 部署示例应用程序
<a name="deploy-sample-application"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 将示例应用程序存储库分支到您的 GitHub 账户。 | 将以下 AWS 示例存储库分支到您的 GitHub 账户：[https://github.com/aws-samples/deploy-kubernetes-resources-to-amazon-eks-using-azure-devops](https://github.com/aws-samples/deploy-kubernetes-resources-to-amazon-eks-using-azure-devops) | AWS DevOps | 
| 创建管道。 | 要在你的 Azure DevOps 帐户中创建管道，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)<pre>pool:<br />  name: eks-agent<br />#pool: self-hosted # If you are running self-hosted Azure DevOps Agents<br /><br />stages:<br /># Refering the pipeline template, input parameter that are not specified will be added with defaults<br />- template: ./pipeline_templates/main_template.yaml<br />  parameters:<br />    serviceConnectionName: aws-sc<br />    awsRegion: <your region><br />    awsEKSClusterName: <name of your EKS cluster><br />    projectName: webapp<br /></pre>[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | AWS DevOps | 
| 验证示例应用程序是否已部署。 | 管道完成后，检查 Amazon ECR 存储库和 Amazon EKS 集群，进而验证示例应用程序是否已成功部署。要验证 Amazon ECR 存储库中的构件，请使用以下步骤：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html)例如，`20250501.1-image` 和 `20250501.1-helm`。要在命名空间 `webapp` 中验证私有 Amazon EKS 集群上的部署，请使用以下命令：<pre>kubectl get deploy -n webapp </pre>预期的输出如下所示：<pre><br />NAME     READY   UP-TO-DATE   AVAILABLE<br />webapp   1/1     1            1           </pre>注意：如果这是您首次运行管道，则可能需要对服务连接和代理池执行授权。在 Azure DevOps 管道界面中查找权限请求，然后批准它们以继续。 | AWS DevOps | 

## 问题排查
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-troubleshooting"></a>


| 问题 | 解决方案 | 
| --- | --- | 
| 当 Amazon ECR 存储库名称与 `webapp` 不匹配时，管道失败 | 示例应用程序希望 Amazon ECR 存储库名称与 `azure_pipeline.yml` 中的 `projectName: webapp` 参数相匹配。要解决此问题，请将您的 Amazon ECR 存储库重命名为 `webapp`，或更新以下内容：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | 
| 错误：Kubernetes 集群无法访问：服务器已要求客户端提供凭证 | 如果您在 Azure Pipelines 的“提取并部署 Helm 图表”步骤中遇到此错误，则根本原因通常源于 Amazon EKS 集群 `aws-auth ConfigMap` 中的 IAM 角色配置不正确。要解决此问题，请检查以下操作：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters.html) | 

## 相关资源
<a name="deploy-workloads-from-azure-devops-pipelines-to-private-amazon-eks-clusters-resources"></a>

**AWS 博客**
+ [如何 DevOps 使用 OpenID Connect AWS 从 Azure 联合进入](https://aws.amazon.com/blogs/modernizing-with-aws/how-to-federate-into-aws-from-azure-devops-using-openid-connect/)

**AWS 服务 文档**
+ [Amazon ECR](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html)
+ [Amazon EKS](https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html)

**微软文档**
+ [什么是 Azure DevOps？](https://learn.microsoft.com/en-us/azure/devops/user-guide/what-is-azure-devops?view=azure-devops)
+ [什么是 Azure Pipelines？](https://learn.microsoft.com/en-us/azure/devops/pipelines/get-started/what-is-azure-pipelines?view=azure-devops)