Skip to content
Draft
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
2 changes: 2 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* `az aks nodepool get-rollback-versions`: Add new command to get available rollback versions for a nodepool.
* `az aks nodepool rollback`: Add new command to rollback a nodepool to a previously used configuration (N-1).

19.0.0b16
+++++++
Expand Down
16 changes: 16 additions & 0 deletions src/aks-preview/azext_aks_preview/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ def aks_agentpool_list_table_format(results):
return [_aks_agentpool_table_format(r) for r in results]


def aks_agentpool_rollback_versions_table_format(results):
"""Format rollback versions for display with "-o table"."""
if not results:
return []

def _format_rollback_version(result):
parsed = compile_jmes("""{
kubernetesVersion: orchestrator_version,
nodeImageVersion: node_image_version,
timestamp: timestamp
}""")
return parsed.search(result, Options(dict_cls=OrderedDict))

return [_format_rollback_version(r) for r in results]


def aks_list_table_format(results):
""""Format a list of managed clusters as summary results for display with "-o table"."""
return [_aks_table_format(r) for r in results]
Expand Down
35 changes: 35 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,41 @@
crafted: true
"""

helps['aks nodepool get-rollback-versions'] = """
type: command
short-summary: Get the available rollback versions for an agent pool of the managed Kubernetes cluster.
long-summary: |
Get the list of historically used Kubernetes and node image versions that can be used for rollback operations.
examples:
- name: Get the available rollback versions for an agent pool.
text: az aks nodepool get-rollback-versions --resource-group MyResourceGroup --cluster-name MyManagedCluster --nodepool-name MyNodePool
crafted: true
"""

helps['aks nodepool rollback'] = """
type: command
short-summary: Rollback an agent pool to the most recently used configuration (N-1).
long-summary: |
Rollback an agent pool to the most recently used version based on rollback history.
This will rollback both the Kubernetes version and node image version to their most recent previous state.
For downgrades to older versions (N-2 or earlier), use a separate downgrade operation.
parameters:
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2.
- name: --if-match
type: string
short-summary: The revision of the resource being updated. This should match the current revision.
- name: --if-none-match
type: string
short-summary: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource.
examples:
- name: Rollback a nodepool to the most recently used version.
text: az aks nodepool rollback --resource-group MyResourceGroup --cluster-name MyManagedCluster --nodepool-name MyNodePool
crafted: true
crafted: true
"""

helps['aks nodepool stop'] = """
type: command
short-summary: Stop running agent pool in the managed Kubernetes cluster.
Expand Down
10 changes: 10 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,16 @@ def load_arguments(self, _):
with self.argument_context("aks nodepool manual-scale delete") as c:
c.argument("current_vm_sizes", is_preview=True)

with self.argument_context("aks nodepool get-rollback-versions") as c:
pass # Uses common nodepool parameters

with self.argument_context("aks nodepool rollback") as c:
c.argument("kubernetes_version")
c.argument("node_image_version")
c.argument("aks_custom_headers", nargs="*")
c.argument("if_match")
c.argument("if_none_match")

with self.argument_context("aks machine") as c:
c.argument("cluster_name", help="The cluster name.")
c.argument(
Expand Down
7 changes: 7 additions & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
aks_addon_show_table_format,
aks_agentpool_list_table_format,
aks_agentpool_show_table_format,
aks_agentpool_rollback_versions_table_format,
aks_machine_list_table_format,
aks_machine_show_table_format,
aks_operation_show_table_format,
Expand Down Expand Up @@ -274,6 +275,12 @@ def load_command_table(self, _):
g.custom_command("update", "aks_agentpool_update", supports_no_wait=True)
g.custom_command("delete", "aks_agentpool_delete", supports_no_wait=True)
g.custom_command("get-upgrades", "aks_agentpool_get_upgrade_profile")
g.custom_command(
"get-rollback-versions",
"aks_agentpool_get_rollback_versions",
table_transformer=aks_agentpool_rollback_versions_table_format
)
g.custom_command("rollback", "aks_agentpool_rollback", supports_no_wait=True)
g.custom_command("stop", "aks_agentpool_stop", supports_no_wait=True)
g.custom_command("start", "aks_agentpool_start", supports_no_wait=True)
g.custom_command(
Expand Down
Loading
Loading