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} add nodepool mode support (and upgrade to 2020-03-01 api version) #12749

Merged
merged 1 commit into from
Mar 26, 2020
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: 2 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acs/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def _aks_agentpool_table_format(result):
osDiskSizeGB: osDiskSizeGB,
count: count,
maxPods: maxPods,
provisioningState: provisioningState
provisioningState: provisioningState,
mode: mode
}""")
# use ordered dicts so headers are predictable
return parsed.search(result, Options(dict_cls=OrderedDict))
Expand Down Expand Up @@ -86,14 +87,12 @@ def find_preview_versions(versions_bag):
if upgrade.get('isPreview', False):
preview[upgrade['kubernetesVersion']] = True
find_preview_versions(result.get('controlPlaneProfile', {}))
find_preview_versions(result.get('agentPoolProfiles', [{}])[0])

# This expression assumes there is one node pool, and that the master and nodes upgrade in lockstep.
parsed = compile_jmes("""{
name: name,
resourceGroup: resourceGroup,
masterVersion: controlPlaneProfile.kubernetesVersion || `unknown`,
nodePoolVersion: agentPoolProfiles[0].kubernetesVersion || `unknown` | set_preview(@),
upgrades: controlPlaneProfile.upgrades[].kubernetesVersion || [`None available`] | sort_versions(@) | set_preview_array(@) | join(`, `, @)
}""")
# use ordered dicts so headers are predictable
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 @@ -625,6 +625,9 @@
- name: --labels
type: string
short-summary: The node labels for the node pool. You can't change the node labels through CLI after the node pool is created. See https://aka.ms/node-labels for syntax of labels.
- name: --mode
type: string
short-summary: The mode for a node pool which defines a node pool's primary function. If set as "System", AKS prefers system pods scheduling to node pools with mode `System`. Learn more at https://aka.ms/aks/nodepool/mode.
"""

