From 615a519f63a35f01c01b65ca302ca19a0b0f58d2 Mon Sep 17 00:00:00 2001 From: Gordon Byers Date: Fri, 30 Jun 2023 12:10:49 +0100 Subject: [PATCH 1/5] natgw not preview --- helper/src/components/deployTab.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/helper/src/components/deployTab.js b/helper/src/components/deployTab.js index b439e7be5..228b2bc5c 100644 --- a/helper/src/components/deployTab.js +++ b/helper/src/components/deployTab.js @@ -117,6 +117,17 @@ export default function DeployTab({ defaults, updateFn, tabValues, invalidArray, ...(cluster.keyVaultKms === "public" && {keyVaultKmsCreate: true, keyVaultKmsOfficerRolePrincipalId: "$(az ad signed-in-user show --query id --out tsv)"}), ...(cluster.keyVaultKms === "byoprivate" && cluster.keyVaultKmsByoKeyId !== '' && cluster.keyVaultKmsByoRG !== '' && {keyVaultKmsByoKeyId: cluster.keyVaultKmsByoKeyId, keyVaultKmsByoRG: cluster.keyVaultKmsByoRG}), }), + ...(net.vnet_opt === "default" && net.aksOutboundTrafficType === 'natGateway' && { + ...(net.aksOutboundTrafficType !== defaults.net.aksOutboundTrafficType && {aksOutboundTrafficType: net.aksOutboundTrafficType}), + ...(net.natGwIpCount !== defaults.net.natGwIpCount && {natGwIpCount: net.natGwIpCount}), + ...(net.natGwIdleTimeout !== defaults.net.natGwIdleTimeout && {natGwIdleTimeout: net.natGwIdleTimeout}) + }), + ...(net.vnet_opt === "custom" && net.aksOutboundTrafficType === 'natGateway' && { + ...({createNatGateway: true}), + ...(net.aksOutboundTrafficType !== defaults.net.aksOutboundTrafficType && {aksOutboundTrafficType: net.aksOutboundTrafficType}), + ...(net.natGwIpCount !== defaults.net.natGwIpCount && {natGwIpCount: net.natGwIpCount}), + ...(net.natGwIdleTimeout !== defaults.net.natGwIdleTimeout && {natGwIdleTimeout: net.natGwIdleTimeout}) + }), ...(addons.csisecret !== "none" && { keyVaultAksCSI: true }), ...(addons.csisecret === 'akvNew' && { keyVaultCreate: true, ...(deploy.kvCertSecretRole && { keyVaultOfficerRolePrincipalId: "$(az ad signed-in-user show --query id --out tsv)"}) }), ...(addons.csisecret !== "none" && addons.keyVaultAksCSIPollInterval !== defaults.addons.keyVaultAksCSIPollInterval && { keyVaultAksCSIPollInterval: addons.keyVaultAksCSIPollInterval }), @@ -135,17 +146,6 @@ export default function DeployTab({ defaults, updateFn, tabValues, invalidArray, const preview_params = { ...(addons.registry === "Premium" && addons.acrUntaggedRetentionPolicyEnabled !== defaults.addons.acrUntaggedRetentionPolicyEnabled && { acrUntaggedRetentionPolicyEnabled: addons.acrUntaggedRetentionPolicyEnabled}), ...(addons.registry === "Premium" && addons.acrUntaggedRetentionPolicyEnabled && addons.acrUntaggedRetentionPolicy !== defaults.addons.acrUntaggedRetentionPolicy && { acrUntaggedRetentionPolicy: addons.acrUntaggedRetentionPolicy}), - ...(net.vnet_opt === "default" && net.aksOutboundTrafficType === 'natGateway' && { - ...(net.aksOutboundTrafficType !== defaults.net.aksOutboundTrafficType && {aksOutboundTrafficType: net.aksOutboundTrafficType}), - ...(net.natGwIpCount !== defaults.net.natGwIpCount && {natGwIpCount: net.natGwIpCount}), - ...(net.natGwIdleTimeout !== defaults.net.natGwIdleTimeout && {natGwIdleTimeout: net.natGwIdleTimeout}) - }), - ...(net.vnet_opt === "custom" && net.aksOutboundTrafficType === 'natGateway' && { - ...({createNatGateway: true}), - ...(net.aksOutboundTrafficType !== defaults.net.aksOutboundTrafficType && {aksOutboundTrafficType: net.aksOutboundTrafficType}), - ...(net.natGwIpCount !== defaults.net.natGwIpCount && {natGwIpCount: net.natGwIpCount}), - ...(net.natGwIdleTimeout !== defaults.net.natGwIdleTimeout && {natGwIdleTimeout: net.natGwIdleTimeout}) - }), ...(net.vnet_opt === "custom" && net.vnetprivateend && { ...(addons.registry !== "none" && { ...(addons.acrPrivatePool !== defaults.addons.acrPrivatePool && {acrPrivatePool: addons.acrPrivatePool}), From 6fddf334c75ef50eefbb523ae7f3a1d953929ceb Mon Sep 17 00:00:00 2001 From: Gordon Byers Date: Sat, 8 Jul 2023 22:19:13 +0100 Subject: [PATCH 2/5] spot bicep --- bicep/aksagentpool.bicep | 56 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/bicep/aksagentpool.bicep b/bicep/aksagentpool.bicep index 6fba74382..fad15b3d1 100644 --- a/bicep/aksagentpool.bicep +++ b/bicep/aksagentpool.bicep @@ -46,11 +46,19 @@ param osSKU string @description('Assign a public IP per node') param enableNodePublicIP bool = false +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 +} + resource aks 'Microsoft.ContainerService/managedClusters@2021-10-01' existing = { name: AksName } @@ -58,27 +66,29 @@ resource aks 'Microsoft.ContainerService/managedClusters@2021-10-01' existing = resource userNodepool 'Microsoft.ContainerService/managedClusters/agentPools@2021-10-01' = { parent: aks name: PoolName - properties: { - 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 - osType: osType - maxPods: maxPods - type: 'VirtualMachineScaleSets' - vnetSubnetID: !empty(subnetId) ? subnetId : null - podSubnetID: !empty(podSubnetID) ? podSubnetID : null - upgradeSettings: { - maxSurge: '33%' - } - nodeTaints: taints - nodeLabels: nodeLabels - enableNodePublicIP: enableNodePublicIP - } + 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 + osType: osType + maxPods: maxPods + type: 'VirtualMachineScaleSets' + vnetSubnetID: !empty(subnetId) ? subnetId : null + podSubnetID: !empty(podSubnetID) ? podSubnetID : null + upgradeSettings: { + maxSurge: '33%' + } + nodeTaints: taints + nodeLabels: nodeLabels + enableNodePublicIP: enableNodePublicIP + }, + spotInstance ? spotProperties : {} + ) } From 2a76fc50b1e4c0c3c1e3aa7a5e7ff6acd7c89b49 Mon Sep 17 00:00:00 2001 From: Gordon Byers Date: Sun, 9 Jul 2023 00:03:40 +0100 Subject: [PATCH 3/5] spot --- bicep/main.bicep | 4 ++++ helper/src/components/clusterTab.js | 1 + helper/src/components/deployTab.js | 1 + helper/src/config.json | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bicep/main.bicep b/bicep/main.bicep index 6aed3e26e..3fa9e95eb 100644 --- a/bicep/main.bicep +++ b/bicep/main.bicep @@ -921,6 +921,9 @@ var autoScale = agentCountMax > agentCount @description('Name for user node pool') param nodePoolName string = 'npuser01' +@description('Config the user node pool as a spot instance') +param nodePoolSpot bool = false + @description('Allocate pod ips dynamically') param cniDynamicIpAllocation bool = false @@ -1392,6 +1395,7 @@ module userNodePool '../bicep/aksagentpool.bicep' = if (!JustUseSystemPool){ enableNodePublicIP: enableNodePublicIP osDiskSizeGB: osDiskSizeGB availabilityZones: availabilityZones + spotInstance: nodePoolSpot } } diff --git a/helper/src/components/clusterTab.js b/helper/src/components/clusterTab.js index 430b4aa63..248c55232 100644 --- a/helper/src/components/clusterTab.js +++ b/helper/src/components/clusterTab.js @@ -223,6 +223,7 @@ export default function ({ defaults, tabValues, updateFn, featureFlag, invalidAr {getError(invalidArray, 'osDiskType')} } updateFn('vmSize', val)} required errorMessage={getError(invalidArray, 'vmSize')} value={cluster.vmSize} /> + updateFn("nodePoolSpot", val)} disabled={cluster.SystemPoolType=='none'} onRenderLabel={() => Spot Instance} /> updateFn("osDiskType", key)} selectedKey={cluster.osDiskType} diff --git a/helper/src/components/deployTab.js b/helper/src/components/deployTab.js index 146e87fd9..677df456a 100644 --- a/helper/src/components/deployTab.js +++ b/helper/src/components/deployTab.js @@ -40,6 +40,7 @@ export default function DeployTab({ defaults, updateFn, tabValues, invalidArray, ...(cluster.autoscale && { agentCountMax: cluster.maxCount }), ...(cluster.osType !== defaults.cluster.osType && { osType: cluster.osType}), ...(cluster.osSKU !== defaults.cluster.osSKU && { osSKU: cluster.osSKU}), + ...(cluster.nodePoolSpot !== defaults.cluster.nodePoolSpot && { nodePoolSpot: cluster.nodePoolSpot}), ...(cluster.osDiskType === "Managed" && { osDiskType: cluster.osDiskType, ...(cluster.osDiskSizeGB > 0 && { osDiskSizeGB: cluster.osDiskSizeGB }) }), ...(net.vnet_opt === "custom" && { custom_vnet: true, diff --git a/helper/src/config.json b/helper/src/config.json index 42dcd7184..3717a7c10 100644 --- a/helper/src/config.json +++ b/helper/src/config.json @@ -58,7 +58,8 @@ "enableAzureRBAC": true, "aadgroupids": "", "availabilityZones": "no", - "DefenderForContainers" : false + "DefenderForContainers" : false, + "nodePoolSpot": false }, "addons": { "logDataCap": 0, From 26b2780f3c311a5ba15a65eac17294a33af1a5e4 Mon Sep 17 00:00:00 2001 From: Gordon Byers Date: Sun, 9 Jul 2023 00:05:36 +0100 Subject: [PATCH 4/5] userpool only --- helper/src/components/deployTab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/src/components/deployTab.js b/helper/src/components/deployTab.js index 677df456a..ed84157a9 100644 --- a/helper/src/components/deployTab.js +++ b/helper/src/components/deployTab.js @@ -40,7 +40,7 @@ export default function DeployTab({ defaults, updateFn, tabValues, invalidArray, ...(cluster.autoscale && { agentCountMax: cluster.maxCount }), ...(cluster.osType !== defaults.cluster.osType && { osType: cluster.osType}), ...(cluster.osSKU !== defaults.cluster.osSKU && { osSKU: cluster.osSKU}), - ...(cluster.nodePoolSpot !== defaults.cluster.nodePoolSpot && { nodePoolSpot: cluster.nodePoolSpot}), + ...(cluster.SystemPoolType !== 'none' && cluster.nodePoolSpot !== defaults.cluster.nodePoolSpot && { nodePoolSpot: cluster.nodePoolSpot}), ...(cluster.osDiskType === "Managed" && { osDiskType: cluster.osDiskType, ...(cluster.osDiskSizeGB > 0 && { osDiskSizeGB: cluster.osDiskSizeGB }) }), ...(net.vnet_opt === "custom" && { custom_vnet: true, From 634d8b2c7c6466154f9cee4f32059f18e44c8f47 Mon Sep 17 00:00:00 2001 From: Gordon Byers Date: Sun, 9 Jul 2023 11:43:05 +0100 Subject: [PATCH 5/5] maxsurge --- bicep/aksagentpool.bicep | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bicep/aksagentpool.bicep b/bicep/aksagentpool.bicep index fad15b3d1..534e77f76 100644 --- a/bicep/aksagentpool.bicep +++ b/bicep/aksagentpool.bicep @@ -46,6 +46,7 @@ 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') @@ -82,8 +83,8 @@ resource userNodepool 'Microsoft.ContainerService/managedClusters/agentPools@202 type: 'VirtualMachineScaleSets' vnetSubnetID: !empty(subnetId) ? subnetId : null podSubnetID: !empty(podSubnetID) ? podSubnetID : null - upgradeSettings: { - maxSurge: '33%' + upgradeSettings: spotInstance ? {} : { + maxSurge: '33%' //Spot pools can't set max surge } nodeTaints: taints nodeLabels: nodeLabels