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
6 changes: 6 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ aks create:
azure_keyvault_kms_key_vault_resource_id:
rule_exclusions:
- option_length_too_long
node_provisioning_default_pools:
rule_exclusions:
- option_length_too_long
aks enable-addons:
parameters:
workspace_resource_id:
Expand Down Expand Up @@ -374,6 +377,9 @@ aks update:
azure_keyvault_kms_key_vault_resource_id:
rule_exclusions:
- option_length_too_long
node_provisioning_default_pools:
rule_exclusions:
- option_length_too_long
aks update-credentials:
parameters:
aad_server_app_secret:
Expand Down
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@
CONST_ARTIFACT_SOURCE_DIRECT = "Direct"
CONST_ARTIFACT_SOURCE_CACHE = "Cache"

# node provisioning mode
CONST_NODE_PROVISIONING_MODE_MANUAL = "Manual"
CONST_NODE_PROVISIONING_MODE_AUTO = "Auto"

# node provisioning default pools
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE = "None"
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO = "Auto"


# consts for decorator pattern
class DecoratorMode(Enum):
Expand Down
30 changes: 30 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 @@ -599,6 +599,17 @@
- name: --enable-static-egress-gateway
type: bool
short-summary: Enable Static Egress Gateway addon to the cluster.
- name: --node-provisioning-mode
type: string
short-summary: Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". For more information on "Auto" mode see aka.ms/aks/nap.
- name: --node-provisioning-default-pools
type: string
short-summary: The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
long-summary: |-
The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
Auto: A standard set of Karpenter NodePools are provisioned.
None: No Karpenter NodePools are provisioned.
WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted by that action.
examples:
- name: Create a Kubernetes cluster with an existing SSH public key.
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
Expand Down Expand Up @@ -678,6 +689,10 @@
text: az aks create -g MyResourceGroup -n MyManagedCluster --os-sku Ubuntu --max-pods MaxPodsPerNode --network-plugin azure --vnet-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/NodeSubnet --pod-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/PodSubnet --pod-ip-allocation-mode StaticBlock
- name: Create a kubernetes cluster with VirtualMachines vm set type.
text: az aks create -g MyResourceGroup -n MyManagedCluster --vm-set-type VirtualMachines --vm-sizes "VMSize1,VMSize2" --node-count 3
- name: Create a kubernetes cluster with auto node provisioning.
text: az aks create -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto
- name: Create a kubernetes cluster with auto node provisioning and no default pools.
text: az aks create -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto --node-provisioning-default-pools None
"""

helps['aks update'] = """
Expand Down Expand Up @@ -1069,6 +1084,17 @@
- name: --migrate-vmas-to-vms
type: bool
short-summary: Migrate cluster with VMAS node pool to VMS node pool.
- name: --node-provisioning-mode
type: string
short-summary: Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". For more information on "Auto" mode see aka.ms/aks/nap.
- name: --node-provisioning-default-pools
type: string
short-summary: The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
long-summary: |-
The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
Auto: A standard set of Karpenter NodePools are provisioned.
None: No Karpenter NodePools are provisioned.
WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted by that action.
examples:
- name: Reconcile the cluster back to its current state.
text: az aks update -g MyResourceGroup -n MyManagedCluster
Expand Down Expand Up @@ -1128,6 +1154,10 @@
text: az aks update -g MyResourceGroup -n MyManagedCLuster --enable-vpa
- name: Disable VPA(Vertical Pod Autoscaler) for an existing kubernetes cluster.
text: az aks update -g MyResourceGroup -n MyManagedCLuster --disable-vpa
- name: Update a kubernetes cluster to use auto node provisioning.
text: az aks update -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto
- name: Update a kubernetes cluster to use auto node provisioning mode with no default pools.
text: az aks update -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto --node-provisioning-default-pools None
"""

helps['aks delete'] = """
Expand Down
62 changes: 61 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
CONST_APP_ROUTING_ANNOTATION_CONTROLLED_NGINX,
CONST_APP_ROUTING_EXTERNAL_NGINX,
CONST_APP_ROUTING_INTERNAL_NGINX,
CONST_APP_ROUTING_NONE_NGINX)
CONST_APP_ROUTING_NONE_NGINX,
CONST_NODE_PROVISIONING_MODE_MANUAL,
CONST_NODE_PROVISIONING_MODE_AUTO,
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE,
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO)
from azure.cli.command_modules.acs.azurecontainerstorage._consts import (
CONST_ACSTOR_ALL,
CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY,
Expand Down Expand Up @@ -192,6 +196,16 @@
CONST_NODE_OS_CHANNEL_SECURITY_PATCH,
]

node_provisioning_modes = [
CONST_NODE_PROVISIONING_MODE_MANUAL,
CONST_NODE_PROVISIONING_MODE_AUTO,
]

node_provisioning_default_pools = [
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE,
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO,
]

dev_space_endpoint_types = ['Public', 'Private', 'None']

keyvault_network_access_types = [CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PUBLIC, CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PRIVATE]
Expand Down Expand Up @@ -534,6 +548,28 @@ def load_arguments(self, _):
c.argument('disable_acns_security', action='store_true')
c.argument("if_match")
c.argument("if_none_match")
# node provisioning
c.argument(
"node_provisioning_mode",
arg_type=get_enum_type(node_provisioning_modes),
help=(
'Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". '
'For more information on "Auto" mode see aka.ms/aks/nap.'
)
)
c.argument(
"node_provisioning_default_pools",
arg_type=get_enum_type(node_provisioning_default_pools),
help=(
'The set of default Karpenter NodePools configured for node provisioning. '
'Valid values are "Auto" and "None". Auto: A standard set of Karpenter NodePools are provisioned. '
'None: No Karpenter NodePools are provisioned. '
'WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter '
'NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. '
'It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted '
'by that action.'
)
)

