diff --git a/src/connectedk8s/azext_connectedk8s/_utils.py b/src/connectedk8s/azext_connectedk8s/_utils.py index e3268806f7b..15547848469 100644 --- a/src/connectedk8s/azext_connectedk8s/_utils.py +++ b/src/connectedk8s/azext_connectedk8s/_utils.py @@ -1315,6 +1315,7 @@ def helm_install_release( ] # Special configurations from 2022-09-01 ARM metadata. + # "dataplaneEndpoints" does not appear in arm_metadata for public and AGC if "dataplaneEndpoints" in arm_metadata: if "arcConfigEndpoint" in arm_metadata["dataplaneEndpoints"]: notification_endpoint = arm_metadata["dataplaneEndpoints"][ @@ -1364,6 +1365,10 @@ def helm_install_release( "'arcConfigEndpoint' doesn't exist under 'dataplaneEndpoints' in the ARM metadata." ) + # Add overrides for AGC Scenario + if cloud_name.lower() == "ussec" or cloud_name.lower() == "usnat": + add_agc_endpoint_overrides(location, cloud_name, arm_metadata, cmd_helm_install) + # Add helmValues content response from DP cmd_helm_install = parse_helm_values(helm_content_values, cmd_helm=cmd_helm_install) @@ -1839,3 +1844,51 @@ def helm_update_agent( logger.info(str.format(consts.Update_Agent_Success, cluster_name)) with contextlib.suppress(OSError): os.remove(user_values_location) + + +def add_agc_endpoint_overrides( + location: str, + cloud_name: str, + arm_metadata: dict[str, Any], + cmd_helm_install: list[str], +) -> None: + logger.debug("Adding AGC scenario overrides.") + + arm_metadata_endpoint_array = ( + arm_metadata["authentication"]["loginEndpoint"].strip("/").split(".") + ) + if len(arm_metadata_endpoint_array) < 4: + raise CLIInternalError("Unexpected loginEndpoint format for AGC") + + cloud_suffix = arm_metadata_endpoint_array[3] + endpoint_suffix = ( + arm_metadata_endpoint_array[2] + "." + arm_metadata_endpoint_array[3] + ) + if cloud_name.lower() == "usnat": + cloud_suffix = ( + arm_metadata_endpoint_array[2] + + "." + + arm_metadata_endpoint_array[3] + + "." + + arm_metadata_endpoint_array[4] + ) + endpoint_suffix = cloud_suffix + + cmd_helm_install.extend( + [ + "--set", + f"global.microsoftArtifactRepository=mcr.microsoft.{cloud_suffix}", + "--set", + f"systemDefaultValues.activeDirectoryEndpoint=https://login.microsoftonline.{endpoint_suffix}", + "--set", + f"systemDefaultValues.azureArcAgents.config_dp_endpoint_override=https://{location}.dp.kubernetesconfiguration.azure.{endpoint_suffix}", + "--set", + f"systemDefaultValues.clusterconnect-agent.notification_dp_endpoint_override=https://guestnotificationservice.azure.{endpoint_suffix}", + "--set", + f"systemDefaultValues.clusterconnect-agent.relay_endpoint_suffix_override=.servicebus.cloudapi.{endpoint_suffix}", + "--set", + f"systemDefaultValues.clusteridentityoperator.his_endpoint_override=https://gbl.his.arc.azure.{endpoint_suffix}/discovery?location={location}&api-version=1.1-preview", + "--set", + f"systemDefaultValues.image.repository=mcr.microsoft.{cloud_suffix}", + ] + )