This repository provides a Helm chart for deploying Azure DevOps agents on Azure Kubernetes Service (AKS) with KEDA-based autoscaling. The solution ensures efficient resource utilization by scaling the agents dynamically based on pending jobs in the Azure DevOps pipeline.
- Docker-based agent deployment: Uses a custom Ubuntu-based Docker image.
- Helm chart for easy deployment: Deploy the agent using Helm with configurable parameters.
- KEDA Autoscaling: Dynamically scales agents based on Azure DevOps pipeline queue length.
- Secure authentication: Uses Kubernetes Secrets for storing Azure DevOps Personal Access Token (PAT).
- Customizable configurations: Helm values allow flexibility in agent pool selection, image versions, and scaling limits.
aks-azure-devops-agents/
│── docker/
│ ├── Dockerfile # Dockerfile for the agent container
│ ├── start.sh # Startup script for the agent
│
│── helm-chart/
│ ├── aks-azure-devops-agents/
│ │ ├── templates/
│ │ │ ├── deployment.yaml # Deployment configuration
│ │ │ ├── scaledobject.yaml # KEDA scaling definition
│ │ │ ├── secret.yaml # Azure DevOps authentication secret
│ │ │ ├── trigger-auth.yaml # KEDA trigger authentication
│ │ ├── Chart.yaml # Helm chart metadata
│ │ ├── values.yaml # Default configuration values
- Azure Kubernetes Service (AKS) cluster
- Helm v3 installed
- KEDA installed on AKS (KEDA installation guide)
- Azure DevOps account with an agent pool
- Personal Access Token (PAT) with agent management permissions
- Clone the repository:
git clone https://github.com/Think-Cube/aks-azure-devops-agents.git cd aks-azure-devops-agents/docker - Build the Docker image:
docker build -t <your-acr>.azurecr.io/keda-devops-agents:<tag> .
- Push the image to Azure Container Registry (ACR):
az acr login --name <your-acr> docker push <your-acr>.azurecr.io/keda-devops-agents:<tag>
- Update Helm values (optional): Modify
helm-chart/aks-azure-devops-agents/values.yamlwith your settings. - Create Kubernetes namespace (if needed):
kubectl create namespace devops-agents
- Deploy using Helm:
helm install azdevops-agents helm-chart/aks-azure-devops-agents \ --namespace devops-agents
KEDA will monitor the number of pending jobs in Azure DevOps and automatically scale the number of running agents between minReplicaCount and maxReplicaCount. Scaling is managed via the ScaledObject resource in scaledobject.yaml.
To remove the agents and associated resources:
helm uninstall azdevops-agents --namespace devops-agents| Parameter | Description | Default |
|---|---|---|
replicaCount |
Initial number of agent replicas | 1 |
image.repository |
Docker image repository | your-acr.azurecr.io/keda-devops-agents |
image.tag |
Image tag | latest |
image.pullPolicy |
Image pull policy | IfNotPresent |
azp.url |
Azure DevOps organization URL | "https://dev.azure.com/Test-Lab" |
azp.pool |
Azure DevOps agent pool name | "Keda-Devops-Agent" |
azp.token |
Base64-encoded Azure DevOps PAT | (set via Secret) |
dockerVolumePath |
Path to Docker socket for agent containers | "/var/run/docker.sock" |
scaledObject.minReplicaCount |
Minimum number of running agents | 1 |
scaledObject.maxReplicaCount |
Maximum number of running agents | 5 |
scaledObject.poolID |
Azure DevOps agent pool ID | 12 |
triggerAuthentication.name |
KEDA TriggerAuthentication name | pipeline-trigger-auth |
kubectl logs -f deployment/azdevops-deployment -n devops-agentskubectl get scaledobjects -n devops-agents
kubectl describe scaledobject azure-pipelines-scaledobject -n devops-agentsThis project is licensed under the MIT License.