Skip to content

Commit 88009c6

Browse files
authored
update to support disconnected environment (#7588)
1 parent c9bcbe2 commit 88009c6

File tree

6 files changed

+71
-56
lines changed

6 files changed

+71
-56
lines changed

src/connectedk8s/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
1.10.2
7+
++++++
8+
* Update for disconnected environment scenario.
9+
610
1.10.1
711
++++++
812
* Fixed an issue where the proxy settings were not disabled when the 'disable_proxy' parameter was provided in the update command.

src/connectedk8s/azext_connectedk8s/_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,8 @@ def helm_install_release(
12131213
helm_client_location,
12141214
enable_private_link,
12151215
arm_metadata,
1216+
registry_path,
1217+
aad_identity_principal_id,
12161218
onboarding_timeout=consts.DEFAULT_MAX_ONBOARDING_TIMEOUT_HELMVALUE_SECONDS,
12171219
helm_content_values=None,
12181220
):
@@ -1258,8 +1260,16 @@ def helm_install_release(
12581260
)
12591261
relay_endpoint = arm_metadata["suffixes"]["relayEndpointSuffix"]
12601262
active_directory = arm_metadata["authentication"]["loginEndpoint"]
1263+
if not aad_identity_principal_id:
1264+
raise CLIInternalError("Failed to create the kubeAadEndpoint endpoint. The identity principal ID of "
1265+
"the created connected cluster is empty.")
1266+
kube_aad_endpoint = f"{aad_identity_principal_id}.k8sproxysvc.connectrp.azs"
12611267
cmd_helm_install.extend(
12621268
[
1269+
"--set",
1270+
"global.kubeAadEndpoint={}".format(
1271+
kube_aad_endpoint
1272+
),
12631273
"--set",
12641274
"systemDefaultValues.azureResourceManagerEndpoint={}".format(
12651275
resource_manager
@@ -1284,6 +1294,10 @@ def helm_install_release(
12841294
"systemDefaultValues.activeDirectoryEndpoint={}".format(
12851295
active_directory
12861296
),
1297+
"--set",
1298+
"systemDefaultValues.image.repository={}".format(
1299+
registry_path.split("/")[0]
1300+
),
12871301
]
12881302
)
12891303
else:

src/connectedk8s/azext_connectedk8s/custom.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ def create_connectedk8s(
301301
):
302302
lowbandwidth = True
303303

304+
azure_local_disconnected = False
305+
if os.getenv("AZURE_LOCAL_DISCONNECTED") == "true":
306+
azure_local_disconnected = True
307+
304308
# Install kubectl and helm
305309
try:
306310
kubectl_client_location = install_kubectl_client()
@@ -316,8 +320,8 @@ def create_connectedk8s(
316320
# Pre onboarding checks
317321
diagnostic_checks = "Failed"
318322
try:
319-
# if aks_hci lowbandwidth scenario skip, otherwise continue to perform pre-onboarding check
320-
if not lowbandwidth:
323+
# if aks_hci lowbandwidth scenario or Azure local disconnected, skip, otherwise continue pre-onboarding check.
324+
if not azure_local_disconnected and not lowbandwidth:
321325
print(
322326
"Step: {}: Starting Pre-onboarding-check".format(
323327
utils.get_utctimestring()
@@ -406,7 +410,7 @@ def create_connectedk8s(
406410
raise ManualInterrupt("Process terminated externally.")
407411

408412
# If the checks didnt pass then stop the onboarding
409-
if diagnostic_checks != consts.Diagnostic_Check_Passed and lowbandwidth is False:
413+
if diagnostic_checks != consts.Diagnostic_Check_Passed and not azure_local_disconnected and not lowbandwidth:
410414
if storage_space_available:
411415
logger.warning(
412416
"The pre-check result logs logs have been saved at this path: "
@@ -439,7 +443,7 @@ def create_connectedk8s(
439443
)
440444
raise ValidationError(err_msg)
441445

442-
if lowbandwidth is False:
446+
if not azure_local_disconnected and not lowbandwidth:
443447
print(
444448
"Step: {}: The required pre-checks for onboarding have succeeded.".format(
445449
utils.get_utctimestring()
@@ -985,6 +989,8 @@ def create_connectedk8s(
985989
helm_client_location,
986990
enable_private_link,
987991
arm_metadata,
992+
registry_path,
993+
put_cc_response.identity.principal_id,
988994
onboarding_timeout,
989995
helm_content_values,
990996
)
@@ -3203,7 +3209,7 @@ def disable_features(
32033209
)
32043210
if not disable_cl and cl_enabled is True and cl_oid != "":
32053211
raise Exception(
3206-
"Disabling 'cluster-connect' feature is not allowed when 'custom-locations' feature is enabled"
3212+
"Disabling 'cluster-connect' feature is not allowed when 'custom-locations' feature is enabled."
32073213
)
32083214
except AttributeError:
32093215
pass
@@ -3723,6 +3729,13 @@ def client_side_proxy_wrapper(
37233729
# initializations
37243730
user_type = "sat"
37253731
creds = ""
3732+
dict_file = {
3733+
"server": {
3734+
"httpPort": int(client_proxy_port),
3735+
"httpsPort": int(api_server_port)
3736+
},
3737+
"identity": {"tenantID": tenant_id}
3738+
}
37263739

37273740
# if service account token is not passed
37283741
if token is None:
@@ -3732,35 +3745,9 @@ def client_side_proxy_wrapper(
37323745
user_type = account["user"]["type"]
37333746

37343747
if user_type == "user":
3735-
dict_file = {
3736-
"server": {
3737-
"httpPort": int(client_proxy_port),
3738-
"httpsPort": int(api_server_port),
3739-
},
3740-
"identity": {
3741-
"tenantID": tenant_id,
3742-
"clientID": consts.CLIENTPROXY_CLIENT_ID,
3743-
},
3744-
}
3748+
dict_file["identity"]["clientID"] = consts.CLIENTPROXY_CLIENT_ID
37453749
else:
3746-
dict_file = {
3747-
"server": {
3748-
"httpPort": int(client_proxy_port),
3749-
"httpsPort": int(api_server_port),
3750-
},
3751-
"identity": {
3752-
"tenantID": tenant_id,
3753-
"clientID": account["user"]["name"],
3754-
},
3755-
}
3756-
3757-
if cloud == "DOGFOOD":
3758-
dict_file["cloud"] = "AzureDogFood"
3759-
3760-
if cloud == consts.Azure_ChinaCloudName:
3761-
dict_file["cloud"] = "AzureChinaCloud"
3762-
elif cloud == consts.Azure_USGovCloudName:
3763-
dict_file["cloud"] = "AzureUSGovernmentCloud"
3750+
dict_file["identity"]["clientID"] = account["user"]["name"]
37643751

37653752
if not utils.is_cli_using_msal_auth():
37663753
# Fetching creds
@@ -3802,17 +3789,27 @@ def client_side_proxy_wrapper(
38023789

38033790
if user_type != "user":
38043791
dict_file["identity"]["clientSecret"] = creds
3792+
3793+
if cloud == "DOGFOOD":
3794+
dict_file["cloud"] = "AzureDogFood"
3795+
elif cloud == consts.Azure_ChinaCloudName:
3796+
dict_file["cloud"] = "AzureChinaCloud"
3797+
elif cloud == consts.Azure_USGovCloudName:
3798+
dict_file["cloud"] = "AzureUSGovernmentCloud"
38053799
else:
3806-
dict_file = {
3807-
"server": {
3808-
"httpPort": int(client_proxy_port),
3809-
"httpsPort": int(api_server_port),
3810-
}
3811-
}
3812-
if cloud == consts.Azure_ChinaCloudName:
3813-
dict_file["cloud"] = "AzureChinaCloud"
3814-
elif cloud == consts.Azure_USGovCloudName:
3815-
dict_file["cloud"] = "AzureUSGovernmentCloud"
3800+
dict_file["cloud"] = cloud
3801+
3802+
# Azure local configurations.
3803+
arm_metadata = utils.get_metadata(cmd.cli_ctx.cloud.endpoints.resource_manager)
3804+
if "dataplaneEndpoints" in arm_metadata:
3805+
dict_file["cloudConfig"] = {}
3806+
dict_file["cloudConfig"]["resourceManagerEndpoint"] = arm_metadata["resourceManager"]
3807+
relay_endpoint_suffix = arm_metadata["suffixes"]["relayEndpointSuffix"]
3808+
if relay_endpoint_suffix[0] == ".":
3809+
dict_file["cloudConfig"]["serviceBusEndpointSuffix"] = (relay_endpoint_suffix)[1:]
3810+
else:
3811+
dict_file["cloudConfig"]["serviceBusEndpointSuffix"] = relay_endpoint_suffix
3812+
dict_file["cloudConfig"]["activeDirectoryEndpoint"] = arm_metadata["authentication"]["loginEndpoint"]
38163813

38173814
telemetry.set_debug_info("User type is ", user_type)
38183815

@@ -4658,6 +4655,9 @@ def install_kubectl_client():
46584655
)
46594656
)
46604657
# Return kubectl client path set by user
4658+
if os.getenv("KUBECTL_CLIENT_PATH"):
4659+
return os.getenv("KUBECTL_CLIENT_PATH")
4660+
46614661
try:
46624662
# Fetching the current directory where the cli installs the kubectl executable
46634663
home_dir = os.path.expanduser("~")
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Connectedk8s Testing
2-
Tests need to be configured before running.
3-
4-
1. Make a copy of `config.json.dist` and rename it to `config.json` (the config.json is git ignored).
5-
1. Fill in the details of the newly created `config.json` file:
6-
- Note that the code doesn't verify that you have a valid RBAC service principal application, so a fake one can be used for testing.
7-
- `customLocationsOid`: The custom locations RP service principal object ID for enabling the custom locations feature.
8-
- `rbacAppId`: The RBAC service principal app ID for testing RBAC feature.
9-
- `rbacAppSecret`: The RBAC service principal secret for testing RBAC feature.
10-
1. Please make sure to test using a service principal with minimal privileges to replicate customer scenarios.
1+
# Connectedk8s Testing
2+
3+
Tests need to be configured before running.
4+
5+
1. Make a copy of `config.json.dist` and rename it to `config.json` (the config.json is git ignored).
6+
1. Fill in the details of the newly created `config.json` file:
7+
- Note that the code doesn't verify that you have a valid RBAC service principal application, so a fake one can be used for testing.
8+
- `customLocationsOid`: The custom locations RP service principal object ID for enabling the custom locations feature.
9+
1. Please make sure to test using a service principal with minimal privileges to replicate customer scenarios.
1110
- Make sure you test with a service principal without Graph API permissions, as some customers don't expect to need it.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"customLocationsOid": "",
3-
"rbacAppId": "",
4-
"rbacAppSecret": "",
53
"location": "eastus2euap"
64
}

src/connectedk8s/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# TODO: Confirm this is the right version number you want and it matches your
1414
# HISTORY.rst entry.
1515

16-
VERSION = "1.10.1"
16+
VERSION = "1.10.2"
1717

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

0 commit comments

Comments
 (0)