Skip to content

Commit 103dc2c

Browse files
xhl873Xiahe Liu
andauthored
[AKS] Add auto upgrade channel to aks create and update (Azure#2694)
* add upgrade channel to aks create/update * add in consts and params * update help.py * fixes * typo * remove extra ) * pr comments * add test * add recording * test recording * add newline at end of file Co-authored-by: Xiahe Liu <Xiahe.Liu@microsoft.com>
1 parent b0cdaee commit 103dc2c

File tree

6 files changed

+1272
-2
lines changed

6 files changed

+1272
-2
lines changed

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
CONST_SPOT_EVICTION_POLICY_DELETE = "Delete"
1313
CONST_SPOT_EVICTION_POLICY_DEALLOCATE = "Deallocate"
1414

15+
# consts for upgrade channel
16+
CONST_RAPID_UPGRADE_CHANNEL = "rapid"
17+
CONST_STABLE_UPGRADE_CHANNEL = "stable"
18+
CONST_PATCH_UPGRADE_CHANNEL = "patch"
19+
CONST_NONE_UPGRADE_CHANNEL = "none"
20+
1521
CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME = "httpApplicationRouting"
1622

1723
CONST_MONITORING_ADDON_NAME = "omsagent"

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@
282282
- name: --disable-sgxquotehelper
283283
type: bool
284284
short-summary: Disable SGX quote helper for confcom addon.
285+
- name: --auto-upgrade-channel
286+
type: string
287+
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch or none, none means disable autoupgrade.
285288
- name: --kubelet-config
286289
type: string
287290
short-summary: Kubelet configurations for agent nodes.
@@ -431,6 +434,9 @@
431434
- name: --aks-custom-headers
432435
type: string
433436
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
437+
- name: --auto-upgrade-channel
438+
type: string
439+
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch or none, none means disable autoupgrade.
434440
- name: --enable-managed-identity
435441
type: bool
436442
short-summary: (PREVIEW) Update current cluster to managed identity to manage cluster resource group.

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
CONST_SPOT_EVICTION_POLICY_DELETE, CONST_SPOT_EVICTION_POLICY_DEALLOCATE, \
2929
CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER, \
3030
CONST_OS_DISK_TYPE_MANAGED, CONST_OS_DISK_TYPE_EPHEMERAL, \
31+
CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL, \
3132
CONST_PRIVATE_DNS_ZONE_SYSTEM, CONST_PRIVATE_DNS_ZONE_NONE
3233

3334

@@ -111,6 +112,7 @@ def load_arguments(self, _):
111112
c.argument('enable_managed_identity', action='store_true')
112113
c.argument('assign_identity', type=str, validator=validate_assign_identity)
113114
c.argument('disable_sgxquotehelper', action='store_true')
115+
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
114116
c.argument('kubelet_config', type=str)
115117
c.argument('linux_os_config', type=str)
116118

@@ -133,6 +135,7 @@ def load_arguments(self, _):
133135
c.argument('attach_acr', acr_arg_type, validator=validate_acr)
134136
c.argument('detach_acr', acr_arg_type, validator=validate_acr)
135137
c.argument('aks_custom_headers')
138+
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
136139
c.argument('enable_managed_identity', action='store_true')
137140
c.argument('assign_identity', type=str, validator=validate_assign_identity)
138141
c.argument('yes', options_list=['--yes', '-y'], help='Do not prompt for confirmation.', action='store_true')

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
ManagedClusterAPIServerAccessProfile,
6868
ManagedClusterSKU,
6969
ManagedClusterIdentityUserAssignedIdentitiesValue,
70+
ManagedClusterAutoUpgradeProfile,
7071
KubeletConfig,
7172
LinuxOSConfig,
7273
SysctlConfig)
@@ -883,6 +884,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
883884
kubelet_config=None,
884885
linux_os_config=None,
885886
assign_identity=None,
887+
auto_upgrade_channel=None,
886888
no_wait=False):
887889
if not no_ssh_key:
888890
try:
@@ -1125,6 +1127,10 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
11251127
if disable_rbac:
11261128
enable_rbac = False
11271129

1130+
auto_upgrade_profile = None
1131+
if auto_upgrade_channel is not None:
1132+
auto_upgrade_profile = ManagedClusterAutoUpgradeProfile(upgrade_channel=auto_upgrade_channel)
1133+
11281134
mc = ManagedCluster(
11291135
location=location, tags=tags,
11301136
dns_prefix=dns_name_prefix,
@@ -1141,7 +1147,8 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
11411147
enable_pod_security_policy=bool(enable_pod_security_policy),
11421148
identity=identity,
11431149
disk_encryption_set_id=node_osdisk_diskencryptionset_id,
1144-
api_server_access_profile=api_server_access_profile)
1150+
api_server_access_profile=api_server_access_profile,
1151+
auto_upgrade_profile=auto_upgrade_profile)
11451152

11461153
if node_resource_group:
11471154
mc.node_resource_group = node_resource_group
@@ -1223,6 +1230,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
12231230
enable_ahub=False,
12241231
disable_ahub=False,
12251232
aks_custom_headers=None,
1233+
auto_upgrade_channel=None,
12261234
enable_managed_identity=False,
12271235
assign_identity=None,
12281236
yes=False):
@@ -1248,6 +1256,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
12481256
not update_aad_profile and \
12491257
not enable_ahub and \
12501258
not disable_ahub and \
1259+
not auto_upgrade_channel and \
12511260
not enable_managed_identity and \
12521261
not assign_identity:
12531262
raise CLIError('Please specify "--enable-cluster-autoscaler" or '
@@ -1267,7 +1276,8 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
12671276
'"--aad-tenant-id" or '
12681277
'"--aad-admin-group-object-ids" or '
12691278
'"--enable-ahub" or '
1270-
'"--disable-ahub" or'
1279+
'"--disable-ahub" or '
1280+
'"--auto-upgrade-channel" or '
12711281
'"--enable-managed-identity"')
12721282

12731283
instance = client.get(resource_group_name, name)
@@ -1404,6 +1414,12 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
14041414
if disable_ahub:
14051415
instance.windows_profile.license_type = 'None'
14061416

1417+
if instance.auto_upgrade_profile is None:
1418+
instance.auto_upgrade_profile = ManagedClusterAutoUpgradeProfile()
1419+
1420+
if auto_upgrade_channel is not None:
1421+
instance.auto_upgrade_profile.upgrade_channel = auto_upgrade_channel
1422+
14071423
if not enable_managed_identity and assign_identity:
14081424
raise CLIError('--assign-identity can only be specified when --enable-managed-identity is specified')
14091425

0 commit comments

Comments
 (0)