Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5989a6a
Update SDK to 20230815
Sep 26, 2023
05f88cd
Fixed async operation calls. Added test recording.
Sep 26, 2023
4bec899
changed test region
Sep 27, 2023
7d158cf
Updated recording
Sep 27, 2023
9ecee25
default hubless
Ealianis Sep 28, 2023
eceab1d
WIP - FleetUpdateStrategy, NodeImageSelection, UpgradeType.
Ealianis Sep 28, 2023
defd5ce
test recording update.
Sep 28, 2023
09bd714
version bump and notes
Ealianis Sep 28, 2023
48168cd
Temp - removed update strategy tests.
Ealianis Sep 28, 2023
f3c9a74
Update src/fleet/HISTORY.rst
Ealianis Sep 28, 2023
58aeaeb
Update src/fleet/HISTORY.rst
Ealianis Sep 28, 2023
56f9fa2
Update src/fleet/azext_fleet/_validators.py
Ealianis Sep 28, 2023
eb66bd7
added help text
Ealianis Sep 28, 2023
527bf14
Command made async. Made MSI support hub agnostic.
Ealianis Sep 28, 2023
4ec4130
added -hub true to existing test scenario
Ealianis Sep 28, 2023
96a8a5b
Updated fleet_test_scenario
Sep 28, 2023
088d8c1
Added updatestrategy test.
Ealianis Sep 28, 2023
bc88972
Updated test recording.
Sep 28, 2023
baec951
Added tests, updated help text.
Sep 29, 2023
51fa613
remove location field for fleet scenario test
Sep 29, 2023
f0fe1b9
wip: update stratget
Sep 29, 2023
4011e55
bug fix
Sep 29, 2023
949c404
lint fixes
Ealianis Sep 29, 2023
18eccda
removed validator references
Sep 29, 2023
ad7ee68
fix updatestrategy create
Sep 29, 2023
f767ccf
bug fix
Sep 29, 2023
f767f58
revert and add check
Sep 29, 2023
49e3fa5
add update strategy support in updaterun
Sep 29, 2023
f6c917f
fixed operation group
Sep 29, 2023
bee0ce5
lint fix
Sep 29, 2023
82f106e
lint fix
Sep 29, 2023
26fd723
fix
Sep 29, 2023
1613c79
update tests
Sep 29, 2023
15191e9
fix test
Sep 30, 2023
ca34e89
fix test
Sep 30, 2023
624c1cd
style fix
Sep 30, 2023
350586d
fix test
Sep 30, 2023
3449758
static code fixes
Sep 30, 2023
3c804e6
fix static analysis
Sep 30, 2023
6305716
fix static analysis
Sep 30, 2023
942656b
fix recording
Sep 30, 2023
c48a355
fix test
Sep 30, 2023
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
11 changes: 11 additions & 0 deletions src/fleet/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ Release History
0.2.4
++++++
* Added support for private fleet & MSI.

0.2.5
++++++
* Upgrade SDK version to 2023-08-15-preview

0.2.6
++++++
* By default, fleets are now created without a hub
* Added support for Fleet Upgrade Strategy
* Added argument for Node Image Selection.

2 changes: 1 addition & 1 deletion src/fleet/azext_fleet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def register_fleet_resource_type():
register_resource_type(
"latest",
CUSTOM_MGMT_FLEET,
SDKProfile("2023-06-15-preview"),
SDKProfile("2023-08-15-preview"),
)


Expand Down
4 changes: 4 additions & 0 deletions src/fleet/azext_fleet/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def cf_update_runs(cli_ctx, *_):
return get_container_service_client(cli_ctx).update_runs


def cf_fleet_update_strategies(cli_ctx, *_):
return get_container_service_client(cli_ctx).fleet_update_strategies


def get_resource_groups_client(cli_ctx, subscription_id=None):
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id).resource_groups
47 changes: 44 additions & 3 deletions src/fleet/azext_fleet/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
short-summary: Path to a json file that defines stages to upgrade a fleet. See examples for further reference.
examples:
- name: Create updaterun for a fleet with 'Full' upgrade type.
text: az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type Full --kubernetes-version 1.25.0
text: az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type Full --kubernetes-version 1.25.0 --node-image-selection Latest
- name: Create updaterun for a fleet with 'NodeImageOnly' upgrade type.
text: az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type NodeImageOnly
text: az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type NodeImageOnly --node-image-selection Latest
- name: Create updaterun for a fleet with 'Full' upgrade type & stages.
text: |
az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type Full --kubernetes-version 1.25.0 --stages ./test/stages.json
az fleet updaterun create -g MyResourceGroup -f MyFleet -n MyUpdateRun --upgrade-type Full --kubernetes-version 1.25.0 --node-image-selection Latest --stages ./test/stages.json

