Deploy workloads from Azure DevOps pipelines to private Amazon EKS clusters
Mahendra Revanasiddappa, Amazon Web Services
Summary
This pattern demonstrates how to implement continuous integration and continuous delivery (CI/CD) from Azure DevOps pipelines to private Amazon Elastic Kubernetes Service (Amazon EKS) clusters. It addresses a critical challenge faced by organizations that are enhancing their security posture by transitioning to private API server endpoints for their Amazon EKS clusters.
A public endpoint exposes the Kubernetes API server directly to the internet, creating a larger attack surface that malicious actors could potentially target. By switching to a private endpoint, access to the cluster's control plane is restricted to within the customer's virtual private cloud (VPC).
Although transitioning an Amazon EKS cluster to a private API endpoint significantly enhances security, it introduces connectivity challenges for external CI/CD platforms like Azure DevOps. The private endpoint is only accessible from within the cluster's VPC or peered networks. Therefore, standard Microsoft-hosted Azure DevOps agents, operating outside the AWS private network, can’t reach the Kubernetes API server directly. This breaks typical deployment workflows that rely on tools like kubectl or Helm running on these agents because they fail to establish a connection to the cluster.
To overcome this problem, this pattern showcases an efficient approach by using self-hosted Azure DevOps agents within private Amazon EKS clusters. This solution offers superior cost optimization, operational efficiency, and scalability while preserving security requirements. This approach particularly benefits enterprises seeking to streamline their multi-cloud DevOps processes without compromising on performance or security.
Prerequisites and limitations
Prerequisites
An active AWS account.
AWS Command Line Interface (AWS CLI) version 2.13.17 or later, installed.
kubectl version 1.25.1 or later, installed.
A private Amazon EKS cluster version 1.24 or later created, with permissions to create namespaces, secrets, and deployments.
Worker nodes in an Amazon EKS cluster with outbound connectivity to the internet so that the Azure DevOps agent running on them can connect to Azure DevOps agent pool.
GitHub account created
. An Azure DevOps project with access to configure service connections, which are authenticated connections between Azure Pipelines and external or remote services, created
. The AWS Toolkit for Azure DevOps version 1.15 or later installed for the Azure DevOps project described in the previous point. For installation instructions, see AWS Toolkit for Azure DevOps
in Visual Studio Marketplace.
Limitations
Some AWS services aren’t available in all AWS Regions. For Region availability, see AWS Services by Region
. For specific endpoints, see Service endpoints and quotas, and choose the link for the service.
Architecture
This pattern creates the following:
Amazon ECR repository - The Amazon Elastic Container Registry (Amazon ECR) repository stores the Docker image with the Azure DevOps agent and the sample app that is deployed.
Azure DevOps agent pool - An Azure DevOps self-hosted agent pool registers the agent running on the private Amazon EKS cluster.
IAM role - An AWS Identity and Access Management (IAM) role for the Azure service connection to provide required access to the agent that’s running on a private Amazon EKS cluster.
Azure DevOps service connection - A service connection in an Azure DevOps account to use the IAM role that provides the required access for the pipeline jobs to access AWS services.
The following diagram shows the architecture of deploying a self-hosted Azure DevOps agent on a private Amazon EKS cluster and deploying a sample application on the same cluster.

