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
3 changes: 3 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++
* Add machine command `az aks machine add` to add a machine to an existing machine pool.
* Add blue-green upgrade strategy support for AKS node pools:
- `az aks nodepool add/update/upgrade`: Add `--upgrade-strategy` parameter to switch between rolling and blue-green nodepool upgrades.
- `az aks nodepool add/update/upgrade`: Add `--drain-batch-size`, `--drain-timeout-bg`, `--batch-soak-duration`, `--final-soak-duration` parameters to configure blue-green upgrade settings.

18.0.0b37
+++++++
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL = "node-image"
CONST_NONE_UPGRADE_CHANNEL = "none"

# consts for upgrade strategy
CONST_UPGRADE_STRATEGY_ROLLING = "Rolling"
CONST_UPGRADE_STRATEGY_BLUE_GREEN = "BlueGreen"

# consts for node os upgrade channel
CONST_NODE_OS_CHANNEL_NODE_IMAGE = "NodeImage"
CONST_NODE_OS_CHANNEL_NONE = "None"
Expand Down
58 changes: 58 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,24 @@
- name: --localdns-config
type: string
short-summary: Set the localDNS Profile for a nodepool with a JSON config file.
- name: --upgrade-strategy
type: string
short-summary: Upgrade strategy for the node pool. Allowed values are "Rolling" or "BlueGreen". Default is "Rolling".
- name: --drain-batch-size
type: string
short-summary: Number or percentage of nodes to drain per batch during blue-green upgrades. Accepts an integer (e.g. '5') or percentage (e.g. '50%'). Default is 10%.
long-summary: |-
Specifies how many nodes to drain in each batch during a blue-green upgrade. Must be a non-zero value, either as an integer (e.g. '5') or a percentage (e.g. '50%') of the total blue nodes at the start of the upgrade. Fractional nodes are rounded up. For more details and best practices, see https://learn.microsoft.com/en-us/azure/aks/upgrade-cluster
- name: --drain-timeout-bg
type: int
short-summary: Timeout (in minutes) to evict pods and gracefully terminate per node during blue-green upgrades. Default is 30 minutes.
long-summary: Maximum time (in minutes) to wait for pod eviction and graceful termination per node during blue-green upgrades. Honors pod disruption budgets. If exceeded, the upgrade fails. Default is 30 minutes.
- name: --batch-soak-duration
type: int
short-summary: Wait time (in minutes) after draining a batch of nodes before proceeding to the next batch. Default is 15 minutes. Only for blue-green upgrades.
- name: --final-soak-duration
type: int
short-summary: Wait time (in minutes) after all old nodes are drained before removing them. Default is 60 minutes. Only for blue-green upgrades.
examples:
- name: Create a nodepool in an existing AKS cluster with ephemeral os enabled.
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --node-osdisk-type Ephemeral --node-osdisk-size 48
Expand All @@ -2094,6 +2112,8 @@
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --vm-set-type VirtualMachines --vm-sizes "Standard_D4s_v3,Standard_D8s_v3" --node-count 3
- name: Create a nodepool with ManagedSystem mode
text: az aks nodepool add -g MyResourceGroup -n managedsystem1 --cluster-name MyManagedCluster --mode ManagedSystem
- name: Create a node pool with blue-green upgrade strategy and default parameters
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --upgrade-strategy BlueGreen
"""

helps['aks nodepool scale'] = """
Expand Down Expand Up @@ -2148,6 +2168,24 @@
- name: --undrainable-node-behavior
type: string
short-summary: Define the behavior for undrainable nodes during upgrade. The value should be "Cordon" or "Schedule". The default value is "Schedule".
- name: --upgrade-strategy
type: string
short-summary: Upgrade strategy for the node pool. Allowed values are "Rolling" or "BlueGreen". Default is "Rolling".
- name: --drain-batch-size
type: string
short-summary: Number or percentage of nodes to drain per batch during blue-green upgrades. Accepts an integer (e.g. '5') or percentage (e.g. '50%'). Default is 10%.
long-summary: |-
Specifies how many nodes to drain in each batch during a blue-green upgrade. Must be a non-zero value, either as an integer (e.g. '5') or a percentage (e.g. '50%') of the total blue nodes at the start of the upgrade. Fractional nodes are rounded up. For more details and best practices, see: https://learn.microsoft.com/en-us/azure/aks/upgrade-cluster
- name: --drain-timeout-bg
type: int
short-summary: Timeout (in minutes) to evict pods and gracefully terminate per node during blue-green upgrades. Default is 30 minutes.
long-summary: Maximum time (in minutes) to wait for pod eviction and graceful termination per node during blue-green upgrades. Honors pod disruption budgets. If exceeded, the upgrade fails. Default is 30 minutes.
- name: --batch-soak-duration
type: int
short-summary: Wait time (in minutes) after draining a batch of nodes before proceeding to the next batch. Default is 15 minutes. Only for blue-green upgrades.
- name: --final-soak-duration
type: int
short-summary: Wait time (in minutes) after all old nodes are drained before removing them. Default is 60 minutes. Only for blue-green upgrades.
"""

helps['aks nodepool update'] = """
Expand Down Expand Up @@ -2254,6 +2292,24 @@
- name: --node-vm-size -s
type: string
short-summary: VM size for Kubernetes nodes. Only configurable when updating the autoscale settings of a VirtualMachines node pool.
- name: --upgrade-strategy
type: string
short-summary: Upgrade strategy for the node pool. Allowed values are "Rolling" or "BlueGreen". Default is "Rolling".
- name: --drain-batch-size
type: string
short-summary: Number or percentage of nodes to drain per batch during blue-green upgrades. Accepts an integer (e.g. '5') or percentage (e.g. '50%'). Default is 10%.
long-summary: |-
Specifies how many nodes to drain in each batch during a blue-green upgrade. Must be a non-zero value, either as an integer (e.g. '5') or a percentage (e.g. '50%') of the total blue nodes at the start of the upgrade. Fractional nodes are rounded up. For more details and best practices, see: https://learn.microsoft.com/en-us/azure/aks/upgrade-cluster
- name: --drain-timeout-bg
type: int
short-summary: Timeout (in minutes) to evict pods and gracefully terminate per node during blue-green upgrades. Default is 30 minutes.
long-summary: Maximum time (in minutes) to wait for pod eviction and graceful termination per node during blue-green upgrades. Honors pod disruption budgets. If exceeded, the upgrade fails. Default is 30 minutes.
- name: --batch-soak-duration
type: int
short-summary: Wait time (in minutes) after draining a batch of nodes before proceeding to the next batch. Default is 15 minutes. Only for blue-green upgrades.
- name: --final-soak-duration
type: int
short-summary: Wait time (in minutes) after all old nodes are drained before removing them. Default is 60 minutes. Only for blue-green upgrades.
examples:
- name: Reconcile the nodepool back to its current state.
text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
Expand All @@ -2267,6 +2323,8 @@
text: az aks nodepool update --mode System -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
- name: Update cluster autoscaler vm size, min-count and max-count for virtual machines node pool
text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --update-cluster-autoscaler --node-vm-size "Standard_D2s_v3" --min-count 2 --max-count 4
- name: Update a node pool with blue-green upgrade settings
text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --drain-batch-size 50% --drain-timeout-bg 5 --batch-soak-duration 10 --final-soak-duration 10
"""

helps['aks nodepool get-upgrades'] = """
Expand Down
32 changes: 32 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@
CONST_ADVANCED_NETWORKPOLICIES_L7,
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD,
CONST_UPGRADE_STRATEGY_ROLLING,
CONST_UPGRADE_STRATEGY_BLUE_GREEN,
)