A sample json to demonstrate the expected format. It takes a stages array. Each stage consists of the stage name, groups array and an optional afterStageWaitInSeconds integer.
Within groups, each group consists of group name, given to a fleet's member(s).
Expand Down Expand Up @@ -202,3 +202,44 @@
type: command
short-summary: Stops a fleet update run.
"""

helps['fleet updaterun wait'] = """
type: command
short-summary: Wait for a fleet updateraun resource to reach a desired state.
long-summary: If an operation on fleet updateraun was interrupted or was started with `--no-wait`, use this command to wait for it to complete.
"""

helps['fleet updatestrategy'] = """
type: group
short-summary: Commands to manage a fleet update strategy.
"""

helps['fleet updatestrategy create'] = """
type: command
short-summary: Creates or updates a update strategy
parameters:
- name: --stages
type: string
short-summary: Path to a json file that defines the update strategy.
"""

helps['fleet updatestrategy show'] = """
type: command
short-summary: Shows a update strategy.
"""

helps['fleet updatestrategy list'] = """
type: command
short-summary: Lists the fleet's update strategies.
"""

helps['fleet updatestrategy delete'] = """
type: command
short-summary: Deletes a update strategy.
"""

helps['fleet updatestrategy wait'] = """
type: command
short-summary: Wait for a fleet updatestrategy resource to reach a desired state.
long-summary: If an operation on fleet updatestrategy was interrupted or was started with `--no-wait`, use this command to wait for it to complete.
"""
38 changes: 15 additions & 23 deletions src/fleet/azext_fleet/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
tags_type,
file_type,
get_location_type,
get_three_state_flag
get_enum_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group

from azext_fleet._validators import validate_member_cluster_id, validate_upgrade_type, validate_kubernetes_version
from azext_fleet._validators import validate_member_cluster_id, validate_upgrade_type, validate_kubernetes_version, validate_apiserver_subnet_id, validate_agent_subnet_id, validate_assign_identity
from azext_fleet._validators import validate_member_cluster_id, validate_kubernetes_version, validate_apiserver_subnet_id, validate_agent_subnet_id, validate_assign_identity, validate_update_strategy_id


def load_arguments(self, _):
Expand All @@ -26,16 +24,17 @@ def load_arguments(self, _):
with self.argument_context('fleet create') as c:
c.argument('tags', tags_type)
c.argument('dns_name_prefix', options_list=['--dns-name-prefix', '-p'])
c.argument('enable_private_cluster', arg_type=get_three_state_flag(), is_preview=True, help='Whether to create the Fleet hub as a private cluster or not.')
c.argument('enable_vnet_integration', arg_type=get_three_state_flag(), is_preview=True, help='Whether to enable apiserver vnet integration for the Fleet hub or not.')
c.argument('enable_private_cluster', action='store_true', is_preview=True, help='Whether to create the Fleet hub as a private cluster or not.')
c.argument('enable_vnet_integration', action='store_true', is_preview=True, help='Whether to enable apiserver vnet integration for the Fleet hub or not.')
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id, is_preview=True, help='The subnet to be used when apiserver vnet integration is enabled. It is required when creating a new Fleet with BYO vnet.')
c.argument('agent_subnet_id', validator=validate_agent_subnet_id, is_preview=True, help='The ID of the subnet which the Fleet hub node will join on startup. If this is not specified, a vnet and subnet will be generated and used.')
c.argument('enable_managed_identity', arg_type=get_three_state_flag(), is_preview=True, help='Enable system assigned managed identity (MSI) on the Fleet resource.')
c.argument('enable_managed_identity', action='store_true', is_preview=True, help='Enable system assigned managed identity (MSI) on the Fleet resource.')
c.argument('assign_identity', validator=validate_assign_identity, is_preview=True, help='With --enable-managed-identity, enable user assigned managed identity (MSI) on the Fleet resource. Specify the existing user assigned identity resource.')
c.argument('enable_hub', action='store_true', is_preview=True, help='If set, the Fleet will be created with a hub cluster.')

with self.argument_context('fleet update') as c:
c.argument('tags', tags_type)
c.argument('enable_managed_identity', arg_type=get_three_state_flag(), is_preview=True, help='Enable system assigned managed identity (MSI) on the Fleet resource.')
c.argument('enable_managed_identity', action='store_true', is_preview=True, help='Enable system assigned managed identity (MSI) on the Fleet resource.')
c.argument('assign_identity', validator=validate_assign_identity, is_preview=True, help='With --enable-managed-identity, enable user assigned managed identity (MSI) on the Fleet resource. Specify the existing user assigned identity resource.')

with self.argument_context('fleet get-credentials') as c:
Expand All @@ -58,22 +57,15 @@ def load_arguments(self, _):
c.argument('fleet_name', options_list=['--fleet-name', '-f'], help='Specify the fleet name.')

with self.argument_context('fleet updaterun create') as c:
c.argument('upgrade_type', validator=validate_upgrade_type)
c.argument('upgrade_type', arg_type=get_enum_type(['Full', 'NodeImageOnly']))
c.argument('kubernetes_version', validator=validate_kubernetes_version)
c.argument('stages', type=file_type, completer=FilesCompleter())
c.argument('update_group')

with self.argument_context('fleet member update') as c:
c.argument('update_group')

with self.argument_context('fleet member update') as c:
c.argument('update_group')
c.argument('node_image_selection', arg_type=get_enum_type(['Latest', 'Consistent']), help='Node Image Selection is an option that lets you choose how your clusters\' nodes are upgraded')
c.argument('stages', type=file_type, completer=FilesCompleter(), help='Path to a json file that defines stages to upgrade a fleet. See examples for further reference.')
c.argument('update_strategy_id', validator=validate_update_strategy_id, help='The ID of the update strategy to use for this update run. If not specified, the default update strategy will be used.')

with self.argument_context('fleet updaterun') as c:
c.argument('name', options_list=['--name', '-n'], help='Specify name for the update run.')
with self.argument_context('fleet updatestrategy') as c:
c.argument('name', options_list=['--name', '-n'], help='Specify name for the fleet update strategy.')
c.argument('fleet_name', options_list=['--fleet-name', '-f'], help='Specify the fleet name.')

with self.argument_context('fleet updaterun create') as c:
c.argument('upgrade_type', validator=validate_upgrade_type)
c.argument('kubernetes_version', validator=validate_kubernetes_version)
c.argument('stages', type=file_type, completer=FilesCompleter())
with self.argument_context('fleet updatestrategy create') as c:
c.argument('stages', type=file_type, completer=FilesCompleter(), help='Path to a json file that defines an update strategy.')
15 changes: 8 additions & 7 deletions src/fleet/azext_fleet/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ def validate_member_cluster_id(namespace):
"--member-cluster-id is not a valid Azure resource ID.")


def validate_upgrade_type(namespace):
upgrade_type = namespace.upgrade_type
if upgrade_type not in ("Full", "NodeImageOnly"):
raise InvalidArgumentValueError(
"--upgrade-type must be set to 'Full' or 'NodeImageOnly'")


def validate_kubernetes_version(namespace):
try:
if namespace.kubernetes_version:
Expand All @@ -41,6 +34,14 @@ def validate_agent_subnet_id(namespace):
_validate_subnet_id(namespace.agent_subnet_id, "--agent-subnet-id")


def validate_update_strategy_id(namespace):
if namespace.update_strategy_id is not None:
from msrestazure.tools import is_valid_resource_id
if not is_valid_resource_id(namespace.update_strategy_id):
raise CLIError(
"--update-strategy-id is not a valid Azure resource ID.")


def _validate_subnet_id(subnet_id, name):
if subnet_id is None or subnet_id == '':
return
Expand Down
19 changes: 17 additions & 2 deletions src/fleet/azext_fleet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# pylint: disable=line-too-long
from azure.cli.core.commands import CliCommandType
from azext_fleet._client_factory import cf_fleets, cf_fleet_members, cf_update_runs
from azext_fleet._client_factory import cf_fleets, cf_fleet_members, cf_update_runs, cf_fleet_update_strategies


def load_command_table(self, _):
Expand All @@ -28,10 +28,16 @@ def load_command_table(self, _):
client_factory=cf_update_runs
)

fleet_update_strategy_sdk = CliCommandType(
operations_tmpl="azext_fleet.vendored_sdks.operations._fleet_update_strategies_operations#FleetUpdateStrategiesOperations.{}",
operation_group="fleet_update_strategies",
client_factory=cf_fleet_update_strategies
)

# fleets command group
with self.command_group("fleet", fleets_sdk, client_factory=cf_fleets, is_preview=True) as g:
g.custom_command("create", "create_fleet", supports_no_wait=True)
g.custom_command("update", "update_fleet")
g.custom_command("update", "update_fleet", supports_no_wait=True)
g.custom_show_command("show", "show_fleet")
g.custom_command("list", "list_fleet")
g.custom_command("delete", "delete_fleet", supports_no_wait=True)
Expand All @@ -55,3 +61,12 @@ def load_command_table(self, _):
g.custom_command("delete", "delete_update_run", supports_no_wait=True)
g.custom_command("start", "start_update_run", supports_no_wait=True)
g.custom_command("stop", "stop_update_run", supports_no_wait=True)
g.wait_command("wait")

# fleet update strategies command group
with self.command_group("fleet updatestrategy", fleet_update_strategy_sdk, client_factory=cf_fleet_update_strategies) as g:
g.custom_command("create", "create_fleet_update_strategy", supports_no_wait=True)
g.custom_show_command("show", "show_fleet_update_strategy")
g.custom_command("list", "list_fleet_update_strategies")
g.custom_command("delete", "delete_fleet_update_strategy", supports_no_wait=True)
g.wait_command("wait")
Loading