Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9d2c82a
switch to new datasource for get-versions command
Apr 26, 2023
ea91261
Fix unexpected prompt for az aks command
norshtein Apr 27, 2023
08f469e
fix
FumingZhang Apr 28, 2023
c9389cf
fix
FumingZhang Apr 28, 2023
d1d88c7
Merge branch 'tosi/fix-msi' into haitao/aks-get-versions-2023
Apr 28, 2023
491052b
premium
Apr 29, 2023
553ced1
fix unittest
Apr 29, 2023
b3bf3df
not a perfect recording
May 1, 2023
fd0591d
Merge branch 'haitao/aks-get-versions-2023' into haitao/aks-premium
May 1, 2023
2dc56aa
add accidentially dropped files
May 3, 2023
ec68529
Merge branch 'dev' into haitao/aks-get-versions-2023
May 3, 2023
5c57afa
Merge branch 'fuming/fix-network-bump-0428' into haitao/aks-get-versi…
May 3, 2023
0d1e9d2
use get_enum_type
May 3, 2023
27d9b7e
Merge branch 'haitao/aks-get-versions-2023' into haitao/aks-premium
May 3, 2023
1a31dd0
I think it works
May 3, 2023
d001554
fix default value
May 4, 2023
eecbef1
Merge branch 'dev' into haitao/aks-premium
May 4, 2023
8267212
apply on the right branch
May 4, 2023
e31e068
fix casing again
May 4, 2023
9dac071
tweaks
May 9, 2023
a27ae6d
Merge branch 'dev' into haitao/aks-premium
Jun 29, 2023
c742ac4
updating recording
Jun 30, 2023
26578fb
Merge branch 'dev' into haitao/aks-premium
Jun 30, 2023
dd68030
short parameter name, and add help for update
Jun 30, 2023
70119b2
fix lint errors
Jun 30, 2023
1e2c911
fix syntax error
Jun 30, 2023
fe9d33d
revert unexpected delete
Jun 30, 2023
12fabbe
fix flake8 E125
haitch Jun 30, 2023
a67ae98
fix lint error
haitch Jun 30, 2023
30da8f1
fix lint error
haitch Jun 30, 2023
0fe9885
remove extra backslash
haitch Jun 30, 2023
2131e39
condition on hasattr
haitch Jul 6, 2023
b15f3b9
address comments
haitch Jul 6, 2023
83b96f8
fix lint
haitch Jul 6, 2023
d37562e
update recording for failed test
haitch Jul 6, 2023
48d93c8
Merge branch 'dev' into haitao/aks-premium
haitch Jul 7, 2023
5e74167
fix test
haitch Jul 7, 2023
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
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
# ManagedClusterSKU Tier
CONST_MANAGED_CLUSTER_SKU_TIER_FREE = "free"
CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD = "standard"
CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM = "premium"

