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 src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Pending
* `az aks create`: Add `--enable-upgrade-gate` to enable health-aware upgrade gating for the cluster.
* `az aks update`: Add `--enable-upgrade-gate` and `--disable-upgrade-gate` to enable or disable health-aware upgrade gating for the cluster.
* `az aks nodepool add/update`: Add `--enable-upgrade-gate` and `--disable-upgrade-gate` to enable or disable health-aware upgrade gating for the node pool.
* `az aks nodepool scale`: extend `--use-patch-api` to VirtualMachines node pools so they also scale via the dedicated PATCH agent pool API.
* `az aks nodepool manual-scale add/update/delete`: add `--use-patch-api` to manage the manual scale profiles of a VirtualMachines node pool via the dedicated PATCH agent pool API instead of the default PUT API.

22.0.0b13
+++++++++
Expand Down
20 changes: 19 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2836,18 +2836,36 @@ def load_arguments(self, _):
"use_patch_api",
action="store_true",
is_preview=True,
help="Scale a VMSS node pool using the preview PATCH agent pool API instead of the default PUT API.",
help="Scale a node pool using the preview PATCH agent pool API instead of the default PUT API.",
)

with self.argument_context("aks nodepool manual-scale add") as c:
c.argument("vm_sizes", is_preview=True)
c.argument(
"use_patch_api",
action="store_true",
is_preview=True,
help="Manage the manual scale profiles using the preview PATCH agent pool API instead of the default PUT API.",
)

with self.argument_context("aks nodepool manual-scale update") as c:
c.argument("current_vm_sizes", is_preview=True)
c.argument("vm_sizes", is_preview=True)
c.argument(
"use_patch_api",
action="store_true",
is_preview=True,
help="Manage the manual scale profiles using the preview PATCH agent pool API instead of the default PUT API.",
)

with self.argument_context("aks nodepool manual-scale delete") as c:
c.argument("current_vm_sizes", is_preview=True)
c.argument(
"use_patch_api",
action="store_true",
is_preview=True,
help="Manage the manual scale profiles using the preview PATCH agent pool API instead of the default PUT API.",
)

