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
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.3.7
++++++

* Install new helm release in azure-arc-release NS

1.3.6
++++++

Expand Down
1 change: 1 addition & 0 deletions src/connectedk8s/azext_connectedk8s/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Dogfood_RMEndpoint = 'https://api-dogfood.resources.windows-int.net/'
Client_Request_Id_Header = 'x-ms-client-request-id'
Default_Onboarding_Source_Tracking_Guid = "77ade16b-0f55-403b-b7d2-739554a897f2"
Release_Install_Namespace = "azure-arc-release"
Helm_Environment_File_Fault_Type = 'helm-environment-file-error'
Invalid_Location_Fault_Type = 'location-validation-error'
Pls_Location_Mismatch_Fault_Type = 'pls-location-mismatch-error'
Expand Down
3 changes: 3 additions & 0 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def delete_arc_agents(release_namespace, kube_config, kube_context, helm_client_
ensure_namespace_cleanup()


# DO NOT use this method for re-put scenarios. This method involves new NS creation for helm release. For re-put scenarios, brownfield scenario needs to be handled where helm release still stays in default NS
def helm_install_release(chart_path, subscription_id, kubernetes_distro, kubernetes_infra, resource_group_name, cluster_name,
location, onboarding_tenant_id, http_proxy, https_proxy, no_proxy, proxy_cert, private_key_pem,
kube_config, kube_context, no_wait, values_file_provided, values_file, cloud_name, disable_auto_upgrade,
Expand All @@ -308,6 +309,8 @@ def helm_install_release(chart_path, subscription_id, kubernetes_distro, kuberne
"--set", "systemDefaultValues.spnOnboarding=false",
"--set", "global.azureEnvironment={}".format(cloud_name),
"--set", "systemDefaultValues.clusterconnect-agent.enabled=true",
"--namespace", "{}".format(consts.Release_Install_Namespace),
"--create-namespace",
"--output", "json"]
# Add custom-locations related params
if enable_custom_locations and not enable_private_link:
Expand Down
38 changes: 4 additions & 34 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, correlat
except Exception as e: # pylint: disable=broad-except
utils.kubernetes_exception_handler(e, consts.Read_ConfigMap_Fault_Type, 'Unable to read ConfigMap',
error_message="Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: ",
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --no-hooks' to cleanup the release before onboarding the cluster again.")
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --namespace {} --no-hooks' to cleanup the release before onboarding the cluster again.".format(release_namespace))
configmap_rg_name = configmap.data["AZURE_RESOURCE_GROUP"]
configmap_cluster_name = configmap.data["AZURE_RESOURCE_NAME"]
if connected_cluster_exists(client, configmap_rg_name, configmap_cluster_name):
Expand Down Expand Up @@ -242,36 +242,6 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, correlat
"and corresponds to a different Kubernetes cluster.", recommendation="To onboard this Kubernetes cluster " +
"to Azure, specify different resource name or resource group name.")

try:
k8s_contexts = config.list_kube_config_contexts() # returns tuple of (all_contexts, current_context)
if kube_context: # if custom kube-context is specified
if k8s_contexts[1].get('name') == kube_context:
current_k8s_context = k8s_contexts[1]
else:
for context in k8s_contexts[0]:
if context.get('name') == kube_context:
current_k8s_context = context
break
else:
current_k8s_context = k8s_contexts[1]

current_k8s_namespace = current_k8s_context.get('context').get('namespace', "default") # Take "default" namespace, if not specified in the kube-config
namespace_exists = False
k8s_v1 = kube_client.CoreV1Api()
k8s_ns = k8s_v1.list_namespace()
for ns in k8s_ns.items:
if ns.metadata.name == current_k8s_namespace:
namespace_exists = True
break
if namespace_exists is False:
telemetry.set_exception(exception="Namespace doesn't exist", fault_type=consts.Default_Namespace_Does_Not_Exist_Fault_Type,
summary="The default namespace defined in the kubeconfig doesn't exist on the kubernetes cluster.")
raise ValidationError("The default namespace '{}' defined in the kubeconfig doesn't exist on the kubernetes cluster.".format(current_k8s_namespace))
except ValidationError as e:
raise e
except Exception as e:
logger.warning("Failed to validate if the active namespace exists on the kubernetes cluster. Exception: {}".format(str(e)))

# Resource group Creation
if resource_group_exists(cmd.cli_ctx, resource_group_name, subscription_id) is False:
from azure.cli.core.profiles import ResourceType
Expand Down Expand Up @@ -816,7 +786,7 @@ def delete_connectedk8s(cmd, client, resource_group_name, cluster_name,
except Exception as e: # pylint: disable=broad-except
utils.kubernetes_exception_handler(e, consts.Read_ConfigMap_Fault_Type, 'Unable to read ConfigMap',
error_message="Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: ",
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --no-hooks' to cleanup the release before onboarding the cluster again.")
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --namepace {} --no-hooks' to cleanup the release before onboarding the cluster again.".format(release_namespace))

subscription_id = get_subscription_id(cmd.cli_ctx)

Expand Down Expand Up @@ -1138,7 +1108,7 @@ def upgrade_agents(cmd, client, resource_group_name, cluster_name, kube_config=N
except Exception as e: # pylint: disable=broad-except
utils.kubernetes_exception_handler(e, consts.Read_ConfigMap_Fault_Type, 'Unable to read ConfigMap',
error_message="Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: ",
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --no-hooks' to cleanup the release before onboarding the cluster again.")
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --namespace {} --no-hooks' to cleanup the release before onboarding the cluster again.".format(release_namespace))
configmap_rg_name = configmap.data["AZURE_RESOURCE_GROUP"]
configmap_cluster_name = configmap.data["AZURE_RESOURCE_NAME"]
if connected_cluster_exists(client, configmap_rg_name, configmap_cluster_name):
Expand Down Expand Up @@ -1294,7 +1264,7 @@ def validate_release_namespace(client, cluster_name, resource_group_name, kube_c
except Exception as e: # pylint: disable=broad-except
utils.kubernetes_exception_handler(e, consts.Read_ConfigMap_Fault_Type, 'Unable to read ConfigMap',
error_message="Unable to read ConfigMap 'azure-clusterconfig' in 'azure-arc' namespace: ",
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --no-hooks' to cleanup the release before onboarding the cluster again.")
message_for_not_found="The helm release 'azure-arc' is present but the azure-arc namespace/configmap is missing. Please run 'helm delete azure-arc --namespace {} --no-hooks' to cleanup the release before onboarding the cluster again.".format(release_namespace))
configmap_rg_name = configmap.data["AZURE_RESOURCE_GROUP"]
configmap_cluster_name = configmap.data["AZURE_RESOURCE_NAME"]
if connected_cluster_exists(client, configmap_rg_name, configmap_cluster_name):
Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.3.6'
VERSION = '1.3.7'

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