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
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@
- name: --disable-static-egress-gateway
type: bool
short-summary: Disable Static Egress Gateway addon to the cluster.
- name: --migrate-vmas-to-vms
type: bool
short-summary: Migrate cluster with VMAS node pool to VMS node pool.
examples:
- name: Reconcile the cluster back to its current state.
text: az aks update -g MyResourceGroup -n MyManagedCluster
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ def load_arguments(self, _):
c.argument('nodepool_labels', nargs='*', validator=validate_nodepool_labels,
help='space-separated labels: key[=value] [key[=value] ...]. See https://aka.ms/node-labels for syntax of labels.')
c.argument('nodepool_taints', validator=validate_nodepool_taints)
c.argument('migrate_vmas_to_vms', action='store_true')

# azure monitor profile
c.argument('enable_azure_monitor_metrics', action='store_true')
c.argument('azure_monitor_workspace_resource_id', validator=validate_azuremonitorworkspaceresourceid)
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ def aks_update(
max_count=None,
nodepool_labels=None,
nodepool_taints=None,
migrate_vmas_to_vms=False,
# azure monitor profile
enable_azure_monitor_metrics=False,
azure_monitor_workspace_resource_id=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
CONST_DNS_ZONE_CONTRIBUTOR_ROLE,
CONST_ARTIFACT_SOURCE_CACHE,
CONST_NONE_UPGRADE_CHANNEL,
CONST_AVAILABILITY_SET,
CONST_VIRTUAL_MACHINES,
)
from azure.cli.command_modules.acs._helpers import (
check_is_managed_aad_cluster,
Expand Down Expand Up @@ -2250,7 +2252,7 @@ def _get_outbound_type(
"for more details."
)
if isBasicSKULb:
if outbound_type is not None:
if not read_from_mc and outbound_type is not None: # outbound type was default to loadbalancer for BLB creation
Comment thread
reneeli123 marked this conversation as resolved.
raise InvalidArgumentValueError(
"{outbound_type} doesn't support basic load balancer sku".format(outbound_type=outbound_type)
)
Expand Down Expand Up @@ -5500,6 +5502,12 @@ def get_disable_static_egress_gateway(self) -> bool:
# because it's already checked in get_enable_static_egress_gateway
return self.raw_param.get("disable_static_egress_gateway")

def get_migrate_vmas_to_vms(self) -> bool:
"""Obtain the value of migrate_vmas_to_vms.
:return: bool
"""
return self.raw_param.get("migrate_vmas_to_vms")


class AKSManagedClusterCreateDecorator(BaseAKSManagedClusterDecorator):
def __init__(
Expand Down Expand Up @@ -8781,6 +8789,34 @@ def update_static_egress_gateway(self, mc: ManagedCluster) -> ManagedCluster:
mc.network_profile.static_egress_gateway_profile.enabled = False
return mc

def update_vmas_to_vms(self, mc: ManagedCluster) -> ManagedCluster:
"""Update the agent pool profile type from VMAS to VMS and LB sku to standard
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

if self.context.get_migrate_vmas_to_vms():
msg = (
"\nWARNING: This operation will be disruptive to your workload while underway. "
"Do you wish to continue?"
)
if not self.context.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
# Ensure we have valid vmas AP
if len(mc.agent_pool_profiles) == 1 and mc.agent_pool_profiles[0].type == CONST_AVAILABILITY_SET:
mc.agent_pool_profiles[0].type = CONST_VIRTUAL_MACHINES
else:
raise ArgumentUsageError('This is not a valid VMAS cluster with {} agent pool profiles and {} agent pool type, we cannot proceed with the migration.'.format(len(mc.agent_pool_profiles), mc.agent_pool_profiles[0].type))

if mc.network_profile.load_balancer_sku == CONST_LOAD_BALANCER_SKU_BASIC:
mc.network_profile.load_balancer_sku = CONST_LOAD_BALANCER_SKU_STANDARD

# Set agent pool profile count and vm_size to None
mc.agent_pool_profiles[0].count = None
mc.agent_pool_profiles[0].vm_size = None

return mc

def update_mc_profile_default(self) -> ManagedCluster:
"""The overall controller used to update the default ManagedCluster profile.

Expand Down Expand Up @@ -8868,6 +8904,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
mc = self.update_static_egress_gateway(mc)
# update kubernetes version and orchestrator version
mc = self.update_kubernetes_version_and_orchestrator_version(mc)
# update VMAS to VMS
mc = self.update_vmas_to_vms(mc)
return mc

def update_kubernetes_version_and_orchestrator_version(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down
Loading
Loading