Skip to content

Commit 69a573a

Browse files
authored
[AKS] az aks create: Add parameters --system-node-subnet-id, --node-subnet-id and --enable-hosted-system to support BYO VNet for Automatic Managed System Pool clusters (#33259)
1 parent 1612f59 commit 69a573a

7 files changed

Lines changed: 719 additions & 32 deletions

File tree

src/azure-cli/azure/cli/command_modules/acs/_help.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,30 @@
345345
- name: --apiserver-subnet-id
346346
type: string
347347
short-summary: The ID of a subnet in an existing VNet into which to assign control plane apiserver pods(requires --enable-apiserver-vnet-integration)
348+
- name: --system-node-subnet-id
349+
type: string
350+
short-summary: (Automatic SKU) The ID of a subnet in an existing VNet to be used by the Managed System Pool in an Automatic cluster.
351+
long-summary: |
352+
Bring-your-own VNet for an Automatic cluster requires three subnets supplied together:
353+
`--system-node-subnet-id` (this flag, for the Managed System Pool), `--node-subnet-id`
354+
(for user node pools), and `--apiserver-subnet-id` (for the control plane API server).
355+
All three subnets must belong to the same VNet and can only be used with `--sku automatic`.
356+
- name: --node-subnet-id
357+
type: string
358+
short-summary: (Automatic SKU) The ID of a subnet in an existing VNet to be used by user node pools in an Automatic cluster.
359+
long-summary: |
360+
Bring-your-own VNet for an Automatic cluster requires three subnets supplied together:
361+
`--system-node-subnet-id` (for the Managed System Pool), `--node-subnet-id` (this flag,
362+
for user node pools), and `--apiserver-subnet-id` (for the control plane API server).
363+
All three subnets must belong to the same VNet and can only be used with `--sku automatic`.
364+
- name: --enable-hosted-system
365+
type: bool
366+
short-summary: (Automatic SKU) Explicitly opt in to a Managed System Pool for the Automatic cluster.
367+
long-summary: |
368+
Only valid with `--sku automatic`. Use this flag when you want to deterministically
369+
request a Managed System Pool regardless of region defaults. It is also implied when
370+
you supply the bring-your-own VNet subnet trio (`--system-node-subnet-id`,
371+
`--node-subnet-id`, `--apiserver-subnet-id`).
348372
- name: --enable-private-cluster
349373
type: string
350374
short-summary: Enable private cluster.

src/azure-cli/azure/cli/command_modules/acs/_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
validate_disable_windows_outbound_nat,
134134
validate_asm_egress_name,
135135
validate_crg_id, validate_apiserver_subnet_id,
136+
validate_system_node_subnet_id, validate_node_subnet_id,
136137
validate_azure_service_mesh_revision,
137138
validate_message_of_the_day,
138139
validate_custom_ca_trust_certificates,
@@ -443,6 +444,9 @@ def load_arguments(self, _):
443444
c.argument('enable_private_cluster', action='store_true')
444445
c.argument('enable_apiserver_vnet_integration', action='store_true')
445446
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id)
447+
c.argument('system_node_subnet_id', validator=validate_system_node_subnet_id)
448+
c.argument('node_subnet_id', validator=validate_node_subnet_id)
449+
c.argument('enable_hosted_system', action='store_true')
446450
c.argument('private_dns_zone')
447451
c.argument('disable_public_fqdn', action='store_true')
448452
c.argument('service_principal')

src/azure-cli/azure/cli/command_modules/acs/_validators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,14 @@ def validate_apiserver_subnet_id(namespace):
455455
_validate_subnet_id(namespace.apiserver_subnet_id, "--apiserver-subnet-id")
456456

457457

