Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

/src/ip-group/ @necusjz @kairu-ms @jsntcy

/src/connectedk8s/ @bavneetsingh16 @deeksha345 @anagg929
/src/connectedk8s/ @bavneetsingh16 @deeksha345 @anagg929 @atchutbarli

/src/storagesync/ @jsntcy

Expand Down
5 changes: 5 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Release History
===============
1.10.8
++++++
* Force delete parameter updated to `connectedk8s delete` command to allow force deletion of connectedk8s ARM resource.
* Parameterize the MCR url for Airgapped clouds.
* Update error strings for config and connectivity errors in connect command.

1.10.7
++++++
Expand Down
28 changes: 18 additions & 10 deletions src/connectedk8s/azext_connectedk8s/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
AHB_Enum_Values = ["True", "False", "NotApplicable"]
Feature_Values = ["cluster-connect", "azure-rbac", "custom-locations"]
CRD_FOR_FORCE_DELETE = [
"arccertificates.clusterconfig.azure.com",
"azureclusteridentityrequests.clusterconfig.azure.com",
"azureextensionidentities.clusterconfig.azure.com",
"connectedclusters.arc.azure.com",
"customlocationsettings.clusterconfig.azure.com",
"extensionconfigs.clusterconfig.azure.com",
"gitconfigs.clusterconfig.azure.com",
"arccertificates.clusterconfig.azure",
"azureclusteridentityrequests.clusterconfig.azure",
"azureextensionidentities.clusterconfig.azure",
"connectedclusters.arc.azure",
"customlocationsettings.clusterconfig.azure",
"extensionconfigs.clusterconfig.azure",
"gitconfigs.clusterconfig.azure",
]
Helm_Install_Release_Userfault_Messages = [
"forbidden",
Expand Down Expand Up @@ -418,7 +418,7 @@

# Connect Precheck Diagnoser constants
Cluster_Diagnostic_Checks_Job_Registry_Path = (
"mcr.microsoft.com/azurearck8s/helmchart/stable/clusterdiagnosticchecks:0.2.2"
"azurearck8s/helmchart/stable/clusterdiagnosticchecks:0.2.2"
)
Cluster_Diagnostic_Checks_Helm_Install_Failed_Fault_Type = (
"Error while installing cluster diagnostic checks helm release"
Expand Down Expand Up @@ -460,6 +460,14 @@

Custom_Location_Enable_Failed_warning = """Important! Custom Location feature wasn't enabled due to insufficient privileges on the Service Principal Name. If the custom location feature is not enabled, you will encounter an error when creating the custom location. Refer to: https://aka.ms/enable-cl-spn"""

KubeApi_Connectivity_Failed_Warning = """Unable to verify connectivity to the Kubernetes cluster.
Please check https://learn.microsoft.com/en-us/azure/azure-arc/kubernetes/diagnose-connection-issues"""

Kubeconfig_Load_Failed_Warning = """Unable to load the kubeconfig file.
Please check https://learn.microsoft.com/en-us/azure/azure-arc/kubernetes/diagnose-connection-issues#is-kubeconfig-pointing-to-the-right-cluster"""

Cluster_Already_Onboarded_Error = """The kubernetes cluster is already onboarded.
Please check if the Kubeconfig is pointing to the correct cluster using command: kubectl config current-context."""

# Diagnostic Results Name
Outbound_Connectivity_Check_Result_String = "Outbound Network Connectivity"
Expand All @@ -481,8 +489,8 @@
DEFAULT_MAX_ONBOARDING_TIMEOUT_HELMVALUE_SECONDS = "1200"

# URL constants
CLIENT_PROXY_MCR_TARGET = "mcr.microsoft.com/azureconnectivity/proxy"
HELM_MCR_URL = "mcr.microsoft.com/azurearck8s/helm"
CLIENT_PROXY_MCR_TARGET = "azureconnectivity/proxy"
HELM_MCR_URL = "azurearck8s/helm"
HELM_VERSION = "v3.12.2"
Download_And_Install_Kubectl_Fault_Type = "Failed to download and install kubectl"
Azure_Access_Token_Variable = "AZURE_ACCESS_TOKEN"
Expand Down
8 changes: 7 additions & 1 deletion src/connectedk8s/azext_connectedk8s/_precheckutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import azext_connectedk8s._utils as azext_utils

if TYPE_CHECKING:
from knack.commands import CLICommand
from kubernetes.client import BatchV1Api, CoreV1Api

logger = get_logger(__name__)
Expand All @@ -30,6 +31,7 @@


def fetch_diagnostic_checks_results(
cmd: CLICommand,
corev1_api_instance: CoreV1Api,
batchv1_api_instance: BatchV1Api,
helm_client_location: str,
Expand All @@ -52,6 +54,7 @@ def fetch_diagnostic_checks_results(
# Executing the cluster_diagnostic_checks job and fetching the logs obtained
cluster_diagnostic_checks_container_log = (
executing_cluster_diagnostic_checks_job(
cmd,
corev1_api_instance,
batchv1_api_instance,
helm_client_location,
Expand Down Expand Up @@ -135,6 +138,7 @@ def fetch_diagnostic_checks_results(


def executing_cluster_diagnostic_checks_job(
cmd: CLICommand,
corev1_api_instance: CoreV1Api,
batchv1_api_instance: BatchV1Api,
helm_client_location: str,
Expand Down Expand Up @@ -208,8 +212,10 @@ def executing_cluster_diagnostic_checks_job(
)
return None

mcr_url = azext_utils.get_mcr_path(cmd)

chart_path = azext_utils.get_chart_path(
consts.Cluster_Diagnostic_Checks_Job_Registry_Path,
f"{mcr_url}/{consts.Cluster_Diagnostic_Checks_Job_Registry_Path}",
kube_config,
kube_context,
helm_client_location,
Expand Down
23 changes: 23 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@
# pylint: disable=bare-except


def get_mcr_path(cmd: CLICommand) -> str:
active_directory_array = cmd.cli_ctx.cloud.endpoints.active_directory.split(".")

# default for public, mc, ff clouds
mcr_postfix = active_directory_array[2]
# special cases for USSec, exclude part of suffix
if len(active_directory_array) == 4 and active_directory_array[2] == "microsoft":
mcr_postfix = active_directory_array[3]
# special case for USNat
elif len(active_directory_array) == 5:
mcr_postfix = (
active_directory_array[2]
+ "."
+ active_directory_array[3]
+ "."
+ active_directory_array[4]
)

mcr_url = f"mcr.microsoft.{mcr_postfix}"
return mcr_url


def validate_connect_rp_location(cmd: CLICommand, location: str) -> None:
subscription_id = (
os.getenv("AZURE_SUBSCRIPTION_ID")
Expand Down Expand Up @@ -1332,6 +1354,7 @@ def helm_install_release(
"Please check if the azure-arc namespace was deployed and run 'kubectl get pods -n azure-arc' "
"to check if all the pods are in running state. A possible cause for pods stuck in pending "
"state could be insufficient resources on the kubernetes cluster to onboard to arc."
" Also pod logs can be checked using kubectl logs <pod-name> -n azure-arc.\n"
)
logger.warning(warn_msg)
raise CLIInternalError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
from azure.cli.core import azclierror, telemetry
from azure.cli.core.style import Style, print_styled_text
from knack import log
from knack.commands import CLICommand

import azext_connectedk8s._constants as consts
import azext_connectedk8s._fileutils as file_utils
import azext_connectedk8s._utils as utils

logger = log.get_logger(__name__)


# Downloads client side proxy to connect to Arc Connectivity Platform
def install_client_side_proxy(
arc_proxy_folder: Optional[str], debug: bool = False
cmd: CLICommand, arc_proxy_folder: Optional[str], debug: bool = False
) -> str:
client_operating_system = _get_client_operating_system()
client_architecture = _get_client_architeture()
Expand All @@ -48,7 +50,11 @@ def install_client_side_proxy(
)

_download_proxy_from_MCR(
install_dir, proxy_name, client_operating_system, client_architecture
cmd,
install_dir,
proxy_name,
client_operating_system,
client_architecture,
)
_check_proxy_installation(install_dir, proxy_name, debug)

Expand All @@ -64,15 +70,21 @@ def install_client_side_proxy(


def _download_proxy_from_MCR(
dest_dir: str, proxy_name: str, operating_system: str, architecture: str
cmd: CLICommand,
dest_dir: str,
proxy_name: str,
operating_system: str,
architecture: str,
) -> None:
mar_target = f"{consts.CLIENT_PROXY_MCR_TARGET}/{operating_system.lower()}/{architecture}/arc-proxy"
mcr_url = utils.get_mcr_path(cmd)

mar_target = f"{mcr_url}/{consts.CLIENT_PROXY_MCR_TARGET}/{operating_system.lower()}/{architecture}/arc-proxy"
logger.debug(
"Downloading Arc Connectivity Proxy from %s in Microsoft Artifact Regristy.",
mar_target,
)

client = oras.client.OrasClient()
client = oras.client.OrasClient(hostname=mcr_url)
t0 = time.time()

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if TYPE_CHECKING:
from subprocess import Popen

from knack.commands import CLICommmand
from knack.commands import CLICommand
from requests.models import Response

from azext_connectedk8s.vendored_sdks.preview_2024_07_01.models import (
Expand All @@ -30,7 +30,7 @@


def handle_post_at_to_csp(
cmd: CLICommmand,
cmd: CLICommand,
api_server_port: int,
tenant_id: str,
clientproxy_process: Popen[bytes],
Expand Down
Loading
Loading