Skip to content

Commit

Permalink
[AKS] az aks upgrade: Support tier switch with AKS upgrade (#29448)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxuan0923 authored Jul 26, 2024
1 parent 461d7b0 commit 1c054a7
Show file tree
Hide file tree
Showing 5 changed files with 3,282 additions and 0 deletions.
6 changes: 6 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 @@ -1888,6 +1888,12 @@
type: string
short-summary: Until when the cluster upgradeSettings overrides are effective.
long-summary: It needs to be in a valid date-time format that's within the next 30 days. For example, 2023-04-01T13:00:00Z. Note that if --force-upgrade is set to true and --upgrade-override-until is not set, by default it will be set to 3 days from now.
- name: --k8s-support-plan
type: string
short-summary: Choose from "KubernetesOfficial" or "AKSLongTermSupport", with "AKSLongTermSupport" you get 1 extra year of CVE patchs.
- name: --tier
type: string
short-summary: Specify SKU tier for managed clusters. '--tier standard' enables a standard managed cluster service with a financially backed SLA. '--tier free' does not have a financially backed SLA. '--tier premium' is required for '--k8s-support-plan AKSLongTermSupport'.
examples:
- name: Upgrade a managed Kubernetes cluster to a newer version. (autogenerated)
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 @@ -672,6 +672,8 @@ def load_arguments(self, _):
c.argument('enable_force_upgrade', action='store_true')
c.argument('disable_force_upgrade', action='store_true', validator=validate_force_upgrade_disable_and_enable_parameters)
c.argument('upgrade_override_until')
c.argument("k8s_support_plan", arg_type=get_enum_type(k8s_support_plans))
c.argument("tier", arg_type=get_enum_type(sku_tiers), validator=validate_sku_tier)

with self.argument_context('aks scale', resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='managed_clusters') as c:
c.argument('nodepool_name', validator=validate_nodepool_name, help='Node pool name, up to 12 alphanumeric characters.')
Expand Down
13 changes: 13 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_COMPLETE,
CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_ROLLBACK,
CONST_AZURE_SERVICE_MESH_MODE_ISTIO,
CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM,
)

from azure.cli.command_modules.acs._helpers import get_snapshot_by_snapshot_id, check_is_private_link_cluster
Expand Down Expand Up @@ -95,6 +96,7 @@
from azure.cli.core.profiles import ResourceType
from azure.cli.core.util import in_cloud_console, sdk_no_wait
from azure.core.exceptions import ResourceNotFoundError as ResourceNotFoundErrorAzCore
from azure.mgmt.containerservice.models import KubernetesSupportPlan
from knack.log import get_logger
from knack.prompting import NoTTYException, prompt_y_n
from knack.util import CLIError
Expand Down Expand Up @@ -824,6 +826,8 @@ def aks_upgrade(cmd,
enable_force_upgrade=False,
disable_force_upgrade=False,
upgrade_override_until=None,
tier=None,
k8s_support_plan=None,
yes=False):
msg = 'Kubernetes may be unavailable during cluster upgrades.\n Are you sure you want to perform this operation?'
if not yes and not prompt_y_n(msg, default="n"):
Expand Down Expand Up @@ -859,6 +863,15 @@ def aks_upgrade(cmd,
mc = client.get(resource_group_name, name)
return _remove_nulls([mc])[0]

if tier is not None:
instance.sku.tier = tier

if k8s_support_plan is not None:
instance.support_plan = k8s_support_plan

if (instance.support_plan == KubernetesSupportPlan.AKS_LONG_TERM_SUPPORT and instance.tier is not None and instance.tier.lower() != CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM.lower()):
raise CLIError("AKS Long Term Support is only available for Premium tier clusters.")

instance = _update_upgrade_settings(
cmd,
instance,
Expand Down
Loading

0 comments on commit 1c054a7

Please sign in to comment.