# outbound type
CONST_OUTBOUND_TYPE_LOAD_BALANCER = "loadBalancer"
Expand Down
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 @@ -427,6 +427,9 @@
- name: --node-resource-group
type: string
short-summary: The node resource group is the resource group where all customer's resources will be created in, such as virtual machines.
- name: --k8s-support-plan
type: string
short-summary: Choose from "KubernetesOfficial" or "AKSLongTermSupport", with "AKSLongTermSupport" you get 1 extra year of CVE patchs.
- name: --enable-defender
type: bool
short-summary: Enable Microsoft Defender security profile.
Expand Down Expand Up @@ -726,6 +729,9 @@
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
- name: --k8s-support-plan
type: string
short-summary: Choose from "KubernetesOfficial" or "AKSLongTermSupport", with "AKSLongTermSupport" you get 1 extra year of CVE patchs.
- name: --enable-windows-gmsa
type: bool
short-summary: Enable Windows gmsa on cluster.
Expand Down
23 changes: 13 additions & 10 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
CONST_GPU_INSTANCE_PROFILE_MIG3_G, CONST_GPU_INSTANCE_PROFILE_MIG4_G,
CONST_GPU_INSTANCE_PROFILE_MIG7_G, CONST_LOAD_BALANCER_SKU_BASIC,
CONST_LOAD_BALANCER_SKU_STANDARD, CONST_MANAGED_CLUSTER_SKU_TIER_FREE,
CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD, CONST_NETWORK_DATAPLANE_AZURE,
CONST_NETWORK_DATAPLANE_CILIUM, CONST_NETWORK_PLUGIN_AZURE,
CONST_NETWORK_PLUGIN_KUBENET, CONST_NETWORK_PLUGIN_MODE_OVERLAY,
CONST_NETWORK_PLUGIN_NONE, CONST_NODE_IMAGE_UPGRADE_CHANNEL,
CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD, CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM,
CONST_NETWORK_DATAPLANE_AZURE, CONST_NETWORK_DATAPLANE_CILIUM,
CONST_NETWORK_PLUGIN_AZURE, CONST_NETWORK_PLUGIN_KUBENET,
CONST_NETWORK_PLUGIN_MODE_OVERLAY, CONST_NETWORK_PLUGIN_NONE,
CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL,
CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER,
CONST_NONE_UPGRADE_CHANNEL, CONST_OS_DISK_TYPE_EPHEMERAL,
CONST_OS_DISK_TYPE_MANAGED, CONST_OS_SKU_AZURELINUX,
CONST_OS_SKU_CBLMARINER, CONST_OS_SKU_MARINER, CONST_OS_SKU_UBUNTU,
CONST_OS_DISK_TYPE_EPHEMERAL, CONST_OS_DISK_TYPE_MANAGED,
CONST_OS_SKU_AZURELINUX, CONST_OS_SKU_CBLMARINER, CONST_OS_SKU_MARINER, CONST_OS_SKU_UBUNTU,
CONST_OS_SKU_WINDOWS2019, CONST_OS_SKU_WINDOWS2022,
CONST_OUTBOUND_TYPE_LOAD_BALANCER, CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
Expand Down Expand Up @@ -56,7 +56,7 @@
validate_pod_subnet_id, validate_ppg, validate_priority,
validate_registry_name, validate_sku_tier, validate_snapshot_id,
validate_snapshot_name, validate_spot_max_price, validate_ssh_key,
validate_taints, validate_vm_set_type, validate_vnet_subnet_id)
validate_taints, validate_vm_set_type, validate_vnet_subnet_id, validate_k8s_support_plan)
from azure.cli.core.commands.parameters import (
edge_zone_type, file_type, get_enum_type,
get_resource_name_completion_list, get_three_state_flag, name_type,
Expand All @@ -67,7 +67,6 @@
# pylint: disable=line-too-long,too-many-statements

# candidates for enumeration, no longer maintained
orchestrator_types = ["Custom", "DCOS", "Kubernetes", "Swarm", "DockerCE"]
regions_in_preview = [
"canadacentral",
"canadaeast",
Expand Down Expand Up @@ -112,7 +111,7 @@

# consts for ManagedCluster
load_balancer_skus = [CONST_LOAD_BALANCER_SKU_BASIC, CONST_LOAD_BALANCER_SKU_STANDARD]
sku_tiers = [CONST_MANAGED_CLUSTER_SKU_TIER_FREE, CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD]
sku_tiers = [CONST_MANAGED_CLUSTER_SKU_TIER_FREE, CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD, CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM]
network_plugins = [CONST_NETWORK_PLUGIN_KUBENET, CONST_NETWORK_PLUGIN_AZURE, CONST_NETWORK_PLUGIN_NONE]
network_plugin_modes = [CONST_NETWORK_PLUGIN_MODE_OVERLAY]
network_dataplanes = [CONST_NETWORK_DATAPLANE_AZURE, CONST_NETWORK_DATAPLANE_CILIUM]
Expand Down Expand Up @@ -141,6 +140,7 @@
def load_arguments(self, _):

acr_arg_type = CLIArgumentType(metavar='ACR_NAME_OR_RESOURCE_ID')
k8s_support_plans = self.get_models("KubernetesSupportPlan", resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='managed_clusters')

# AKS command argument configuration
with self.argument_context('aks', resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='managed_clusters') as c:
Expand Down Expand Up @@ -221,6 +221,7 @@ def load_arguments(self, _):
c.argument('attach_acr', acr_arg_type)
c.argument('skip_subnet_role_assignment', action='store_true')
c.argument('node_resource_group')
c.argument('k8s_support_plan', arg_type=get_enum_type(k8s_support_plans), validator=validate_k8s_support_plan)
c.argument('enable_defender', action='store_true')
c.argument('defender_config', validator=validate_defender_config_parameter)
c.argument('disable_disk_driver', action='store_true')
Expand Down Expand Up @@ -251,6 +252,7 @@ def load_arguments(self, _):
c.argument('enable_secret_rotation', action='store_true')
c.argument('rotation_poll_interval')
c.argument('enable_sgxquotehelper', action='store_true')

# nodepool paramerters
c.argument('nodepool_name', default='nodepool1',
help='Node pool name, up to 12 alphanumeric characters', validator=validate_nodepool_name)
Expand Down Expand Up @@ -321,6 +323,7 @@ def load_arguments(self, _):
c.argument('aad_tenant_id')
c.argument('aad_admin_group_object_ids')
c.argument('enable_oidc_issuer', action='store_true')
c.argument('k8s_support_plan', arg_type=get_enum_type(k8s_support_plans), validator=validate_k8s_support_plan)
c.argument('windows_admin_password')
c.argument('enable_ahub', action='store_true')
c.argument('disable_ahub', action='store_true')
Expand Down
17 changes: 15 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acs/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from ipaddress import ip_network
from math import isclose, isnan

from azure.mgmt.containerservice.models import KubernetesSupportPlan
from azure.cli.command_modules.acs._consts import (
CONST_MANAGED_CLUSTER_SKU_TIER_FREE,
CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD,
CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM,
CONST_OS_SKU_AZURELINUX,
CONST_OS_SKU_CBLMARINER,
CONST_OS_SKU_MARINER,
Expand Down Expand Up @@ -201,8 +203,19 @@ def validate_sku_tier(namespace):
if namespace.tier is not None:
if namespace.tier == '':
return
if namespace.tier.lower() not in (CONST_MANAGED_CLUSTER_SKU_TIER_FREE, CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD):
raise InvalidArgumentValueError("--tier can only be free or standard")
if namespace.tier.lower() not in (
CONST_MANAGED_CLUSTER_SKU_TIER_FREE, CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD,
CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM):
raise InvalidArgumentValueError("--tier can only be free, standard and premium")


def validate_k8s_support_plan(namespace):
if namespace.k8s_support_plan is not None:
if namespace.k8s_support_plan == '':
return
if namespace.k8s_support_plan.lower() not in (
KubernetesSupportPlan.KUBERNETES_OFFICIAL.lower(), KubernetesSupportPlan.AKS_LONG_TERM_SUPPORT.lower()):
raise InvalidArgumentValueError("--k8s-support-plan can only be KubernetesOfficial or AKSLongTermSupport")


def validate_load_balancer_outbound_ips(namespace):
Expand Down
3 changes: 3 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 @@ -59,6 +59,7 @@
CONST_VIRTUAL_NODE_SUBNET_NAME,
DecoratorEarlyExitException,
)

from azure.cli.command_modules.acs._helpers import get_snapshot_by_snapshot_id
from azure.cli.command_modules.acs._resourcegroup import get_rg_location
from azure.cli.command_modules.acs._validators import extract_comma_separated_string
Expand Down Expand Up @@ -434,6 +435,7 @@ def aks_create(
attach_acr=None,
skip_subnet_role_assignment=False,
node_resource_group=None,
k8s_support_plan=None,
enable_defender=False,
defender_config=None,
disable_disk_driver=False,
Expand Down Expand Up @@ -574,6 +576,7 @@ def aks_update(
aad_tenant_id=None,
aad_admin_group_object_ids=None,
enable_oidc_issuer=False,
k8s_support_plan=None,
windows_admin_password=None,
enable_ahub=False,
disable_ahub=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
from types import SimpleNamespace
from typing import Dict, List, Optional, Tuple, TypeVar, Union

from azure.mgmt.containerservice.models import KubernetesSupportPlan

from azure.cli.command_modules.acs._consts import (
CONST_LOAD_BALANCER_SKU_BASIC,
CONST_LOAD_BALANCER_SKU_STANDARD,
CONST_MANAGED_CLUSTER_SKU_TIER_FREE,
CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD,
CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM,
CONST_OUTBOUND_TYPE_LOAD_BALANCER,
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
Expand Down Expand Up @@ -4045,6 +4048,10 @@ def get_cluster_autoscaler_profile(self) -> Union[Dict[str, str], None]:
"""
return self._get_cluster_autoscaler_profile()

def _get_k8s_support_plan(self) -> KubernetesSupportPlan:
support_plan = self.raw_param.get("k8s_support_plan")
return support_plan

def _get_uptime_sla(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of uptime_sla.

Expand Down Expand Up @@ -4690,6 +4697,24 @@ def get_node_resource_group(self) -> Union[str, None]:
# this parameter does not need validation
return node_resource_group

def get_k8s_support_plan(self) -> Union[str, None]:
"""Obtain the value of kubernetes_support_plan.

:return: string or None
"""
# default to None
support_plan = None
# try to read the property value corresponding to the parameter from the `mc` object
if self.mc and hasattr(self.mc, "support_plan") and self.mc.support_plan is not None:
support_plan = self.mc.support_plan

# if specified by customer, use the specified value
support_plan = self.raw_param.get("k8s_support_plan")

# this parameter does not need dynamic completion
# this parameter does not need validation
return support_plan

def get_yes(self) -> bool:
"""Obtain the value of yes.

Expand Down Expand Up @@ -5811,6 +5836,12 @@ def set_up_sku(self, mc: ManagedCluster) -> ManagedCluster:
name="Base",
tier="Standard"
)

if self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM:
mc.sku = self.models.ManagedClusterSKU(
name="Base",
tier="Premium"
)
return mc

def set_up_extended_location(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down Expand Up @@ -5838,6 +5869,20 @@ def set_up_node_resource_group(self, mc: ManagedCluster) -> ManagedCluster:
mc.node_resource_group = self.context.get_node_resource_group()
return mc

def set_up_k8s_support_plan(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up supportPlan for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

support_plan = self.context.get_k8s_support_plan()
if support_plan == KubernetesSupportPlan.AKS_LONG_TERM_SUPPORT:
if mc is None or mc.sku is None or mc.sku.tier.lower() != CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM.lower():
raise AzCLIError("Long term support is only available for premium tier clusters.")

mc.support_plan = support_plan
return mc

def set_up_azure_monitor_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up azure monitor profile for the ManagedCluster object.
:return: the ManagedCluster object
Expand Down Expand Up @@ -5926,6 +5971,8 @@ def construct_mc_profile_default(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_http_proxy_config(mc)
# set up workload autoscaler profile
mc = self.set_up_workload_auto_scaler_profile(mc)
# setup k8s support plan
mc = self.set_up_k8s_support_plan(mc)
# set up azure monitor metrics profile
mc = self.set_up_azure_monitor_profile(mc)

Expand Down Expand Up @@ -6341,6 +6388,13 @@ def update_sku(self, mc: ManagedCluster) -> ManagedCluster:
"""
self._ensure_mc(mc)

# Premium without LTS is ok (not vice versa)
if self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM:
mc.sku = self.models.ManagedClusterSKU(
name="Base",
tier="Premium"
)

if self.context.get_uptime_sla() or self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD:
mc.sku = self.models.ManagedClusterSKU(
name="Base",
Expand Down Expand Up @@ -6469,6 +6523,7 @@ def update_windows_profile(self, mc: ManagedCluster) -> ManagedCluster:
enable_windows_gmsa = self.context.get_enable_windows_gmsa()

if any([enable_ahub, disable_ahub, windows_admin_password, enable_windows_gmsa]) and not mc.windows_profile:
# seems we know the error
raise UnknownError(
"Encounter an unexpected error while getting windows profile from the cluster in the process of update."
)
Expand Down Expand Up @@ -6821,6 +6876,20 @@ def update_workload_identity_profile(self, mc: ManagedCluster) -> ManagedCluster

return mc

def update_k8s_support_plan(self, mc: ManagedCluster) -> ManagedCluster:
"""Update supportPlan for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

support_plan = self.context.get_k8s_support_plan()
if support_plan == KubernetesSupportPlan.AKS_LONG_TERM_SUPPORT:
if mc is None or mc.sku is None or mc.sku.tier.lower() != CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM.lower():
raise AzCLIError("Long term support is only available for premium tier clusters.")

mc.support_plan = support_plan
return mc

def update_azure_keyvault_kms(self, mc: ManagedCluster) -> ManagedCluster:
"""Update security profile azureKeyvaultKms for the ManagedCluster object.

Expand Down Expand Up @@ -7058,6 +7127,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
mc = self.update_http_proxy_config(mc)
# update workload autoscaler profile
mc = self.update_workload_auto_scaler_profile(mc)
# update kubernetes support plan
mc = self.update_k8s_support_plan(mc)
# update azure monitor metrics profile
mc = self.update_azure_monitor_profile(mc)
return mc
Expand Down
Loading