with self.argument_context('aks update') as c:
# managed cluster paramerters
Expand Down Expand Up @@ -711,6 +747,30 @@ def load_arguments(self, _):
c.argument('disable_cost_analysis', action='store_true')
c.argument("if_match")
c.argument("if_none_match")
# node provisioning
c.argument(
"node_provisioning_mode",
is_preview=True,
arg_type=get_enum_type(node_provisioning_modes),
help=(
'Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". '
'For more information on "Auto" mode see aka.ms/aks/nap.'
)
)
c.argument(
"node_provisioning_default_pools",
is_preview=True,
arg_type=get_enum_type(node_provisioning_default_pools),
help=(
'The set of default Karpenter NodePools configured for node provisioning. '
'Valid values are "Auto" and "None". Auto: A standard set of Karpenter NodePools are provisioned. '
'None: No Karpenter NodePools are provisioned. '
'WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter '
'NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. '
'It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted '
'by that action.'
)
)
with self.argument_context('aks disable-addons', resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='managed_clusters') as c:
c.argument('addons', options_list=['--addons', '-a'])

Expand Down
8 changes: 7 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ def aks_create(
# apiserver vnet integration
enable_apiserver_vnet_integration=False,
apiserver_subnet_id=None,
# node provisioning
node_provisioning_mode=None,
node_provisioning_default_pools=None,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down Expand Up @@ -849,7 +852,10 @@ def aks_update(
enable_apiserver_vnet_integration=False,
apiserver_subnet_id=None,
enable_private_cluster=False,
disable_private_cluster=False
disable_private_cluster=False,
# node provisioning
node_provisioning_mode=None,
node_provisioning_default_pools=None,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5534,6 +5534,20 @@ def get_migrate_vmas_to_vms(self) -> bool:
"""
return self.raw_param.get("migrate_vmas_to_vms")

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

:return: string or None
"""
return self.raw_param.get("node_provisioning_mode")

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

:return: string or None
"""
return self.raw_param.get("node_provisioning_default_pools")


class AKSManagedClusterCreateDecorator(BaseAKSManagedClusterDecorator):
def __init__(
Expand Down Expand Up @@ -5714,6 +5728,44 @@ def set_up_image_cleaner(self, mc: ManagedCluster) -> ManagedCluster:

return mc

def set_up_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

mode = self.context.get_node_provisioning_mode()
if mode is not None:
if mc.node_provisioning_profile is None:
mc.node_provisioning_profile = (
self.models.ManagedClusterNodeProvisioningProfile() # pylint: disable=no-member
)

# set mode
mc.node_provisioning_profile.mode = mode

return mc

def set_up_node_provisioning_default_pools(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

default_pools = self.context.get_node_provisioning_default_pools()
if default_pools is not None:
if mc.node_provisioning_profile is None:
mc.node_provisioning_profile = (
self.models.ManagedClusterNodeProvisioningProfile() # pylint: disable=no-member
)

# set default_node_pools
mc.node_provisioning_profile.default_node_pools = default_pools

return mc

def set_up_node_provisioning_profile(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

mc = self.set_up_node_provisioning_mode(mc)
mc = self.set_up_node_provisioning_default_pools(mc)

return mc

def init_mc(self) -> ManagedCluster:
"""Initialize a ManagedCluster object with required parameter location and attach it to internal context.

Expand Down Expand Up @@ -6971,6 +7023,8 @@ def construct_mc_profile_default(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_bootstrap_profile(mc)
# set up static egress gateway profile
mc = self.set_up_static_egress_gateway(mc)
# set up node provisioning profile
mc = self.set_up_node_provisioning_profile(mc)

# DO NOT MOVE: keep this at the bottom, restore defaults
if not bypass_restore_defaults:
Expand Down Expand Up @@ -8874,6 +8928,48 @@ def update_vmas_to_vms(self, mc: ManagedCluster) -> ManagedCluster:

return mc

def update_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

mode = self.context.get_node_provisioning_mode()
if mode is not None:
if mc.node_provisioning_profile is None:
mc.node_provisioning_profile = (
self.models.ManagedClusterNodeProvisioningProfile() # pylint: disable=no-member
)

# set mode
mc.node_provisioning_profile.mode = mode

return mc

def update_node_provisioning_default_pools(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

default_pools = self.context.get_node_provisioning_default_pools()
if default_pools is not None:
if mc.node_provisioning_profile is None:
mc.node_provisioning_profile = (
self.models.ManagedClusterNodeProvisioningProfile() # pylint: disable=no-member
)

# set default_node_pools
mc.node_provisioning_profile.default_node_pools = default_pools

return mc

def update_node_provisioning_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Updates the nodeProvisioningProfile field of the managed cluster

:return: the ManagedCluster object
"""
self._ensure_mc(mc)

mc = self.update_node_provisioning_mode(mc)
mc = self.update_node_provisioning_default_pools(mc)

return mc

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

Expand Down Expand Up @@ -8965,6 +9061,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
mc = self.update_kubernetes_version_and_orchestrator_version(mc)
# update VMAS to VMS
mc = self.update_vmas_to_vms(mc)
# update node provisioning profile
mc = self.update_node_provisioning_profile(mc)
return mc

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