helps['aks nodepool delete'] = """
Expand Down Expand Up @@ -670,6 +673,9 @@
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --mode
type: string
short-summary: The mode for a node pool which defines a node pool's primary function. If set as "System", AKS prefers system pods scheduling to node pools with mode `System`. Learn more at https://aka.ms/aks/nodepool/mode.
examples:
- name: Enable cluster-autoscaler within node count range [1,5]
text: az aks nodepool update --enable-cluster-autoscaler --min-count 1 --max-count 5 -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/acs/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from distutils.version import StrictVersion # pylint: disable=no-name-in-module,import-error
# pylint: disable=no-name-in-module,import-error
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterAPIServerAccessProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterAPIServerAccessProfile
from knack.util import CLIError


Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/acs/_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from distutils.version import StrictVersion # pylint: disable=no-name-in-module,import-error

# pylint: disable=no-name-in-module,import-error
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterLoadBalancerProfile
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterLoadBalancerProfileManagedOutboundIPs
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterLoadBalancerProfileOutboundIPPrefixes
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterLoadBalancerProfileOutboundIPs
from azure.mgmt.containerservice.v2019_11_01.models import ResourceReference
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterLoadBalancerProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterLoadBalancerProfileManagedOutboundIPs
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterLoadBalancerProfileOutboundIPPrefixes
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterLoadBalancerProfileOutboundIPs
from azure.mgmt.containerservice.v2020_03_01.models import ResourceReference

from knack.log import get_logger

Expand Down
3 changes: 3 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 @@ -62,6 +62,7 @@
]

storage_profile_types = ["StorageAccount", "ManagedDisks"]
nodepool_mode_type = ["System", "User"]


def load_arguments(self, _):
Expand Down Expand Up @@ -291,6 +292,7 @@ def load_arguments(self, _):
c.argument('node_taints', type=str, validator=validate_taints)
c.argument('tags', tags_type)
c.argument('labels', nargs='*', validator=validate_nodepool_labels)
c.argument('mode', get_enum_type(nodepool_mode_type))

for scope in ['aks nodepool show', 'aks nodepool delete', 'aks nodepool scale', 'aks nodepool upgrade', 'aks nodepool update']:
with self.argument_context(scope) as c:
Expand All @@ -301,6 +303,7 @@ def load_arguments(self, _):
c.argument('disable_cluster_autoscaler', options_list=["--disable-cluster-autoscaler", "-d"], action='store_true')
c.argument('update_cluster_autoscaler', options_list=["--update-cluster-autoscaler", "-u"], action='store_true')
c.argument('tags', tags_type)
c.argument('mode', get_enum_type(nodepool_mode_type))

with self.argument_context('aks upgrade-connector') as c:
c.argument('aci_resource_group')
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/acs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def load_command_table(self, _):
)

managed_clusters_sdk = CliCommandType(
operations_tmpl='azure.mgmt.containerservice.v2019_11_01.operations.'
operations_tmpl='azure.mgmt.containerservice.v2020_03_01.operations.'
'_managed_clusters_operations#ManagedClustersOperations.{}',
client_factory=cf_managed_clusters
)
Expand Down
53 changes: 33 additions & 20 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@

from azure.mgmt.containerservice.models import ContainerServiceOrchestratorTypes

from azure.mgmt.containerservice.v2019_11_01.models import ContainerServiceNetworkProfile
from azure.mgmt.containerservice.v2019_11_01.models import ContainerServiceLinuxProfile
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterServicePrincipalProfile
from azure.mgmt.containerservice.v2019_11_01.models import ContainerServiceSshConfiguration
from azure.mgmt.containerservice.v2019_11_01.models import ContainerServiceSshPublicKey
from azure.mgmt.containerservice.v2019_11_01.models import ContainerServiceStorageProfileTypes
from azure.mgmt.containerservice.v2019_11_01.models import ManagedCluster
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterAADProfile
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterAddonProfile
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterAgentPoolProfile
from azure.mgmt.containerservice.v2019_11_01.models import ManagedClusterIdentity
from azure.mgmt.containerservice.v2019_11_01.models import AgentPool
from azure.mgmt.containerservice.v2020_03_01.models import ContainerServiceNetworkProfile
from azure.mgmt.containerservice.v2020_03_01.models import ContainerServiceLinuxProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterServicePrincipalProfile
from azure.mgmt.containerservice.v2020_03_01.models import ContainerServiceSshConfiguration
from azure.mgmt.containerservice.v2020_03_01.models import ContainerServiceSshPublicKey
from azure.mgmt.containerservice.v2020_03_01.models import ContainerServiceStorageProfileTypes
from azure.mgmt.containerservice.v2020_03_01.models import ManagedCluster
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterAADProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterAddonProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterAgentPoolProfile
from azure.mgmt.containerservice.v2020_03_01.models import ManagedClusterIdentity
from azure.mgmt.containerservice.v2020_03_01.models import AgentPool

from azure.mgmt.containerservice.v2019_09_30_preview.models import OpenShiftManagedClusterAgentPoolProfile
from azure.mgmt.containerservice.v2019_09_30_preview.models import OpenShiftAgentPoolProfileRole
Expand Down Expand Up @@ -1713,7 +1713,8 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
vnet_subnet_id=vnet_subnet_id,
availability_zones=zones,
max_pods=int(max_pods) if max_pods else None,
type=vm_set_type
type=vm_set_type,
mode="System"
)
if node_osdisk_size:
agent_pool_profile.os_disk_size_gb = int(node_osdisk_size)
Expand Down Expand Up @@ -2734,6 +2735,7 @@ def aks_agentpool_add(cmd, client, resource_group_name, cluster_name, nodepool_n
node_taints=None,
tags=None,
labels=None,
mode="User",
no_wait=False):
instances = client.list(resource_group_name, cluster_name)
for agentpool_profile in instances:
Expand Down Expand Up @@ -2769,7 +2771,8 @@ def aks_agentpool_add(cmd, client, resource_group_name, cluster_name, nodepool_n
max_pods=int(max_pods) if max_pods else None,
orchestrator_version=kubernetes_version,
availability_zones=zones,
node_taints=taints_array
node_taints=taints_array,
mode=mode
)

_check_cluster_autoscaler_flag(enable_cluster_autoscaler, min_count, max_count, node_count, agent_pool)
Expand Down Expand Up @@ -2810,14 +2813,21 @@ def aks_agentpool_update(cmd, client, resource_group_name, cluster_name, nodepoo
update_cluster_autoscaler=False,
min_count=None, max_count=None,
tags=None,
mode=None,
no_wait=False):

update_flags = enable_cluster_autoscaler + disable_cluster_autoscaler + update_cluster_autoscaler
if update_flags != 1:
if update_flags != 0 or tags is None:
raise CLIError('Please specify "--enable-cluster-autoscaler" or '
'"--disable-cluster-autoscaler" or '
'"--update-cluster-autoscaler"')
update_autoscaler = enable_cluster_autoscaler + disable_cluster_autoscaler + update_cluster_autoscaler

if update_autoscaler > 1:
raise CLIError('Please specify one of "--enable-cluster-autoscaler" or '
'"--disable-cluster-autoscaler" or '
'"--update-cluster-autoscaler"')

if (update_autoscaler == 0 and not tags and not mode):
raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or '
'"--disable-cluster-autoscaler" or '
'"--update-cluster-autoscaler" or '
'"--tags" or "--mode"')

instance = client.get(resource_group_name, cluster_name, nodepool_name)
node_count = instance.count
Expand Down Expand Up @@ -2853,6 +2863,9 @@ def aks_agentpool_update(cmd, client, resource_group_name, cluster_name, nodepoo

instance.tags = tags

if mode is not None:
instance.mode = mode

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)


Expand Down
Loading