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
6 changes: 5 additions & 1 deletion src/fleet/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ Release History

1.5.0
++++++
* Upgrade SDK version to 2025-03-01
* Upgrade SDK version to 2025-03-01

1.5.1
++++++
* create_fleet now creates a role assignment when fleet type is private
5 changes: 5 additions & 0 deletions src/fleet/azext_fleet/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ def cf_auto_upgrade_profiles(cli_ctx, *_):

def cf_auto_upgrade_profile_operations(cli_ctx, *_):
return get_container_service_client(cli_ctx).auto_upgrade_profile_operations


def get_provider_client(cli_ctx):
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
18 changes: 18 additions & 0 deletions src/fleet/azext_fleet/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from knack.log import get_logger
from knack.prompting import NoTTYException, prompt_y_n
from knack.util import CLIError
from azure.cli.command_modules.acs._roleassignments import add_role_assignment

from azext_fleet.constants import FLEET_1P_APP_ID
from azext_fleet._client_factory import get_provider_client

logger = get_logger(__name__)

Expand Down Expand Up @@ -148,3 +152,17 @@ def _load_kubernetes_configuration(filename):
raise
except (yaml.parser.ParserError, UnicodeDecodeError) as ex:
raise CLIError(f'Error parsing {filename} ({str(ex)})') from ex


def assign_network_contributor_role_to_subnet(cmd, subnet_id):
resource_client = get_provider_client(cmd.cli_ctx)
provider = resource_client.providers.get("Microsoft.ContainerService")

# provider registration state being is checked to ensure that the Fleet service principal is available
# to create the role assignment on the subnet
if provider.registration_state != 'Registered':
raise CLIError("The Microsoft.ContainerService resource provider is not registered."
"Run `az provider register -n Microsoft.ContainerService --wait`.")
if not add_role_assignment(cmd, 'Network Contributor', FLEET_1P_APP_ID, scope=subnet_id):
raise CLIError("failed to create role assignment for Fleet RP.\n"
f"Do you have owner permissions on the subnet {subnet_id}?\n")
1 change: 1 addition & 0 deletions src/fleet/azext_fleet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
UPGRADE_TYPE_CONTROLPLANEONLY = "ControlPlaneOnly"
UPGRADE_TYPE_FULL = "Full"
UPGRADE_TYPE_NODEIMAGEONLY = "NodeImageOnly"
FLEET_1P_APP_ID = "609d2f62-527f-4451-bfd2-ac2c7850822c"

UPGRADE_TYPE_ERROR_MESSAGES = {
UPGRADE_TYPE_CONTROLPLANEONLY: f"Please set kubernetes version when upgrade type is '{UPGRADE_TYPE_CONTROLPLANEONLY}'.", # pylint: disable=line-too-long
Expand Down
4 changes: 4 additions & 0 deletions src/fleet/azext_fleet/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from azext_fleet._client_factory import CUSTOM_MGMT_FLEET
from azext_fleet._helpers import print_or_merge_credentials
from azext_fleet._helpers import assign_network_contributor_role_to_subnet
from azext_fleet.constants import UPGRADE_TYPE_CONTROLPLANEONLY
from azext_fleet.constants import UPGRADE_TYPE_FULL
from azext_fleet.constants import UPGRADE_TYPE_NODEIMAGEONLY
Expand Down Expand Up @@ -109,6 +110,9 @@ def create_fleet(cmd,
identity=managed_service_identity
)

if enable_private_cluster:
assign_network_contributor_role_to_subnet(cmd, resource_group_name, agent_subnet_id)

return sdk_no_wait(no_wait,
client.begin_create_or_update,
resource_group_name,
Expand Down
3,071 changes: 2,073 additions & 998 deletions src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubful.yaml

Large diffs are not rendered by default.

1,063 changes: 609 additions & 454 deletions src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubless.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/fleet/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.
VERSION = '1.5.0'
VERSION = '1.5.1'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading