AKS-Construction/bicep/aksagentpool.bicep

99 строки
2.8 KiB
Bicep
Исходник Постоянная ссылка Обычный вид История

2022-03-04 22:54:46 +03:00
param AksName string
param PoolName string
@description('The zones to use for a node pool')
param availabilityZones array = []
@description('OS disk type')
param osDiskType string
2022-03-04 22:54:46 +03:00
@description('VM SKU')
param agentVMSize string
2022-03-04 22:54:46 +03:00
@description('Disk size in GB')
param osDiskSizeGB int = 0
@description('The number of agents for the user node pool')
param agentCount int = 1
2022-03-04 22:54:46 +03:00
@description('The maximum number of nodes for the user node pool')
param agentCountMax int = 3
2022-03-04 22:54:46 +03:00
var autoScale = agentCountMax > agentCount
@description('The maximum number of pods per node.')
param maxPods int = 30
2022-03-21 15:15:03 +03:00
@description('Any taints that should be applied to the node pool')
param nodeTaints array = []
2022-03-22 15:47:57 +03:00
@description('Any labels that should be applied to the node pool')
param nodeLabels object = {}
2022-03-21 15:15:03 +03:00
@description('The subnet the node pool will use')
2022-03-04 22:54:46 +03:00
param subnetId string
@description('The subnet the pods will use')
2023-05-29 12:07:09 +03:00
param podSubnetID string = ''
@description('OS Type for the node pool')
@allowed(['Linux','Windows'])
param osType string
@allowed(['AzureLinux','Ubuntu','Windows2019','Windows2022'])
param osSKU string
@description('Assign a public IP per node')
param enableNodePublicIP bool = false
@description('If the node pool should use VM spot instances')
param spotInstance bool = false
@description('Apply a default sku taint to Windows node pools')
param autoTaintWindows bool = false
var taints = autoTaintWindows ? union(nodeTaints, ['sku=Windows:NoSchedule']) : nodeTaints
var spotProperties = {
scaleSetPriority: 'Spot'
scaleSetEvictionPolicy: 'Delete'
spotMaxPrice: -1
}
// Default OS Disk Size in GB for Linux is 30, for Windows is 100
var defaultOsDiskSizeGB = osType == 'Linux' ? 30 : 100
resource aks 'Microsoft.ContainerService/managedClusters@2024-01-01' existing = {
2022-03-04 22:54:46 +03:00
name: AksName
}
resource userNodepool 'Microsoft.ContainerService/managedClusters/agentPools@2024-01-01' = {
2022-03-04 22:54:46 +03:00
parent: aks
name: PoolName
properties: union({
mode: 'User'
vmSize: agentVMSize
count: agentCount
minCount: autoScale ? agentCount : null
maxCount: autoScale ? agentCountMax : null
enableAutoScaling: autoScale
availabilityZones: !empty(availabilityZones) ? availabilityZones : null
osDiskType: osDiskType
osSKU: osSKU
osDiskSizeGB: osDiskSizeGB == 0 ? defaultOsDiskSizeGB : osDiskSizeGB
osType: osType
maxPods: maxPods
type: 'VirtualMachineScaleSets'
vnetSubnetID: !empty(subnetId) ? subnetId : null
podSubnetID: !empty(podSubnetID) ? podSubnetID : null
upgradeSettings: spotInstance ? {} : {
maxSurge: '33%' //Spot pools can't set max surge
}
nodeTaints: taints
nodeLabels: nodeLabels
enableNodePublicIP: enableNodePublicIP
},
spotInstance ? spotProperties : {}
)
2022-03-04 22:54:46 +03:00
}