As a developer, I've seen firsthand how a pool can benefit from using Azure DevOps for scalable pipelines. Azure DevOps provides a centralized platform for managing and automating the entire software development lifecycle.
With Azure DevOps, a pool can streamline its pipeline processes, reducing the time and effort required to deliver software. This is particularly important for a pool that needs to scale quickly to meet changing demands.
Azure DevOps offers a range of features that make it an ideal choice for a pool, including continuous integration and delivery, automated testing, and version control. By leveraging these features, a pool can ensure that its software is of the highest quality and meets the needs of its users.
By using Azure DevOps, a pool can also improve its collaboration and communication among team members, which is essential for delivering software efficiently and effectively.
Pool Configuration
To choose a Microsoft-hosted agent from the Azure Pipelines pool in your Azure DevOps Services YAML pipeline, you need to specify the name of the image using the YAML VM Image Label from the table.
You can designate a pool in your pipeline by specifying the name of the image, and the default Agent Specification is windows-2019.
In the classic editor, you can choose a pool and agent by navigating to the pipeline settings, selecting the desired Agent pool, and then the desired image from the Agent Specification drop-down.
To manage pools and queues, you can use the Azure CLI to view information about agent pools and queues, but you cannot edit them at this time.
You can list agent pools and queues, and show agent pool details and queue details using the Azure CLI.
To configure the agent container, you can use the script in Step 5 as the entrypoint for your agent container, and change the section of the shell script to use the --once switch to terminate and cleanup the agent when the job is complete.
The if statement for cleanup is only required if you are using the auto-deployment parent template method.
Security and Permissions
Security and permissions are crucial aspects of Azure DevOps pool management. Roles are defined on each agent pool, and membership in these roles governs what operations you can perform on an agent pool.
To control sharing and use of agents, understand how security works for agent pools. Roles are defined on each agent pool, and membership in these roles governs what operations you can perform on an agent pool.
There are three types of roles on an agent pool: Reader, Service Account, and Administrator. Members of the Reader role can view the agent pool as well as agents. Members of the Service Account role can use the organization agent pool to create a project agent pool in a project.
The Administrator role has the most permissions, including registering or unregistering agents from the organization agent pool, managing membership for all roles of the organization agent pool, and referring to the organization agent pool when creating a project agent pool in a project.
Here are the roles and their purposes on an agent pool in organization settings:
At the project level, roles are also defined on each project agent pool, and memberships in these roles govern what operations you can perform on an agent pool.
Organization-Level Security Settings
At the organization level, security settings are crucial to control who can access and manage agent pools. The All agent pools node in the Agent Pools tab is used to control the security of all organization agent pools.
By default, TFS and Azure DevOps Server administrators are also administrators of the 'All agent pools' node. This means they have full control over the security settings for all agent pools in the organization.
You can choose from the following roles to manage access to the organization agent pool:
Note that role memberships for individual organization agent pools are automatically inherited from those of the 'All agent pools' node. This ensures consistency in security settings across the organization.
Pipeline Permissions
Pipeline permissions control which YAML pipelines are authorized to use an agent pool. This is a crucial aspect of security, as it determines which pipelines can access and utilize the resources of the agent pool.
You can configure pipeline permissions to allow open access for all pipelines, or you can lock down the agent pool and only allow selected YAML pipelines to use it. If any other YAML pipeline refers to the agent pool, an authorization request will be raised, which must be approved by an agent pool Administrator.
Here's a breakdown of the two options:
- Open access for all pipelines: This can be achieved by selecting the "Open access for all pipelines" option in the Pipeline permissions section of the security tab of an agent pool.
- Lock down the agent pool: This involves selecting the "Lock down the agent pool and only allow selected YAML pipelines to use it" option, and then specifying which YAML pipelines are authorized to use the agent pool.
By default, certain groups are added to the Administrator role of 'All agent pools', including Build Administrators, Release Administrators, and Project Administrators. This means that members of these groups will have administrator privileges for all agent pools in a project.
Deployment Strategies
Deployment strategies in Azure DevOps are crucial for a seamless application update experience. We can deploy updates using lifecycle hooks, which can run steps during deployment and resolve into agent jobs or server jobs.
To achieve this, we use deployment jobs that inherit the pool specified by the deployment job. For example, deployment jobs use the $(Pipeline.Workspace) system variable.
There are different deployment strategies available, including rolling deployment and canary deployment. A rolling deployment replaces instances of the previous version of an application with instances of the new version on a fixed set of virtual machines.
Here are the key steps involved in a rolling deployment:
- Enable initialization.
- Deploy the update.
- Route traffic to the updated version.
- Test the updated version after routing traffic.
- In case of failure, run steps to restore to the last known good version.
A canary deployment strategy is an advanced deployment strategy that helps mitigate the risk involved in rolling out new versions of applications. It supports the preDeploy lifecycle hook and iterates with the deploy, routeTraffic, and postRouteTraffic lifecycle hooks.
To configure a canary deployment, you can specify the keyword rolling: under the strategy: node. The strategy.name variable is available in this strategy block, which takes the name of the strategy. In this case, rolling.
You can also control the number/percentage of virtual machine targets to deploy to in parallel using the maxParallel variable. This ensures that the app is running on these machines and is capable of handling requests while the deployment is taking place on the rest of the machines.
Agent Management
You can view information about agent pools and queues using the Azure CLI, but editing them is not currently possible.
Managing agent pools and queues is a crucial part of Azure DevOps, and understanding how security works for agent pools can help control sharing and use of agents. Roles are defined on each agent pool, and membership in these roles governs what operations you can perform on an agent pool.
Configuring the agent container requires using a specific script as the entrypoint, and you'll need to change it to add the --once switch to make the agent terminate and cleanup itself when the job is complete.
Managed DevOps pools can drastically reduce time spent in management of agents based on on-premises infrastructure or manually maintained. Teams that switch to Managed DevOps Pools can create new pools in under a minute and spend little time actively managing the pool.
By default, MDP pools are stateless, but teams can choose to reuse the same agent in multiple jobs to improve performance. Managed DevOps Pools implements best practices for stateful agents by auto-recycling agents based on time or the agent running out of disk space.
Azure DevOps Features
Managed DevOps Pools can help optimize a team's DevOps bill through various features, making it easy to find a balance between performance and cost.
This feature offers advanced management of Standby agents, allowing teams to better manage their costs compared to Scale Set agent pools.
We've observed private preview customers reducing their Azure billing by as much as 50% with the help of Managed DevOps Pools.
Inject Steps Automatically with Pipeline Decorators
Injecting steps automatically into your deployment jobs can be a game-changer for enforcing safe deployment practices.
Pipeline decorators are the key to making this happen, allowing you to auto-inject custom steps like vulnerability scanners into every lifecycle hook execution of every deployment job.
This means you can ensure that your deployment jobs are always running with an extra layer of security and quality control.
By applying pipeline decorators to all pipelines in an organization, you can set up a consistent and reliable process for injecting custom steps.
This can be a huge time-saver and help prevent mistakes that can occur when manually adding steps to each deployment job.
Pool Demands
Demands are a powerful feature in Azure DevOps that allow you to specify the capabilities of your agents. By default, if you don't use demands in your agent scaler, it scales based on the pool's queue length.
Demands are useful when you have multiple agents with different capabilities existing within the same pool. You can specify a comma-separated list of demands, such as maven, java, and make, and KEDA will determine which agents can fulfill the job based on these demands.
If you require all demands to be fulfilled exactly, you can set requireAllDemands to true. This means a job with demands maven will not match an agent with capabilities maven, java.
Here are the possible ways to use demands in your agent scaler:
- If neither parent nor demands are defined in the scaling definition, it will scale the workload to fulfill the job.
- If parent is set, KEDA will interrogate the job request to determine if the parent is able to fulfill the job. If the parent is able to complete the job it scales the workload to fulfill the request.
- Finally, if the demands are set in the scaling definition then KEDA will determine which agents can fulfill the job based on the demands provided.
Note that if more than one scaling definition is able to fulfill the demands of the job, they will both spin up an agent.
Sources
- https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues
- https://learn.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs
- https://keda.sh/docs/2.15/scalers/azure-pipelines/
- https://praveenkumarsreeram.com/2021/04/14/azure-devops-configure-self-hosted-agent-for-azure-pipelines/
- https://devblogs.microsoft.com/devops/managed-devops-pools/
Featured Images: pexels.com