Skip to content
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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.5.39
+++++
* Add commands for agentpool start stop feature

0.5.38
+++++
* Add parameter `--rotation-poll-interval` for Azure Keyvault Secrets Provider Addon.
Expand Down
30 changes: 30 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,36 @@
short-summary: name of the node pool.
"""

helps['aks nodepool stop'] = """
type: command
short-summary: Stop running agent pool in the managed Kubernetes cluster.
parameters:
- name: --nodepool-name
type: string
short-summary: Agent pool name
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
examples:
- name: Stop agent pool in the managed cluster
text: az aks nodepool stop --nodepool-name nodepool1 -g MyResourceGroup --cluster-name MyManagedCluster
"""

helps['aks nodepool start'] = """
type: command
short-summary: Start stopped agent pool in the managed Kubernetes cluster.
parameters:
- name: --nodepool-name
type: string
short-summary: Agent pool name
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
examples:
- name: Start agent pool in the managed cluster
text: az aks nodepool start --nodepool-name nodepool1 -g MyResourceGroup --cluster-name MyManagedCluster
"""

helps['aks nodepool delete'] = """
type: command
short-summary: Delete the agent pool in the managed Kubernetes cluster.
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def load_command_table(self, _):
g.custom_command('delete', 'aks_agentpool_delete',
supports_no_wait=True)
g.custom_command('get-upgrades', 'aks_agentpool_get_upgrade_profile')
g.custom_command('stop', 'aks_agentpool_stop', supports_no_wait=True)
g.custom_command('start', 'aks_agentpool_start', supports_no_wait=True)

# AKS pod identity commands
with self.command_group('aks pod-identity', managed_clusters_sdk, client_factory=cf_managed_clusters) as g:
Expand Down
49 changes: 49 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
ManagedClusterPodIdentity,
ManagedClusterPodIdentityException,
UserAssignedIdentity,
PowerState,
WindowsGmsaProfile)
from ._client_factory import cf_resource_groups
from ._client_factory import get_auth_management_client
Expand Down Expand Up @@ -2687,6 +2688,54 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)


def aks_agentpool_stop(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
cluster_name,
nodepool_name,
aks_custom_headers=None,
no_wait=False):
agentpool_exists = False
instances = client.list(resource_group_name, cluster_name)
for agentpool_profile in instances:
if agentpool_profile.name.lower() == nodepool_name.lower():
agentpool_exists = True
break

if not agentpool_exists:
raise InvalidArgumentValueError(
"Node pool {} doesnt exist, use 'aks nodepool list' to get current node pool list".format(nodepool_name))

instance = client.get(resource_group_name, cluster_name, nodepool_name)
power_state = PowerState(code="Stopped")
instance.power_state = power_state
headers = get_aks_custom_headers(aks_custom_headers)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance, headers=headers)


def aks_agentpool_start(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
cluster_name,
nodepool_name,
aks_custom_headers=None,
no_wait=False):
agentpool_exists = False
instances = client.list(resource_group_name, cluster_name)
for agentpool_profile in instances:
if agentpool_profile.name.lower() == nodepool_name.lower():
agentpool_exists = True
break
if not agentpool_exists:
raise InvalidArgumentValueError(
"Node pool {} doesnt exist, use 'aks nodepool list' to get current node pool list".format(nodepool_name))
instance = client.get(resource_group_name, cluster_name, nodepool_name)
power_state = PowerState(code="Running")
instance.power_state = power_state
headers = get_aks_custom_headers(aks_custom_headers)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance, headers=headers)


def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
Expand Down
Loading