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')
|
2023-01-31 20:16:20 +03:00
|
|
|
param osDiskType string
|
2022-03-04 22:54:46 +03:00
|
|
|
|
|
|
|
@description('VM SKU')
|
2023-01-31 20:16:20 +03:00
|
|
|
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')
|
2023-01-31 20:16:20 +03:00
|
|
|
param agentCount int = 1
|
2022-03-04 22:54:46 +03:00
|
|
|
|
|
|
|
@description('The maximum number of nodes for the user node pool')
|
2023-01-31 20:16:20 +03:00
|
|
|
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
|
|
|
|
|
2023-05-05 16:18:36 +03:00
|
|
|
@description('The subnet the pods will use')
|
2023-05-29 12:07:09 +03:00
|
|
|
param podSubnetID string = ''
|
2023-05-05 16:18:36 +03:00
|
|
|
|
2022-05-20 12:46:12 +03:00
|
|
|
@description('OS Type for the node pool')
|
2023-01-31 20:16:20 +03:00
|
|
|
@allowed(['Linux','Windows'])
|
|
|
|
param osType string
|
|
|
|
|
2023-11-16 15:36:10 +03:00
|
|
|
@allowed(['AzureLinux','Ubuntu','Windows2019','Windows2022'])
|
2023-01-31 20:16:20 +03:00
|
|
|
param osSKU string
|
|
|
|
|
|
|
|
@description('Assign a public IP per node')
|
|
|
|
param enableNodePublicIP bool = false
|
|
|
|
|
2023-10-26 13:58:58 +03:00
|
|
|
@description('If the node pool should use VM spot instances')
|
|
|
|
param spotInstance bool = false
|
|
|
|
|
2023-01-31 20:16:20 +03:00
|
|
|
@description('Apply a default sku taint to Windows node pools')
|
|
|
|
param autoTaintWindows bool = false
|
|
|
|
|
|
|
|
var taints = autoTaintWindows ? union(nodeTaints, ['sku=Windows:NoSchedule']) : nodeTaints
|
2022-05-20 12:46:12 +03:00
|
|
|
|
2023-10-26 13:58:58 +03:00
|
|
|
var spotProperties = {
|
|
|
|
scaleSetPriority: 'Spot'
|
|
|
|
scaleSetEvictionPolicy: 'Delete'
|
|
|
|
spotMaxPrice: -1
|
|
|
|
}
|
|
|
|
|
2023-11-16 15:28:11 +03:00
|
|
|
// Default OS Disk Size in GB for Linux is 30, for Windows is 100
|
|
|
|
var defaultOsDiskSizeGB = osType == 'Linux' ? 30 : 100
|
|
|
|
|
2024-04-09 21:31:47 +03:00
|
|
|
resource aks 'Microsoft.ContainerService/managedClusters@2024-01-01' existing = {
|
2022-03-04 22:54:46 +03:00
|
|
|
name: AksName
|
|
|
|
}
|
|
|
|
|
2024-04-09 21:31:47 +03:00
|
|
|
resource userNodepool 'Microsoft.ContainerService/managedClusters/agentPools@2024-01-01' = {
|
2022-03-04 22:54:46 +03:00
|
|
|
parent: aks
|
|
|
|
name: PoolName
|
2023-10-26 13:58:58 +03:00
|
|
|
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
|
2023-11-16 15:28:11 +03:00
|
|
|
osDiskSizeGB: osDiskSizeGB == 0 ? defaultOsDiskSizeGB : osDiskSizeGB
|
2023-10-26 13:58:58 +03:00
|
|
|
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
|
|
|
}
|