458+
def validate_system_node_subnet_id(namespace):
459+
_validate_subnet_id(namespace.system_node_subnet_id, "--system-node-subnet-id")
460+
461+
462+
def validate_node_subnet_id(namespace):
463+
_validate_subnet_id(namespace.node_subnet_id, "--node-subnet-id")
464+
465+
458466
def _validate_subnet_id(subnet_id, name):
459467
if subnet_id is None or subnet_id == '':
460468
return

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,10 @@ def aks_create(
10331033
# apiserver vnet integration
10341034
enable_apiserver_vnet_integration=False,
10351035
apiserver_subnet_id=None,
1036+
# BYO VNet for Managed System Pool (Automatic SKU)
1037+
system_node_subnet_id=None,
1038+
node_subnet_id=None,
1039+
enable_hosted_system=False,
10361040
# node provisioning
10371041
node_provisioning_mode=None,
10381042
node_provisioning_default_pools=None,
@@ -1276,7 +1280,7 @@ def aks_upgrade(cmd,
12761280
instance = client.get(resource_group_name, name)
12771281

12781282
vmas_cluster = False
1279-
for agent_profile in instance.agent_pool_profiles:
1283+
for agent_profile in (instance.agent_pool_profiles or []):
12801284
if agent_profile.type.lower() == "availabilityset":
12811285
vmas_cluster = True
12821286
break
@@ -1293,7 +1297,7 @@ def aks_upgrade(cmd,
12931297

12941298
# This only provide convenience for customer at client side so they can run az aks upgrade to upgrade all
12951299
# nodepools of a cluster. The SDK only support upgrade single nodepool at a time.
1296-
for agent_pool_profile in instance.agent_pool_profiles:
1300+
for agent_pool_profile in (instance.agent_pool_profiles or []):
12971301
if vmas_cluster:
12981302
raise CLIError('This cluster is using AvailabilitySet. Node image upgrade only operation '
12991303
'can only be applied on VirtualMachineScaleSets or VirtualMachines cluster.')
@@ -1357,7 +1361,7 @@ def aks_upgrade(cmd,
13571361
return None
13581362

13591363
if upgrade_all:
1360-
for agent_profile in instance.agent_pool_profiles:
1364+
for agent_profile in (instance.agent_pool_profiles or []):
13611365
agent_profile.orchestrator_version = kubernetes_version
13621366
agent_profile.creation_data = None
13631367

@@ -1441,12 +1445,17 @@ def _upgrade_single_nodepool_image_version(no_wait, client, resource_group_name,
14411445
def aks_scale(cmd, client, resource_group_name, name, node_count, nodepool_name="", no_wait=False):
14421446
instance = client.get(resource_group_name, name)
14431447

1444-
if len(instance.agent_pool_profiles) > 1 and nodepool_name == "":
1448+
agent_pool_profiles = instance.agent_pool_profiles or []
1449+
if not agent_pool_profiles:
1450+
raise CLIError('The cluster has no scalable node pools (this may be a Managed System Pool for '
1451+
'Automatic cluster). Use az aks nodepool add/scale against a user node pool instead.')
1452+
1453+
if len(agent_pool_profiles) > 1 and nodepool_name == "":
14451454
raise CLIError('There are more than one node pool in the cluster. '
14461455
'Please specify nodepool name or use az aks nodepool command to scale node pool')
14471456

1448-
for agent_profile in instance.agent_pool_profiles:
1449-
if agent_profile.name == nodepool_name or (nodepool_name == "" and len(instance.agent_pool_profiles) == 1):
1457+
for agent_profile in agent_pool_profiles:
1458+
if agent_profile.name == nodepool_name or (nodepool_name == "" and len(agent_pool_profiles) == 1):
14501459
if agent_profile.enable_auto_scaling:
14511460
raise CLIError(
14521461
"Cannot scale cluster autoscaler enabled node pool.")

src/azure-cli/azure/cli/command_modules/acs/linter_exclusions.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
---
22
aks create:
33
parameters:
4+
system_node_subnet_id:
5+
rule_exclusions:
6+
- missing_parameter_test_coverage
7+
node_subnet_id:
8+
rule_exclusions:
9+
- missing_parameter_test_coverage
10+
enable_hosted_system:
11+
rule_exclusions:
12+
- missing_parameter_test_coverage
413
appgw_watch_namespace:
514
rule_exclusions:
615
- option_length_too_long

0 commit comments

Comments
 (0)