Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ terraform.tfstate.backup

# corebuild
internal/corebuild/configuration/cgo.yaml

.idea/
6 changes: 5 additions & 1 deletion internal/corebuild/configuration/.corebuild.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ environment:
tenant_id: "?" # MANDATORY The id of the tenant where the subscription is located. Try to avoid cross tenant scenarios. Build and application infrastructure should be im same tenant.
region: "francecentral" # MANDATORY. Make sure the core build infrastructure is deployed in different region than the infrastructure you plan to deploy with the created agentpool.
node_sku: "Standard_B2s" # [Optional] SKU of the underlying virtual-machine-scale-set. Defaults to "Standard_B2s". Make sure, the provisioned subscription and region has sufficient usage and quotas for this setting.
node_disk_size_gb: 128 # [Optional] Default disk size is 30gb and can be extended if required
# [Optional] Default agent directory is mounted in ephemeral storage. Size depends on node sku. Add data disk if additional agent storage required.
data_disk:
enabled: false
size_gb: 32
type: "StandardSSD_LRS"

security:
authorized_ip_ranges:
Expand Down
17 changes: 11 additions & 6 deletions internal/corebuild/configuration/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ type SourceConfig struct {
Security Security `yaml:"security" json:"security"`
AzureDevops AzureDevops `yaml:"azure_devops" json:"azure_devops"`
}
type DataDisk struct {
Enabled bool `yaml:"enabled" json:"enabled"`
SizeGb int `yaml:"size_gb" json:"size_gb"`
Type string `yaml:"type" json:"type"`
}
type Environment struct {
Name string `yaml:"name" json:"name"`
SubscriptionID string `yaml:"subscription_id" json:"subscription_id"`
TenantID string `yaml:"tenant_id" json:"tenant_id"`
Region string `yaml:"region" json:"region"`
NodeSku string `yaml:"node_sku" json:"node_sku"`
NodeDiskSizeGb int `yaml:"node_disk_size_gb" json:"node_disk_size_gb"`
Name string `yaml:"name" json:"name"`
SubscriptionID string `yaml:"subscription_id" json:"subscription_id"`
TenantID string `yaml:"tenant_id" json:"tenant_id"`
Region string `yaml:"region" json:"region"`
NodeSku string `yaml:"node_sku" json:"node_sku"`
DataDisk DataDisk `yaml:"data_disk" json:"data_disk"`
}
type AuthorizedIPRanges struct {
Cidrs []string `yaml:"cidrs" json:"cidrs"`
Expand Down
5 changes: 4 additions & 1 deletion internal/corebuild/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ func (o *Orchestrator) initializeTerraform() (terraform.Terraform, error) {
vars["build_agent_pool_lb_name"] = loadBalancerName
vars["build_agent_pool_name"] = vmss
vars["build_agent_pool_node_sku"] = o.config.Environment.NodeSku
vars["build_agent_pool_node_disk_size_gb"] = o.config.Environment.NodeDiskSizeGb

vars["build_agent_pool_data_disk_enabled"] = o.config.Environment.DataDisk.Enabled
vars["build_agent_pool_data_disk_size_gb"] = o.config.Environment.DataDisk.SizeGb
vars["build_agent_pool_data_disk_type"] = o.config.Environment.DataDisk.Type

vars["azure_devops_project_name"] = o.config.AzureDevops.ProjectName
vars["azure_devops_service_connection_name"] = fmt.Sprintf("%s-federated-serviceconnection", o.config.Environment.Name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ disk_setup:
table_type: gpt
layout: [66, [33,82]]
overwrite: true
%{ if use_data_disk ~}
/dev/sdc:
table_type: gpt
layout: true
overwrite: true
%{ endif ~}

fs_setup:
- device: ephemeral0.1
filesystem: ext4
%{ if use_data_disk ~}
- device: /dev/sdc
filesystem: ext4
%{ endif ~}

mounts:
- ["ephemeral0.1", "/agent"]
%{ if use_data_disk ~}
- ["/dev/sdc", "/agent"]
%{ else ~}
- ["ephemeral0.1", "/agent"]
%{ endif ~}

4 changes: 3 additions & 1 deletion internal/corebuild/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ variable "build_agent_pool_lb_name" {}
####################################
variable "build_agent_pool_name" {}
variable "build_agent_pool_node_sku" {}
variable "build_agent_pool_node_disk_size_gb" {}
variable "build_agent_pool_data_disk_enabled" {}
variable "build_agent_pool_data_disk_size_gb" {}
variable "build_agent_pool_data_disk_type" {}

####################################
// Azure Devops Buildagent
Expand Down
16 changes: 14 additions & 2 deletions internal/corebuild/terraform/vmss.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ resource "azurerm_linux_virtual_machine_scale_set" "buildagentpool" {
upgrade_mode = "Manual"
single_placement_group = false
platform_fault_domain_count = 1
custom_data = filebase64("${path.module}/config/cloud-config.txt")
custom_data = base64encode(templatefile("${path.module}/config/cloud-config.tpl", {
use_data_disk = var.build_agent_pool_data_disk_enabled
}))

# https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-upgrade#supported-os-images
source_image_reference {
Expand All @@ -34,7 +36,17 @@ resource "azurerm_linux_virtual_machine_scale_set" "buildagentpool" {
os_disk {
storage_account_type = "StandardSSD_LRS"
caching = "ReadWrite"
disk_size_gb = var.build_agent_pool_node_disk_size_gb == 0 ? null : var.build_agent_pool_node_disk_size_gb
}

dynamic "data_disk" {
for_each = var.build_agent_pool_data_disk_enabled ? [1] : []

content {
lun = 0
disk_size_gb = var.build_agent_pool_data_disk_size_gb
caching = "ReadWrite"
storage_account_type = var.build_agent_pool_data_disk_type
}
}

identity {
Expand Down