from azext_aks_preview._validators import (
Expand Down Expand Up @@ -223,6 +225,7 @@
validate_gateway_prefix_size,
validate_max_unavailable,
validate_max_blocked_nodes,
validate_drain_batch_size,
validate_resource_group_parameter,
validate_location_resource_group_cluster_parameters,
)
Expand Down Expand Up @@ -507,6 +510,11 @@
CONST_GPU_DRIVER_TYPE_GRID,
]

upgrade_strategies = [
CONST_UPGRADE_STRATEGY_ROLLING,
CONST_UPGRADE_STRATEGY_BLUE_GREEN,
]


def load_arguments(self, _):
acr_arg_type = CLIArgumentType(metavar="ACR_NAME_OR_RESOURCE_ID")
Expand Down Expand Up @@ -1678,12 +1686,20 @@ def load_arguments(self, _):
c.argument("node_taints", validator=validate_nodepool_taints)
c.argument("node_osdisk_type", arg_type=get_enum_type(node_os_disk_types))
c.argument("node_osdisk_size", type=int)
# upgrade strategy
c.argument("upgrade_strategy", arg_type=get_enum_type(upgrade_strategies))
# rolling upgrade params
c.argument("max_surge", validator=validate_max_surge)
c.argument("drain_timeout", type=int)
c.argument("node_soak_duration", type=int)
c.argument("undrainable_node_behavior")
c.argument("max_unavailable", validator=validate_max_unavailable)
c.argument("max_blocked_nodes", validator=validate_max_blocked_nodes)
# blue-green upgrade parameters
c.argument("drain_batch_size", validator=validate_drain_batch_size)
c.argument("drain_timeout_bg", type=int)
c.argument("batch_soak_duration", type=int)
c.argument("final_soak_duration", type=int)
c.argument("mode", arg_type=get_enum_type(node_mode_types))
c.argument("scale_down_mode", arg_type=get_enum_type(scale_down_modes))
c.argument("max_pods", type=int, options_list=["--max-pods", "-m"])
Expand Down Expand Up @@ -1816,12 +1832,20 @@ def load_arguments(self, _):
c.argument("labels", nargs="*", validator=validate_nodepool_labels)
c.argument("tags", tags_type)
c.argument("node_taints", validator=validate_nodepool_taints)
# upgrade strategy
c.argument("upgrade_strategy", arg_type=get_enum_type(upgrade_strategies))
# rolling upgrade parameters
c.argument("max_surge", validator=validate_max_surge)
c.argument("drain_timeout", type=int)
c.argument("node_soak_duration", type=int)
c.argument("undrainable_node_behavior")
c.argument("max_unavailable", validator=validate_max_unavailable)
c.argument("max_blocked_nodes", validator=validate_max_blocked_nodes)
# blue-green upgrade parameters
c.argument("drain_batch_size", validator=validate_drain_batch_size)
c.argument("drain_timeout_bg", type=int)
c.argument("batch_soak_duration", type=int)
c.argument("final_soak_duration", type=int)
c.argument("mode", arg_type=get_enum_type(node_mode_types))
c.argument("scale_down_mode", arg_type=get_enum_type(scale_down_modes))
# extensions
Expand Down Expand Up @@ -1898,12 +1922,20 @@ def load_arguments(self, _):
)

