{"id":29084929,"url":"https://github.com/workleap/gsoft-azure-pipelines-scaler-example","last_synced_at":"2026-01-22T06:38:14.498Z","repository":{"id":74307003,"uuid":"452442120","full_name":"workleap/gsoft-azure-pipelines-scaler-example","owner":"workleap","description":"Example for Azure Pipelines Agent hosted in Kubernetes and scaled dynamically on-demand.","archived":false,"fork":false,"pushed_at":"2022-01-31T16:12:49.000Z","size":318,"stargazers_count":5,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T04:13:12.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/workleap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-26T21:11:07.000Z","updated_at":"2024-03-16T16:52:53.000Z","dependencies_parsed_at":"2023-03-11T16:59:52.466Z","dependency_job_id":null,"html_url":"https://github.com/workleap/gsoft-azure-pipelines-scaler-example","commit_stats":null,"previous_names":["gsoft-inc/gsoft-azure-pipelines-scaler-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/workleap/gsoft-azure-pipelines-scaler-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workleap%2Fgsoft-azure-pipelines-scaler-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workleap%2Fgsoft-azure-pipelines-scaler-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workleap%2Fgsoft-azure-pipelines-scaler-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workleap%2Fgsoft-azure-pipelines-scaler-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/workleap","download_url":"https://codeload.github.com/workleap/gsoft-azure-pipelines-scaler-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workleap%2Fgsoft-azure-pipelines-scaler-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-27T22:11:46.938Z","updated_at":"2026-01-22T06:38:14.481Z","avatar_url":"https://github.com/workleap.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self-Host Your Azure Pipeline Agents in Kubernetes and Scale Them On Demand (example)\n\n## 00 - Azure Infrastructure (optional)\n\nIf you don't already have your infrastructure setup, you can use this Terraform project to create:\n- Azure Kubernetes Service (AKS)\n- Azure Container Registry (ACR)\n- Access role to pull images from ACR in AKS\n\n### Prerequisites\n- [Terraform](https://www.terraform.io/downloads)\n- [Azure Subscription](https://azure.microsoft.com/en-ca/free/) with following roles (minimum):\n  - Contributor (for creating resources)\n  - User Access Manager (for assigning AcrPull role to AKS cluster)\n\n\n\nTo create the infrastructure, open a terminal in the `./00-infrastructure` directory and execute the following:\n\n```bash\nterraform init\nterraform apply\n```\n\nOnce completed, the Terraform will output the required values you will need later on:\n\n![Terraform Output](docs/terraform_output.png)\n\n## 01 - Image\n\n### Prerequisites\n- Container registry (#00)\n\nFirst login to your registry.  For Azure Container Registries, use the following:\n\n```bash\nexport YOUR_REGISTRY_NAME=\u003cYOUR_REGISTRY_NAME\u003e\naz acr login -n $YOUR_REGISTRY_NAME`\n```\n\nThe build and push your Pipeline Agent Image with the following commands (from the `./01-image` directory):\n\n```bash\nexport YOUR_REGISTRY_URL=\u003cYOUR_REGISTRY_URL\u003e\ndocker build -t $YOUR_REGISTRY_URL/pipeline_agent .\ndocker push $YOUR_REGISTRY_URL/pipeline_agent\n```\n\n## 02 - Kubernetes\n\n### Prerequisites\n- Kubernetes cluster with access to your container registry (#00)\n- Container registry with agent image (#01)\n- [Helm](https://helm.sh/docs/intro/install/)\n- [Helmfile](https://github.com/roboll/helmfile#installation)\n\nFirst, authenticate to your k8s cluster and set the context.  If you're using AKS, authenticate using the Azure CLI:\n\n```bash\nexport YOUR_AKS_RESOURCE_GROUP_NAME=\u003cYOUR_AKS_RESOURCE_GROUP_NAME\u003e\nexport YOUR_AKS_NAME=\u003cYOUR_AKS_NAME\u003e\naz aks get-credentials -g $YOUR_AKS_RESOURCE_GROUP_NAME -n $YOUR_AKS_NAME\n```\n\nNow we'll deploy [KEDA](https://keda.sh/), the agent deployment and KEDA scaler to our k8s cluster.  \nHere I'm using Helm combined with Helmfile to install the required Helm repositories and charts to our cluster.\n\nYou'll need to provide the following:\n- Your Azure Pipelines URL (https://dev.azure.com/YOUR_ORG)\n- Your Azure Pipelines pool name (ex: default)\n- [Your Azure Pipelines pool ID](https://keda.sh/docs/2.5/scalers/azure-pipelines/#how-to-determine-your-pool-id)\n- [Your Personal Access Token (PAT) with Agent Pools (read, manage) scope, created by a user who has permission to configure agents](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops\u0026tabs=preview-page)\n\nFrom the `./02-kubernetes` directory, execute the following:\n\n```bash\nexport YOUR_REGISTRY_URL=\u003cYOUR_REGISTRY_URL\u003e\nexport YOUR_AZP_URL=\u003cYOUR_AZP_URL\u003e\nexport YOUR_AZP_POOL=\u003cYOUR_AZP_POOL\u003e\nexport YOUR_AZP_POOL_ID=\u003cYOUR_AZP_POOL_ID\u003e\nexport YOUR_AZP_PAT=\u003cYOUR_AZP_PAT\u003e\n\nhelmfile -f ./00-keda.yaml apply\nhelmfile -f ./01-agent.yaml apply\n```\n\nYou're done! 🎉\nYou should now see your agent pod(s) created under the `azure-pipelines-agents` namespace:\n\n![agent pods](./docs/pods.png)\n\nThey should also be registered as agents in your Azure Pipelines Pool:\n\n![agent pool](./docs/agent_pool.png)\n\n## 03 - Test it! (optional)\n\nYou can take my word that it works but if you want to test it, here's a easy way.  Create a test pipeline with the following (replace with your pool name):\n```yaml\npool:\n  name: default\n\nsteps:\n- checkout: none\n- script: |\n    waiting for completion\n    sleep 30\n  displayName: 'wait 30 seconds'\n```\n\nTrigger a few consecutive runs and watch your agent get added magically 🪄 to your pool:\n\n![scaled agent pool](./docs/scaled_pool.png)\n\nAfter they are done, they should scale back to their minimum required count.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkleap%2Fgsoft-azure-pipelines-scaler-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkleap%2Fgsoft-azure-pipelines-scaler-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkleap%2Fgsoft-azure-pipelines-scaler-example/lists"}