Skip to content
Merged
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
53 changes: 53 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"][
Expand Down Expand Up @@ -1364,6 +1365,10 @@ def helm_install_release(
"'arcConfigEndpoint' doesn't exist under 'dataplaneEndpoints' in the ARM metadata."
)

# Add overrides for AGC Scenario

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it not pass cmd_helm_install.extend with both the public and azc given the public ones are above this. would it be better to do if else..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above if condition does not execute in AGC so this should be fine

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)

Expand Down Expand Up @@ -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}",
]
)
Loading