The diagram shows the following workflow:
Deploy a self-hosted Azure DevOps agent as a deployment inside an Amazon EKS cluster.
An Azure DevOps agent connects to the agent pool on an Azure DevOps account using a personal access token (PAT) for authentication.
Azure Pipelines configures a pipeline to deploy by using code from a GitHub repository.
The pipeline runs on the agent from the agent pool that was configured in the pipeline configuration. The Azure DevOps agent gets the job information of the pipeline by constantly polling to the Azure DevOps account.
The Azure DevOps agent builds a Docker image as part of the pipeline job and pushes the image to the Amazon ECR repository.
The Azure DevOps agent deploys the sample application on a private Amazon EKS cluster in a namespace called
webapp
.
Tools
Tools
Amazon Elastic Container Registry (Amazon ECR) is a managed container image registry service that’s secure, scalable, and reliable.
Amazon Elastic Kubernetes Service (Amazon EKS) helps you run Kubernetes on AWS without needing to install or maintain your own Kubernetes control plane or nodes.
AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
Other tools
Code repository
The code for this pattern is available in the GitHub deploy-kubernetes-resources-to-amazon-eks-using-azure-devops
repository.
Best practices
For Amazon EKS, see the Amazon EKS Best Practices Guide.
Follow the principle of least privilege and grant the minimum permissions required to perform a task. For more information, see Grant least privilege and Security best practices in the IAM documentation.
Epics
Task | Description | Skills required |
---|---|---|
Find the Azure DevOps organization GUID. | Sign in to your Azure DevOps account, and then use the following URL to find the organization GUID:
| AWS DevOps |
Configure an IdP in the AWS account. | To configure an Identity provider (IdP) in the AWS account for an Azure service connection, use the following steps:
For more details, see How to federate into AWS from Azure DevOps using OpenID Connect | AWS DevOps |
Create an IAM policy in the AWS account. | To create an IAM policy to provide the required permissions to the IAM role used by the Azure DevOps pipeline, use the following steps:
| AWS DevOps |
Create an IAM role in the AWS account. | To configure an IAM role in the AWS account for the Azure service connection, use the following steps:
In the policy, provide your information for the following placeholders:
| AWS DevOps |
Create a service connection in the Azure DevOps account. | To configure an Azure service connection, use the following steps:
For more details, see Create a service connection | AWS DevOps |
Add IAM role to Amazon EKS configuration file. | The IAM role must have the necessary permissions to perform the required operations on the Amazon EKS cluster. Because it’s a pipeline role, the IAM role must be able to manage almost all types of resources on the cluster. Therefore, the To add the required configuration to the
Replace For more information, see How Amazon EKS works with IAM in the Amazon EKS documentation. | AWS DevOps |
Task | Description | Skills required |
---|---|---|
Create a self-hosted agent pool. | To configure a self-hosted agent pool in the Azure DevOps account, use the following steps:
For more details, see Create and manage agent pools |
Task | Description | Skills required |
---|---|---|
Create an Amazon ECR repository. | The Docker images that are used to deploy the Azure DevOps agent and sample application (
For more details, see Creating an Amazon ECR private repository to store images in the Amazon ECR documentation. | AWS DevOps |
Create a Dockerfile to build the Azure DevOps agent. | Create a Dockerfile to build the Docker image that has the Azure DevOps agent installed. Store the following content in a file named
| AWS DevOps |
Create script for the Azure DevOps agent. | To create the
| AWS DevOps |
Build a Docker image with the Azure DevOps agent. | To create a Docker image to install the Azure DevOps agent, use the Dockerfile that you created earlier to build the image. In the same directory where the Dockerfile is stored, run the following commands:
Replace | AWS DevOps |
Task | Description | Skills required |
---|---|---|
Generate an Azure personal access token. | The agent running on the private Amazon EKS cluster requires a personal access token (PAT) so that it can authenticate with the Azure DevOps account. To generate a PAT, use the following steps:
For more details, see Register an agent using a personal access token (PAT) | AWS DevOps |
Use the Kubernetes manifest file for agent deployment. | To deploy the Azure DevOps agent on the private Amazon EKS cluster, copy the following manifest file and store the file as
Replace | AWS DevOps |
Deploy the agent on the private Amazon EKS cluster. | To deploy the Azure Devops agent on the private Amazon EKS cluster, use the following command:
| AWS DevOps |
Verify the agent is running. | To verify that the Azure DevOps agent is running, use the following command:
The expected output should be similar to the following:
Make sure that the | AWS DevOps |
Verify the agent is registered with the Azure DevOps agent pool. | To verify that the agent is deployed on the private Amazon EKS cluster and is registered with the agent pool
You should see one agent listed with a Status of Online, and the name of the agent should start with azure-pipelines-agent-eks-*. | AWS DevOps |
Task | Description | Skills required |
---|---|---|
Fork the sample application repository to your GitHub account. | Fork the following AWS Samples repository to your GitHub account: https://github.com/aws-samples/deploy-kubernetes-resources-to-amazon-eks-using-azure-devops | AWS DevOps |
Create a pipeline. | To create a pipeline in your Azure DevOps account, use the following steps:
| AWS DevOps |
Verify that the sample application deployed. | After the pipeline completes, verify the successful deployment of the sample application by checking both the Amazon ECR repository and the Amazon EKS cluster. To verify artifacts in the Amazon ECR repository, use the following steps:
For example, To verify deployment on the private Amazon EKS cluster in the namespace
The expected output is as follows:
Note: If this is your first pipeline run, you might need to authorize the service connection and agent pool. Look for permission requests in the Azure DevOps pipeline interface, and approve them to proceed. | AWS DevOps |
Troubleshooting
Issue | Solution |
---|---|
Pipeline fails when Amazon ECR repository name doesn’t match | The sample application expects the Amazon ECR repository name to match the To resolve this issue, rename your Amazon ECR repository to
|
Error: Kubernetes cluster unreachable: the server has asked for the client to provide credentials | If you encounter this error in the "Pull and Deploy Helm Chart" step in your Azure pipeline, the root cause typically stems from an incorrect IAM role configuration in your Amazon EKS cluster's To resolve this issue, check the following:
|
Related resources
AWS Blogs
AWS services documentation
Microsoft documentation