with self.argument_context("aks nodepool auto-scale add") as c:
c.argument("node_vm_size", is_preview=True)
Expand Down
85 changes: 76 additions & 9 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,10 +2498,9 @@ def aks_agentpool_scale(cmd, # pylint: disable=unused-argument
instance.count = new_node_count # pylint: disable=no-member

# By default scale via the PUT agent pool API (begin_create_or_update).
# When --use-patch-api is set, scale a VMSS node pool via the preview PATCH agent
# When --use-patch-api is set, scale the node pool via the preview PATCH agent
# pool API, which scales to the target count without a full reconciliation.
# VirtualMachines node pools are not supported yet and keep using the PUT API.
if use_patch_api and instance.type_properties_type == CONST_VIRTUAL_MACHINE_SCALE_SETS:
if use_patch_api:
return _aks_agentpool_scale_patch(
cmd,
client,
Expand Down Expand Up @@ -2531,10 +2530,11 @@ def _aks_agentpool_scale_patch(cmd,
instance,
headers=None,
no_wait=False):
"""Scale a VMSS agent pool via the dedicated PATCH agent pool API.
"""Scale an agent pool via the dedicated PATCH agent pool API.

Sends only the already-updated target count on ``instance`` so the pool scales
without triggering a full agent pool reconciliation.
Sends only the already-updated target count (VMSS) or manual scale profiles
(VirtualMachines) on ``instance`` so the pool scales without triggering a full
agent pool reconciliation.
"""
AgentPoolUpdate = cmd.get_models(
"AgentPoolUpdate",
Expand All @@ -2547,7 +2547,35 @@ def _aks_agentpool_scale_patch(cmd,
operation_group="agent_pools",
)

parameters = AgentPoolUpdate(properties=AgentPoolUpdateProperties(count=instance.count))
if instance.type_properties_type == CONST_VIRTUAL_MACHINES:
AgentPoolUpdateVirtualMachinesProfile = cmd.get_models(
"AgentPoolUpdateVirtualMachinesProfile",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="agent_pools",
)
AgentPoolUpdateScaleProfile = cmd.get_models(
"AgentPoolUpdateScaleProfile",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="agent_pools",
)
AgentPoolUpdateManualScaleProfile = cmd.get_models(
"AgentPoolUpdateManualScaleProfile",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="agent_pools",
)
manual = [
AgentPoolUpdateManualScaleProfile(size=m.size, count=m.count)
for m in instance.virtual_machines_profile.scale.manual
]
properties = AgentPoolUpdateProperties(
virtual_machines_profile=AgentPoolUpdateVirtualMachinesProfile(
scale=AgentPoolUpdateScaleProfile(manual=manual)
)
)
else:
properties = AgentPoolUpdateProperties(count=instance.count)

parameters = AgentPoolUpdate(properties=properties)
return sdk_no_wait(
no_wait,
client.begin_update,
Expand Down Expand Up @@ -3097,6 +3125,7 @@ def aks_agentpool_manual_scale_add(cmd,
nodepool_name,
vm_sizes,
node_count,
use_patch_api=False,
no_wait=False):
instance = client.get(resource_group_name, cluster_name, nodepool_name)
if instance.type_properties_type != CONST_VIRTUAL_MACHINES:
Expand All @@ -3112,6 +3141,18 @@ def aks_agentpool_manual_scale_add(cmd,
new_manual_scale_profile = ManualScaleProfile(size=sizes[0], count=int(node_count))
instance.virtual_machines_profile.scale.manual.append(new_manual_scale_profile)

# When --use-patch-api is set, add the manual scale profile via the preview
# PATCH agent pool API instead of the default PUT API.
if use_patch_api:
return _aks_agentpool_scale_patch(
cmd,
client,
resource_group_name,
cluster_name,
nodepool_name,
instance,
no_wait=no_wait,
)
return sdk_no_wait(
no_wait,
client.begin_create_or_update,
Expand All @@ -3122,14 +3163,15 @@ def aks_agentpool_manual_scale_add(cmd,
)


def aks_agentpool_manual_scale_update(cmd, # pylint: disable=unused-argument
def aks_agentpool_manual_scale_update(cmd,
client,
resource_group_name,
cluster_name,
nodepool_name,
current_vm_sizes,
vm_sizes=None,
node_count=None,
use_patch_api=False,
no_wait=False):
if vm_sizes is None and node_count is None:
raise RequiredArgumentMissingError("specify --vm-sizes or --node-count or both.")
Expand Down Expand Up @@ -3160,6 +3202,18 @@ def aks_agentpool_manual_scale_update(cmd, # pylint: disable=unused-argument
f"Manual with size {current_vm_sizes[0]} doesn't exist in node pool {nodepool_name}"
)

# When --use-patch-api is set, update the manual scale profiles via the preview
# PATCH agent pool API instead of the default PUT API.
if use_patch_api:
return _aks_agentpool_scale_patch(
cmd,
client,
resource_group_name,
cluster_name,
nodepool_name,
instance,
no_wait=no_wait,
)
return sdk_no_wait(
no_wait,
client.begin_create_or_update,
Expand All @@ -3170,12 +3224,13 @@ def aks_agentpool_manual_scale_update(cmd, # pylint: disable=unused-argument
)


def aks_agentpool_manual_scale_delete(cmd, # pylint: disable=unused-argument
def aks_agentpool_manual_scale_delete(cmd,
client,
resource_group_name,
cluster_name,
nodepool_name,
current_vm_sizes,
use_patch_api=False,
no_wait=False):
instance = client.get(resource_group_name, cluster_name, nodepool_name)
if instance.type_properties_type != CONST_VIRTUAL_MACHINES:
Expand All @@ -3196,6 +3251,18 @@ def aks_agentpool_manual_scale_delete(cmd, # pylint: disable=unused-argument
f"Manual with size {current_vm_sizes[0]} doesn't exist in node pool {nodepool_name}"
)

# When --use-patch-api is set, delete the manual scale profile via the preview
# PATCH agent pool API instead of the default PUT API.
if use_patch_api:
return _aks_agentpool_scale_patch(
cmd,
client,
resource_group_name,
cluster_name,
nodepool_name,
instance,
no_wait=no_wait,
)
return sdk_no_wait(
no_wait,
client.begin_create_or_update,
Expand Down
Loading
Loading