@Samuel.Yan , Thank you for your question. Since you have created an AKS cluster with --vm-set-type
set to AvailabilitySet
, you can scale your cluster up/down to add/remove nodes respectively.
In Azure CLI this can be implemented as:
az aks scale --resource-group $ClusterResourceGroup --name $ClusterName --node-count $DesiredNodeCount
For more information please check here.
Using Azure Python SDK you can define the scale function:
def aks_scale(cmd, client, resource_group_name, name, node_count, nodepool_name="", no_wait=False):
instance = client.get(resource_group_name, name)
if len(instance.agent_pool_profiles) > 1 and nodepool_name == "":
raise CLIError('There are more than one node pool in the cluster. '
'Please specify nodepool name or use az aks nodepool command to scale node pool')
if node_count == 0:
raise CLIError("Can't scale down to 0 nodes.")
for agent_profile in instance.agent_pool_profiles:
if agent_profile.name == nodepool_name or (nodepool_name == "" and len(instance.agent_pool_profiles) == 1):
agent_profile.count = int(node_count) # pylint: disable=no-member
# null out the SP and AAD profile because otherwise validation complains
instance.service_principal_profile = None
instance.aad_profile = None
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
raise CLIError('The nodepool "{}" was not found.'.format(nodepool_name))
as described here.
For more information please check the Container Service Management Library azure-mgmt-containerservice.
You need not manage the infrastructural resources (like VM, NIC, OS Disk etc) manually and we highly recommend against doing so as these might have adverse effects of desynchronization with the AKS control plane. Microsoft.ContainerService
Resource Provider will manage these for you under the hood if you are using az aks
commands or the azure-mgmt-containerservice Azure Python SDK Library to operate on your AKS cluster.
----
Hope this helps.
Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.