Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] az aks create/update: Add new parameter --node-os-upgrade-channel to specify which OS on your nodes is updated #27167

Merged
merged 2 commits into from
Aug 17, 2023
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
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 @@ -653,6 +656,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="Space-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 @@ -663,6 +664,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 @@ -5847,6 +5867,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 @@ -6667,6 +6693,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