Skip to content

Commit

Permalink
[AKS] az aks create/update: Add new parameter `--node-os-upgrade-ch…
Browse files Browse the repository at this point in the history
…annel` to specify which OS on your nodes is updated (#27167)
  • Loading branch information
paulgmiller authored Aug 17, 2023
1 parent facd777 commit c963779
Show file tree
Hide file tree
Showing 9 changed files with 3,815 additions and 0 deletions.
5 changes: 5 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 @@ -86,6 +86,11 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL = "node-image"
CONST_NONE_UPGRADE_CHANNEL = "none"

# consts for node os upgrade channel
CONST_NODE_OS_CHANNEL_NODE_IMAGE = "NodeImage"
CONST_NODE_OS_CHANNEL_NONE = "None"
CONST_NODE_OS_CHANNEL_UNMANAGED = "Unmanaged"

# network plugin
CONST_NETWORK_PLUGIN_KUBENET = "kubenet"
CONST_NETWORK_PLUGIN_AZURE = "azure"
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 @@ -195,6 +195,9 @@
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade.
- name: --node-os-upgrade-channel
type: string
short-summary: Manner in which the OS on your nodes is updated. It could be NodeImage, None, SecurityPatch or Unmanaged.
- name: --enable-cluster-autoscaler
type: bool
short-summary: Enable cluster autoscaler, default value is false.
Expand Down Expand Up @@ -664,6 +667,9 @@
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade.
- name: --node-os-upgrade-channel
type: string
short-summary: Manner in which the OS on your nodes is updated. It could be NodeImage, None, SecurityPatch or Unmanaged.
- name: --attach-acr
type: string
short-summary: Grant the 'acrpull' role assignment to the ACR specified by name or resource ID.
Expand Down
10 changes: 10 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 @@ -22,6 +22,9 @@
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_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
CONST_NODE_OS_CHANNEL_UNMANAGED,
CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER,
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,
Expand Down Expand Up @@ -130,6 +133,12 @@
CONST_NONE_UPGRADE_CHANNEL,
]

node_os_upgrade_channels = [
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
CONST_NODE_OS_CHANNEL_UNMANAGED,
]

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 @@ -212,6 +221,7 @@ def load_arguments(self, _):
c.argument('network_policy', validator=validate_network_policy)
c.argument('network_dataplane', arg_type=get_enum_type(network_dataplanes))
c.argument('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels))
c.argument('node_os_upgrade_channel', arg_type=get_enum_type(node_os_upgrade_channels))
c.argument('cluster_autoscaler_profile', nargs='+', options_list=["--cluster-autoscaler-profile", "--ca-profile"],
help="Comma-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.")
c.argument('uptime_sla', action='store_true', deprecate_info=c.deprecate(target='--uptime-sla', hide=True))
Expand Down
2 changes: 2 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 @@ -506,6 +506,7 @@ def aks_create(
network_policy=None,
network_dataplane=None,
auto_upgrade_channel=None,
node_os_upgrade_channel=None,
cluster_autoscaler_profile=None,
uptime_sla=False,
tier=None,
Expand Down Expand Up @@ -665,6 +666,7 @@ def aks_update(
nat_gateway_idle_timeout=None,
outbound_type=None,
auto_upgrade_channel=None,
node_os_upgrade_channel=None,
cluster_autoscaler_profile=None,
uptime_sla=False,
no_uptime_sla=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ aks create:
enable_windows_recording_rules:
rule_exclusions:
- option_length_too_long
node_os_upgrade_channel:
rule_exclusions:
- option_length_too_long

aks enable-addons:
parameters:
Expand Down Expand Up @@ -105,4 +108,7 @@ aks update:
enable_windows_recording_rules:
rule_exclusions:
- option_length_too_long
node_os_upgrade_channel:
rule_exclusions:
- option_length_too_long
...
Original file line number Diff line number Diff line change
Expand Up @@ -4027,6 +4027,26 @@ def get_auto_upgrade_channel(self) -> Union[str, None]:
# this parameter does not need validation
return auto_upgrade_channel

def get_node_os_upgrade_channel(self) -> Union[str, None]:
"""Obtain the value of node_os_upgrade_channel.
:return: string or None
"""
# read the original value passed by the command
node_os_upgrade_channel = self.raw_param.get("node_os_upgrade_channel")

# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.mc and
self.mc.auto_upgrade_profile and
self.mc.auto_upgrade_profile.node_os_upgrade_channel is not None
):
node_os_upgrade_channel = self.mc.auto_upgrade_profile.node_os_upgrade_channel

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

def _get_cluster_autoscaler_profile(self, read_only: bool = False) -> Union[Dict[str, str], None]:
"""Internal function to dynamically obtain the value of cluster_autoscaler_profile according to the context.
Expand Down Expand Up @@ -5906,6 +5926,12 @@ def set_up_auto_upgrade_profile(self, mc: ManagedCluster) -> ManagedCluster:
if auto_upgrade_channel:
auto_upgrade_profile = self.models.ManagedClusterAutoUpgradeProfile(upgrade_channel=auto_upgrade_channel)
mc.auto_upgrade_profile = auto_upgrade_profile

node_os_upgrade_channel = self.context.get_node_os_upgrade_channel()
if node_os_upgrade_channel:
if mc.auto_upgrade_profile is None:
mc.auto_upgrade_profile = self.models.ManagedClusterAutoUpgradeProfile()
mc.auto_upgrade_profile.node_os_upgrade_channel = node_os_upgrade_channel
return mc

def set_up_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down Expand Up @@ -6726,6 +6752,13 @@ def update_auto_upgrade_profile(self, mc: ManagedCluster) -> ManagedCluster:
if mc.auto_upgrade_profile is None:
mc.auto_upgrade_profile = self.models.ManagedClusterAutoUpgradeProfile()
mc.auto_upgrade_profile.upgrade_channel = auto_upgrade_channel

node_os_upgrade_channel = self.context.get_node_os_upgrade_channel()
if node_os_upgrade_channel is not None:
if mc.auto_upgrade_profile is None:
mc.auto_upgrade_profile = self.models.ManagedClusterAutoUpgradeProfile()
mc.auto_upgrade_profile.node_os_upgrade_channel = node_os_upgrade_channel

return mc

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

0 comments on commit c963779

Please sign in to comment.