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

add --node-os-upgrade-channel to az aks create and az aks update #5788

6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
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_SECURITY_PATCH = "SecurityPatch"
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/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch, node-image or none, none means disable autoupgrade.
- name: --node-os-upgrade-channel
type: string
short-summary: <TODO let Paul fill in>
- name: --kubelet-config
type: string
short-summary: Kubelet configurations for agent nodes.
Expand Down Expand Up @@ -713,6 +716,9 @@
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch, node-image or none, none means disable autoupgrade.
- name: --node-os-upgrade-channel
type: string
short-summary: <TODO let Paul fill in>
- name: --enable-managed-identity
type: bool
short-summary: Update current cluster to managed identity to manage cluster resource group.
Expand Down
12 changes: 12 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL,
CONST_NODEPOOL_MODE_SYSTEM,
CONST_NODEPOOL_MODE_USER,
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
CONST_NODE_OS_CHANNEL_SECURITY_PATCH,
CONST_NODE_OS_CHANNEL_UNMANAGED,
CONST_NONE_UPGRADE_CHANNEL,
CONST_OS_DISK_TYPE_EPHEMERAL,
CONST_OS_DISK_TYPE_MANAGED,
Expand Down Expand Up @@ -190,6 +194,12 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL,
CONST_NONE_UPGRADE_CHANNEL,
]
nodeos_upgrade_channels = [
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
CONST_NODE_OS_CHANNEL_SECURITY_PATCH,
CONST_NODE_OS_CHANNEL_UNMANAGED,
]

# consts for maintenance configuration
schedule_types = [
Expand Down Expand Up @@ -262,6 +272,7 @@ def load_arguments(self, _):
c.argument('network_policy')
c.argument('kube_proxy_config')
c.argument('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels))
c.argument('node_os_upgrade_channel', arg_type=get_enum_type(nodeos_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')
Expand Down Expand Up @@ -400,6 +411,7 @@ def load_arguments(self, _):
c.argument('nat_gateway_idle_timeout', type=int, validator=validate_nat_gateway_idle_timeout)
c.argument('kube_proxy_config')
c.argument('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels))
c.argument('node_os_upgrade_channel', arg_type=get_enum_type(nodeos_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')
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ def aks_create(
network_policy=None,
kube_proxy_config=None,
auto_upgrade_channel=None,
node_os_upgrade_channel=None,
cluster_autoscaler_profile=None,
uptime_sla=False,
fqdn_subdomain=None,
Expand Down Expand Up @@ -758,6 +759,7 @@ def aks_update(
nat_gateway_idle_timeout=None,
kube_proxy_config=None,
auto_upgrade_channel=None,
node_os_upgrade_channel=None,
cluster_autoscaler_profile=None,
uptime_sla=False,
no_uptime_sla=False,
Expand Down
54 changes: 54 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,26 @@ def get_kube_proxy_config(self) -> Union[Dict, ContainerServiceNetworkProfileKub
# this parameter does not need validation
return kube_proxy_config

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_enable_pod_security_policy(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_pod_security_policy.

Expand Down Expand Up @@ -2120,6 +2140,21 @@ def set_up_kube_proxy_config(self, mc: ManagedCluster) -> ManagedCluster:
mc.network_profile.kube_proxy_config = self.context.get_kube_proxy_config()
return mc

def set_up_auto_upgrade_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up auto upgrade profile for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

mc = super().set_up_auto_upgrade_profile(mc)

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 construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) -> ManagedCluster:
"""The overall controller used to construct the default ManagedCluster profile.

Expand Down Expand Up @@ -2153,6 +2188,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_kube_proxy_config(mc)
# set up custom ca trust certificates
mc = self.set_up_custom_ca_trust_certificates(mc)
# set up auto upgrade profile
mc = self.set_up_auto_upgrade_profile(mc)

# DO NOT MOVE: keep this at the bottom, restore defaults
mc = self._restore_defaults_in_mc(mc)
Expand Down Expand Up @@ -2658,6 +2695,21 @@ def update_linux_profile(self, mc: ManagedCluster) -> ManagedCluster:
)
return mc

def update_auto_upgrade_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Update auto upgrade profile for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)


mc = super().update_auto_upgrade_profile(mc)
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_mc_profile_preview(self) -> ManagedCluster:
"""The overall controller used to update the preview ManagedCluster profile.

Expand Down Expand Up @@ -2695,5 +2747,7 @@ def update_mc_profile_preview(self) -> ManagedCluster:
mc = self.update_kube_proxy_config(mc)
# update custom ca trust certificates
mc = self.update_custom_ca_trust_certificates(mc)
# update auto upgrade profile
mc = self.update_auto_upgrade_profile(mc)

return mc
Loading