Skip to content

Commit 42894d6

Browse files
authored
aks update node disruption profile flag (#9893)
1 parent 7069057 commit 42894d6

7 files changed

Lines changed: 2753 additions & 0 deletions

File tree

src/aks-preview/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Pending
1313
+++++++
1414
* `az aks update`: Add `--control-plane-scaling-size` parameter to update the control plane scaling size on an existing cluster with available sizes 'H2', 'H4', and 'H8'.
1515
* `az aks bastion`: Fix `--subscription` not being passed to internal `az network bastion tunnel` and bastion discovery commands.
16+
* `az aks update`: Add `--node-disruption-policy` (preview) to update the node disruption policy for a cluster. Requires AFEC registration `Microsoft.ContainerService/NodeDisruptionProfile`. This is a cluster-level property that applies to all node pools in the cluster.
1617

1718
21.0.0b3
1819
+++++++

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,8 @@
414414
CONST_K8S_EXTENSION_NAME = "k8s-extension"
415415
CONST_K8S_EXTENSION_ACTION_MOD_NAME = "azext_k8s_extension.action"
416416
CONST_K8S_EXTENSION_FORMAT_MOD_NAME = "azext_k8s_extension._format"
417+
418+
# Node Disruption Policy Consts
419+
CONST_NODE_DISRUPTION_POLICY_ALLOW = "Allow"
420+
CONST_NODE_DISRUPTION_POLICY_BLOCK = "Block"
421+
CONST_NODE_DISRUPTION_POLICY_ALLOW_DURING_MAINTENANCE_WINDOW = "AllowDuringMaintenanceWindow"

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
CONST_NETWORK_PLUGIN_NONE,
7979
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL,
8080
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK,
81+
CONST_NODE_DISRUPTION_POLICY_ALLOW,
82+
CONST_NODE_DISRUPTION_POLICY_BLOCK,
83+
CONST_NODE_DISRUPTION_POLICY_ALLOW_DURING_MAINTENANCE_WINDOW,
8184
CONST_NODE_IMAGE_UPGRADE_CHANNEL,
8285
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
8386
CONST_NODE_OS_CHANNEL_NONE,
@@ -562,6 +565,12 @@
562565
CONST_UPGRADE_STRATEGY_BLUE_GREEN,
563566
]
564567

568+
node_disruption_policies = [
569+
CONST_NODE_DISRUPTION_POLICY_ALLOW,
570+
CONST_NODE_DISRUPTION_POLICY_BLOCK,
571+
CONST_NODE_DISRUPTION_POLICY_ALLOW_DURING_MAINTENANCE_WINDOW,
572+
]
573+
565574

566575
def load_arguments(self, _):
567576
acr_arg_type = CLIArgumentType(metavar="ACR_NAME_OR_RESOURCE_ID")
@@ -1939,6 +1948,12 @@ def load_arguments(self, _):
19391948
"Available values are 'H2', 'H4', and 'H8'. "
19401949
"The control plane scaling profile must already be enabled on the cluster.",
19411950
)
1951+
c.argument(
1952+
"node_disruption_policy",
1953+
arg_type=get_enum_type(node_disruption_policies),
1954+
is_preview=True,
1955+
help="Set the node disruption policy for the cluster.",
1956+
)
19421957

19431958
with self.argument_context("aks delete") as c:
19441959
c.argument("if_match")

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,8 @@ def aks_update(
14391439
# health monitor
14401440
enable_continuous_control_plane_and_addon_monitor=False,
14411441
disable_continuous_control_plane_and_addon_monitor=False,
1442+
# node disruption policy
1443+
node_disruption_policy=None,
14421444
# control plane scaling
14431445
control_plane_scaling_size=None,
14441446
):

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,6 +3818,11 @@ def get_node_provisioning_mode(self) -> Union[str, None]:
38183818
"""
38193819
return self.raw_param.get("node_provisioning_mode")
38203820

3821+
def get_node_disruption_policy(self) -> Union[str, None]:
3822+
"""Obtain the value of node_disruption_policy.
3823+
"""
3824+
return self.raw_param.get("node_disruption_policy")
3825+
38213826
def get_node_provisioning_default_pools(self) -> Union[str, None]:
38223827
"""Obtain the value of node_provisioning_default_pools.
38233828
"""
@@ -7722,6 +7727,25 @@ def update_node_provisioning_profile(self, mc: ManagedCluster) -> ManagedCluster
77227727

77237728
return mc
77247729

7730+
def update_node_disruption_policy(self, mc: ManagedCluster) -> ManagedCluster:
7731+
"""Updates the nodeDisruptionPolicy field of the managed cluster
7732+
7733+
:return: the ManagedCluster object
7734+
"""
7735+
self._ensure_mc(mc)
7736+
7737+
policy = self.context.get_node_disruption_policy()
7738+
if policy is not None:
7739+
if mc.node_disruption_profile is None:
7740+
mc.node_disruption_profile = (
7741+
self.models.NodeDisruptionProfile() # pylint: disable=no-member
7742+
)
7743+
7744+
# set policy
7745+
mc.node_disruption_profile.node_disruption_policy = policy
7746+
7747+
return mc
7748+
77257749
def update_ai_toolchain_operator(self, mc: ManagedCluster) -> ManagedCluster:
77267750
"""Updates the aiToolchainOperatorProfile field of the managed cluster
77277751
@@ -8281,6 +8305,8 @@ def update_mc_profile_preview(self) -> ManagedCluster:
82818305
mc = self.update_http_proxy_enabled(mc)
82828306
# update user-defined scheduler configuration for kube-scheduler upstream
82838307
mc = self.update_upstream_kubescheduler_user_configuration(mc)
8308+
# update node disruption policy
8309+
mc = self.update_node_disruption_policy(mc)
82848310
# update control plane scaling profile
82858311
mc = self.update_control_plane_scaling_profile(mc)
82868312
# update ManagedSystem pools, must at end

0 commit comments

Comments
 (0)