with self.argument_context("aks nodepool upgrade") as c:
# upgrade strategy
c.argument("upgrade_strategy", arg_type=get_enum_type(upgrade_strategies))
# rolling upgrade parameters
c.argument("max_surge", validator=validate_max_surge)
c.argument("drain_timeout", type=int)
c.argument("node_soak_duration", type=int)
c.argument("undrainable_node_behavior")
c.argument("max_unavailable", validator=validate_max_unavailable)
c.argument("max_blocked_nodes", validator=validate_max_blocked_nodes)
# blue-green upgrade parameters
c.argument("drain_batch_size", validator=validate_drain_batch_size)
c.argument("drain_timeout_bg", type=int)
c.argument("batch_soak_duration", type=int)
c.argument("final_soak_duration", type=int)
c.argument("snapshot_id", validator=validate_snapshot_id)
c.argument(
"yes",
Expand Down
17 changes: 17 additions & 0 deletions src/aks-preview/azext_aks_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,23 @@ def validate_max_blocked_nodes(namespace):
raise InvalidArgumentValueError('--max-blocked-nodes should be an int or percentage')


def validate_drain_batch_size(namespace):
"""validates drain batch size parameter as non-zero integers or percentages."""
if namespace.drain_batch_size is None:
return
int_or_percent = namespace.drain_batch_size
if int_or_percent.endswith('%'):
int_or_percent = int_or_percent.rstrip('%')

try:
value = int(int_or_percent)
if value <= 0:
raise InvalidArgumentValueError('--drain-batch-size must be a non-zero value')
except ValueError:
# pylint: disable=raise-missing-from
raise InvalidArgumentValueError('--drain-batch-size should be an integer or percentage (e.g., "5" or "50%")')


def validate_assign_identity(namespace):
if namespace.assign_identity is not None:
if namespace.assign_identity == '':
Expand Down
Loading
Loading