-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit with changes from private repo till revision - e80111761c191ee6366a2af830fa53e1e092fd95
- Loading branch information
0 parents
commit 1a8796c
Showing
197 changed files
with
15,512 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.gradle/ | ||
.idea/ | ||
*.iml | ||
build/ | ||
out/ | ||
src/main/resources-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Create an elastic agent profile for Azure | ||
The elastic agent profile provides an ability to configure an Azure Instance with the required OS, size and other parameters. | ||
|
||
* Navigate to **_Admin > Elastic Agent Profiles_** in the main menu | ||
* Click the **_Add_** button to create a new elastic agent profile | ||
|
||
![Alt text](readme-screenshots/azure/elastic_profile/profile_listing.png?raw=true "Elastic Profile") | ||
|
||
**_Note:_** *Configuration marked with (\*) are mandatory* | ||
|
||
* Choose the Plugin ID and provide the name for the elastic profile to be created. | ||
|
||
![Alt text](readme-screenshots/azure/elastic_profile/elastic_profile_1.png?raw=true "Elastic Profile") | ||
|
||
#Azure instance configuration | ||
|
||
![Alt text](readme-screenshots/azure/elastic_profile/elastic_profile_2.png?raw=true "Elastic Profile") | ||
|
||
1. **Operating system\*:** Choose the platform or the operating system to be installed on the Azure instance. | ||
|
||
2. Provide one of the two options to setup the platform on the instance. | ||
|
||
a. **Image URN:** Specify the base [image urn](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage#terminology) from Azure market place for specific version of OS to be installed. | ||
|
||
b. **Custom Image Id:** Optionally if you have a custom image built with all the necessary dependencies associated with your subscription, provide the resource id here. | ||
|
||
3. **Size\*:** Size of the virtual machine which defines machine configuration like number of CPU cores, memory, storage. [Available sizes](https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-sizes-specs) | ||
|
||
4. **OS Disk Storage type\*:** Choose the storage type of OS disk [Standard SSD | Premium SSD | Standard HDD] based on the agent vm's responsibility. | ||
|
||
5. **OS Disk size (in GB):** This field is to capture the os disk size for the agent. | ||
|
||
6. **Custom Script:** Post provision scripts such as environment variable configuration, custom software installation scripts can be provided here. | ||
Shell script for Linux and Powershell script for windows are supported. The script will be run as System user on windows. | ||
|
||
7. **Agent Idle timeout (in minutes):** Agent virtual machines will be kept idle for this period(specified in minutes) before termination, after job completion. This setting overrides the value configured in Plugin settings. | ||
|
||
8. **Subnet name:** Name of the subnet in which the agent virtual machine has to be created. This value has to be one of the subnets configured in plugin settings. If this field is blank, agent virtual machine will be created in one of the subnets provided in the Plugin settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# GoCD Microsoft Azure Elastic Agent Plugin | ||
|
||
The plugin needs to be configured with elastic profile configurations in order to create VMs on azure. | ||
|
||
Table of Contents | ||
================= | ||
|
||
* [Prerequisites](#prerequisites) | ||
* [Installation](#installation) | ||
* [Configuration](#configuring-the-azure-elastic-agent-plugin) | ||
|
||
## Prerequisites | ||
|
||
### Go Server | ||
* The GoCD server version **18.10.0** or higher. | ||
|
||
### Azure subscription | ||
* You will need a valid [Azure subscription](https://azure.microsoft.com/en-us/free/) with privileges to create Virtual machines inside it. | ||
* There should be a [virtual network](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview) created in the azure subscription, go-agent virtual machines will be created inside it. | ||
|
||
A virtual network enables Azure resources, such as virtual machines (VM), to communicate privately with each other and with the internet. Please note the EA created will need to communicate with your GoCD server. | ||
|
||
`az network vnet create --name gocd-virtual-network --resource-group gocd-resource-group --subnet-name default` | ||
|
||
After the successful creation of the virtual network please note the Virtual Network ID from the response which will be similar to | ||
|
||
```json | ||
{ | ||
"id": "/subscriptions/3986fa0c-d463-4qf7-b508-cc38db097f58/resourceGroups/gocd-resource-group/providers/Microsoft.Network/virtualNetworks/gocd-virtual-network" | ||
} | ||
``` | ||
|
||
Refer [azure documentation](https://docs.microsoft.com/en-us/azure/virtual-network/quick-create-cli) for managing your Virtual Networks | ||
|
||
* Create a new [resource group](https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-key-features#resource-groups) which will contain all the go-agent virtual machines. | ||
A resource group is a container that holds related resources for an Azure solution. GoCD uses the resource group to create as a container in which it creates your Azure EA. | ||
|
||
`az group create --name gocd-resource-group --location "Central US"` | ||
|
||
On successful creation of a Resource Group | ||
|
||
```json | ||
{ | ||
"id": "/subscriptions/3386fa3c-d463-4cf7-b508-cc38db097e58/resourceGroups/gocd-resource-group", | ||
"location": "centralus", | ||
"managedBy": null, | ||
"name": "gocd-resource-group", | ||
"properties": { | ||
"provisioningState": "Succeeded" | ||
}, | ||
"tags": null | ||
} | ||
``` | ||
|
||
Refer [azure documentation](https://docs.microsoft.com/en-us/azure/azure-resource-manager/cli-azure-resource-manager#create-a-resource-group) for managing your resource groups. | ||
|
||
* Create a [service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest) with access to create network interfaces, virtual machines, network security groups and managed disks in the region of the virtual network. The service principal credentials are required to setup the plugin. | ||
|
||
Service principals are separate identities that can be associated with an account. The service principal [clientid/secret] is used for sdk authentication | ||
|
||
`az ad sp create-for-rbac --name ServicePrincipalName --password PASSWORD` | ||
|
||
On successful creation of a Service Principal | ||
|
||
```json | ||
{ | ||
"appId": "f6a9bfde-414f-4700-a10c-07eafb7f1eaa", | ||
"displayName": "ServicePrincipalName", | ||
"name": "http://ServicePrincipalName", | ||
"password": "PASSWORD", | ||
"tenant": "cf03984b-4fa1-465f-b731-wecea9eece05" | ||
} | ||
``` | ||
Refer [azure documentation](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest) for creating a service principal. | ||
|
||
By default a service principal will have a [Contributor](https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#contributor) role. For more fine grained access control, ensure that the service principal has the following access: | ||
|
||
<pre class="highlight shell"> | ||
<code> | ||
Microsoft.Compute/virtualMachines/* | ||
Microsoft.Network/networkInterfaces/* | ||
Microsoft.Compute/disks/* | ||
Microsoft.Compute/locations/* | ||
Microsoft.Resources/subscriptions/resourceGroups/read | ||
Microsoft.Network/virtualNetworks/read | ||
Microsoft.Network/virtualNetworks/subnets/read | ||
Microsoft.Network/virtualNetworks/subnets/join/* | ||
Microsoft.Network/networkSecurityGroups/read" | ||
Microsoft.Network/networkSecurityGroups/join/* | ||
</code> | ||
</pre> | ||
|
||
You can create a [custom role](https://docs.microsoft.com/en-us/azure/role-based-access-control/custom-roles) using the below template. Ensure this role is [assigned to the service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#manage-service-principal-roles). | ||
|
||
<pre class="highlight shell"> | ||
<code> | ||
{ | ||
"Actions": [ | ||
"Microsoft.Compute/virtualMachines/*", | ||
"Microsoft.Network/networkInterfaces/*", | ||
"Microsoft.Compute/disks/*", | ||
"Microsoft.Compute/locations/*", | ||
"Microsoft.Resources/subscriptions/resourceGroups/read", | ||
"Microsoft.Network/virtualNetworks/read", | ||
"Microsoft.Network/virtualNetworks/subnets/read", | ||
"Microsoft.Network/virtualNetworks/subnets/join/*", | ||
"Microsoft.Network/networkSecurityGroups/read", | ||
"Microsoft.Network/networkSecurityGroups/join/*", | ||
"Microsoft.Resources/subscriptions/locations/read" | ||
], | ||
"AssignableScopes": [ | ||
"/subscriptions/{subscriptionId}" | ||
], | ||
"DataActions": [], | ||
"Description": "Role for service principal used for GoCD Azure elastic agent plugin", | ||
"IsCustom": true, | ||
"Name": "gocd-azure-plugin-scope", | ||
"NotActions": [], | ||
"NotDataActions": [] | ||
} | ||
</code> | ||
</pre> | ||
|
||
### Some useful commands | ||
|
||
1. az group list : List resource groups for a user account | ||
2. az account list-locations : List of allowed locations for deploying resources for an account | ||
3. az network vnet list : List of virtual networks for a user account | ||
4. az ad sp list --display-name <service-principal-name> : Details of the service principal | ||
|
||
### Related help topics | ||
|
||
1. [Getting Started with Microsoft Azure](https://azure.microsoft.com/en-in/get-started/) | ||
2. [Azure virtual machines](https://azure.microsoft.com/en-us/services/virtual-machines/) | ||
3. [Azure service principal](https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals) | ||
4. [Custom roles](https://docs.microsoft.com/en-us/azure/role-based-access-control/custom-roles) | ||
|
||
## Installation | ||
|
||
* Copy the file `build/libs/azure-elastic-agent-plugin-VERSION.jar` to the GoCD server under `${GO_SERVER_DIR}/plugins/external` | ||
and restart the server. | ||
* The `GO_SERVER_DIR` is usually `/var/lib/go-server` on **Linux** and `C:\Program Files\Go Server` on **Windows**. | ||
|
||
## Configuring the Azure Elastic Agent Plugin | ||
|
||
1. Configure the GoCD Azure Elastic Agent [Plugin Settings](./PLUGIN_SETTINGS.md): The plugin settings are used to provide global level configurations for the plugin. Configurations such as Azure credentials, Azure settings like Virtual Network, region, Go Server configuration are provided in plugin settings. | ||
|
||
![Alt text](readme-screenshots/azure-plugin-settings.png?raw=true "azure-plugin-settings") | ||
|
||
2. Configure an [Elastic Profile](./ELASTIC_PROFILE_CONFIGURATION.md) for GoCD Azure Elastic Agent Plugin: The Elastic Agent Profile is used to define the configuration of the Azure instance. The profile is used to configure the platform, VM image, size and the custom scripts to be run on the instance. | ||
|
||
![Alt text](readme-screenshots/azure-elastic-profile.png?raw=true "azure-elastic-profile") | ||
|
||
3. Assign the Elastic Profile to a job | ||
|
||
![Alt text](readme-screenshots/assign-elastic-profile.png?raw=true "assign-elastic-profile") | ||
|
||
|
Oops, something went wrong.