Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] az aks upgrade: Support tier switch with AKS upgrade #29448

Merged
merged 7 commits into from
Jul 26, 2024
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
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
Comment on lines +866 to +870
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add validation about lts tier requires premium sku?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FumingZhang thanks for reviewing! Yes, we can add it here or rely on the validation on the server side. I just updated the code to raise CLIError for it on L872.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having an issue on L872. shouldn't it be instance.sku.tier not instance.tier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdrinovsky thanks for bringing this to my attention, I started a PR to get it fixed #29949


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