Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cli to support arc gateway and workload identity #7822

Merged
merged 74 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
30ad18d
update cli to support arc gateway
Jul 23, 2024
c2d32ce
update the version and history doc
Jul 23, 2024
855b398
fix CI style issues reported
Jul 23, 2024
9642364
fix dp request body format issue
Jul 24, 2024
e76b020
use serialization instead of as_dict
Jul 24, 2024
755c651
use serialization instead of as_dict for update function
Jul 24, 2024
2025464
update variable name
Jul 24, 2024
4f087e3
add preview flag for new params
Jul 24, 2024
44a6b73
add validation for cli params
Jul 24, 2024
e6b601b
add examples cmd to use gateway
Jul 24, 2024
13e0bcb
fixes when no config or config protected settings are passed
Jul 25, 2024
7585ae1
pass id to dp
Jul 25, 2024
f13926c
fix dp request body details
Jul 25, 2024
9ce33d8
fix dp request body details
Jul 25, 2024
cb24396
fix error message
Jul 26, 2024
c82574a
remove redundant entry for helm content values
Jul 30, 2024
658ebe7
allow update to gateway enablement
dimbleby Jul 31, 2024
64c521f
rePUT should only change things it cares about
dimbleby Jul 31, 2024
1d55e60
Merge pull request #2 from dimbleby/arc-gateway-fixes
bavneetsingh16 Jul 31, 2024
51601a2
fix upgrade scenarios
Aug 2, 2024
125d4ea
fix proxy param issues
Aug 2, 2024
542dcbd
fix proxy param issues
Aug 2, 2024
da72f13
add fixes for wif
deeksha345 Aug 5, 2024
030db6a
updating setup and history
deeksha345 Aug 6, 2024
9fc7d35
fixing generate payload
deeksha345 Aug 6, 2024
7fba1f4
fixing null issue
deeksha345 Aug 6, 2024
91ea337
Merge pull request #3 from bavneetsingh16/deesharma/wiffixes
deeksha345 Aug 6, 2024
6854c5a
pull upstream changes
Aug 6, 2024
ff894ba
update print stmts
Aug 8, 2024
22a1f9b
remove redundant cli param
Aug 20, 2024
ba4a4e0
fix issue for removing azure-arc-release namespace
Aug 20, 2024
78bcad7
fix connect+connect scenario
Aug 20, 2024
6996701
logic change to handle configuration protected settings
Aug 28, 2024
e14b9cf
merge latest changes
Aug 28, 2024
769a74d
change for redacted protected settings
Aug 29, 2024
a003282
update troubleshooting for connectedk8s
Aug 30, 2024
1a7eb88
update az troubleshoot for workload identity
deeksha345 Sep 3, 2024
f30ad87
Merge pull request #7 from bavneetsingh16/deesharma/aztroubleshootupdate
deeksha345 Sep 3, 2024
989dd1f
add provider registration check for hybrid compute for gateway feature
Sep 3, 2024
75e2218
replace msrestazure with azure.core
Sep 4, 2024
f2da411
adding registration check for wif
deeksha345 Sep 4, 2024
0e22b09
Merge pull request #8 from bavneetsingh16/deesharma/providerregistration
bavneetsingh16 Sep 4, 2024
3f5ac06
ruff formatting
dimbleby Aug 30, 2024
6bd9e61
ruff autofixes
dimbleby Aug 30, 2024
52feb8c
ruff manual fixes
dimbleby Aug 23, 2024
2ed189a
miscellaneous fixes
dimbleby Aug 28, 2024
45d94ed
s/diganostic/diagnostic
dimbleby Aug 30, 2024
9896cd9
remove unwanted parameter
dimbleby Sep 4, 2024
a02462b
Merge pull request #6 from dimbleby/linting
bavneetsingh16 Sep 4, 2024
3edbb19
fix kubectl silent failure issue and change redacted param split logic
Sep 4, 2024
c9cd95c
add_config_protected_settings parameters in wrong order
dimbleby Sep 5, 2024
ed169b3
Merge pull request #9 from dimbleby/fix-proxy-order
bavneetsingh16 Sep 5, 2024
c7c55cc
Relax RP registration checks
sardobi Sep 11, 2024
951dd74
adding proper checks for self hosted issuer parameter
deeksha345 Sep 19, 2024
11a7163
Merge pull request #11 from bavneetsingh16/deesharma/selfhostedissuer…
deeksha345 Sep 20, 2024
e84a2c9
missing imports, undefined variables
dimbleby Sep 24, 2024
0aac632
reinstate three-state-flag
dimbleby Sep 26, 2024
f32c978
make it possible to disable workload identity
dimbleby Sep 26, 2024
744c31a
disallow disabling OIDC issuer
dimbleby Sep 26, 2024
72829b0
Merge pull request #12 from dimbleby/missing-imports
bavneetsingh16 Sep 26, 2024
41dd3b1
fix autoUpdate issue
Sep 26, 2024
624b35b
Merge branch 'feature/arc_gateway' of https://github.com/bavneetsingh…
Sep 26, 2024
d580517
small update
deeksha345 Sep 26, 2024
5f05484
add preview flag for gateway
Sep 26, 2024
9fa5859
Merge branch 'feature/arc_gateway' of https://github.com/bavneetsingh…
Sep 26, 2024
46ffbe3
Merge pull request #10 from sardobi/joedouble/relax-rp-registration-c…
bavneetsingh16 Sep 27, 2024
e3bf7cd
update codeowners file
Sep 27, 2024
1d36c24
Merge branch 'feature/arc_gateway' of https://github.com/bavneetsingh…
Sep 27, 2024
984506f
update pycryptodome
Sep 27, 2024
f0a9346
add preview flag to gateway_resource_id in create cmd
Sep 27, 2024
b8a302c
update help and release notes
Sep 30, 2024
0d47300
merge upstream changes
Oct 8, 2024
f9d89f9
suggested review changes
Oct 9, 2024
24c1e05
get helm chart value from dp if null
Oct 9, 2024
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

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

/src/connectedk8s/ @akashkeshari @sirireddy12
/src/connectedk8s/ @bavneetsingh16 @deeksha345 @anagg929

/src/storagesync/ @jsntcy

Expand Down
7 changes: 7 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

1.10.0
++++++
* Added support for arc gateway feature.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Added support for arc gateway feature.
* Add support for arc gateway feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is better to specify which commands/parameters are impacted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks for reviewing!

* Bug fix for Workload Identity poll or agent state.
* Bug fix for connectedk8s update with workload identity enabled.
* Update pycryptodome to 3.20.0.

1.9.3
++++++
* Removed a workaround that is no longer needed after updating to MSAL 1.30.0+
Expand Down
21 changes: 16 additions & 5 deletions src/connectedk8s/azext_connectedk8s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@

from azure.cli.core import AzCommandsLoader

from azext_connectedk8s._help import helps # pylint: disable=unused-import
from azext_connectedk8s._help import helps


class Connectedk8sCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_connectedk8s._client_factory import cf_connectedk8s

connectedk8s_custom = CliCommandType(
operations_tmpl='azext_connectedk8s.custom#{}',
client_factory=cf_connectedk8s)
super(Connectedk8sCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=connectedk8s_custom)
operations_tmpl="azext_connectedk8s.custom#{}",
client_factory=cf_connectedk8s,
)
super(Connectedk8sCommandsLoader, self).__init__(
cli_ctx=cli_ctx, custom_command_type=connectedk8s_custom
)

def load_command_table(self, args):
from azext_connectedk8s.commands import load_command_table

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_connectedk8s._params import load_arguments

load_arguments(self, command)


COMMAND_LOADER_CLS = Connectedk8sCommandsLoader

__all__ = [
"helps",
"Connectedk8sCommandsLoader",
"COMMAND_LOADER_CLS",
]
139 changes: 92 additions & 47 deletions src/connectedk8s/azext_connectedk8s/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@

from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.core.profiles import ResourceType
from azure.cli.core._profile import Profile
from azure.cli.core import telemetry
from azure.cli.core.azclierror import ValidationError
from azure.cli.core.commands.client_factory import configure_common_settings
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.graphrbac import GraphRbacManagementClient

import os
import requests
Expand All @@ -22,12 +18,18 @@

def cf_connectedk8s(cli_ctx, *_):
from azext_connectedk8s.vendored_sdks import ConnectedKubernetesClient

if os.getenv(consts.Azure_Access_Token_Variable):
validate_custom_token()
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient,
subscription_id=os.getenv('AZURE_SUBSCRIPTION_ID'),
credential=credential)
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
ConnectedKubernetesClient,
subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
credential=credential,
)
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient)


Expand All @@ -36,13 +38,21 @@ def cf_connected_cluster(cli_ctx, _):


def cf_connectedk8s_prev_2022_10_01(cli_ctx, *_):
from azext_connectedk8s.vendored_sdks.preview_2022_10_01 import ConnectedKubernetesClient
from azext_connectedk8s.vendored_sdks.preview_2022_10_01 import (
ConnectedKubernetesClient,
)

if os.getenv(consts.Azure_Access_Token_Variable):
validate_custom_token()
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient,
subscription_id=os.getenv('AZURE_SUBSCRIPTION_ID'),
credential=credential)
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
ConnectedKubernetesClient,
subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
credential=credential,
)
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient)


Expand All @@ -51,56 +61,87 @@ def cf_connected_cluster_prev_2022_10_01(cli_ctx, _):


def cf_connectedk8s_prev_2023_11_01(cli_ctx, *_):
from azext_connectedk8s.vendored_sdks.preview_2023_11_01 import ConnectedKubernetesClient
from azext_connectedk8s.vendored_sdks.preview_2023_11_01 import (
ConnectedKubernetesClient,
)

if os.getenv(consts.Azure_Access_Token_Variable):
validate_custom_token()
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient,
subscription_id=os.getenv('AZURE_SUBSCRIPTION_ID'),
credential=credential)
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
ConnectedKubernetesClient,
subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
credential=credential,
)
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient)


def cf_connected_cluster_prev_2023_11_01(cli_ctx, _):
return cf_connectedk8s_prev_2023_11_01(cli_ctx).connected_cluster


def cf_connectedk8s_prev_2024_07_01(cli_ctx, *_):
from azext_connectedk8s.vendored_sdks.preview_2024_07_01 import ConnectedKubernetesClient
from azext_connectedk8s.vendored_sdks.preview_2024_07_01 import (
ConnectedKubernetesClient,
)

if os.getenv(consts.Azure_Access_Token_Variable):
validate_custom_token()
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient,
subscription_id=os.getenv('AZURE_SUBSCRIPTION_ID'),
credential=credential)
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
ConnectedKubernetesClient,
subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
credential=credential,
)
return get_mgmt_service_client(cli_ctx, ConnectedKubernetesClient)


def cf_connected_cluster_prev_2024_07_01(cli_ctx, _):
return cf_connectedk8s_prev_2024_07_01(cli_ctx).connected_cluster


def cf_connectedmachine(cli_ctx, subscription_id):
from azure.mgmt.hybridcompute import HybridComputeManagementClient

if os.getenv(consts.Azure_Access_Token_Variable):
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, HybridComputeManagementClient,
subscription_id=subscription_id,
credential=credential).private_link_scopes
return get_mgmt_service_client(cli_ctx, HybridComputeManagementClient,
subscription_id=subscription_id).private_link_scopes
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
HybridComputeManagementClient,
subscription_id=subscription_id,
credential=credential,
).private_link_scopes
return get_mgmt_service_client(
cli_ctx, HybridComputeManagementClient, subscription_id=subscription_id
).private_link_scopes


def cf_resource_groups(cli_ctx, subscription_id=None):
return _resource_client_factory(cli_ctx, subscription_id).resource_groups


def _resource_client_factory(cli_ctx, subscription_id=None):
from azure.mgmt.resource import ResourceManagementClient
if os.getenv(consts.Azure_Access_Token_Variable):
credential = AccessTokenCredential(access_token=os.getenv(consts.Azure_Access_Token_Variable))
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id, credential=credential)
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id)
credential = AccessTokenCredential(
access_token=os.getenv(consts.Azure_Access_Token_Variable)
)
return get_mgmt_service_client(
cli_ctx,
ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id,
credential=credential,
)
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id
)


def resource_providers_client(cli_ctx, subscription_id=None):
Expand All @@ -113,30 +154,34 @@ def resource_providers_client(cli_ctx, subscription_id=None):


class AccessTokenCredential:
"""Simple access token Authentication. Returns the access token as-is.
"""
"""Simple access token Authentication. Returns the access token as-is."""

def __init__(self, access_token):
self.access_token = access_token

def get_token(self, *arg, **kwargs):
import time

# Assume the access token expires in 60 minutes
return AccessToken(self.access_token, int(time.time()) + 3600)

def signed_session(self, session=None):
session = session or requests.Session()
header = "{} {}".format('Bearer', self.access_token)
session.headers['Authorization'] = header
header = "{} {}".format("Bearer", self.access_token)
session.headers["Authorization"] = header
return session


def validate_custom_token():
if os.getenv('AZURE_SUBSCRIPTION_ID') is None:
telemetry.set_exception(exception='Required environment variable \'AZURE_SUBSCRIPTION_ID\' is not set, when '
'using Custom Access Token.',
fault_type=consts.Custom_Token_Env_Var_Sub_Id_Missing_Fault_Type,
summary='Required environment variable \'AZURE_SUBSCRIPTION_ID\' is not set, when '
'using Custom Access Token.')
raise ValidationError("Environment variable 'AZURE_SUBSCRIPTION_ID' should be set when custom access token "
"is enabled.")
if os.getenv("AZURE_SUBSCRIPTION_ID") is None:
telemetry.set_exception(
exception="Required environment variable 'AZURE_SUBSCRIPTION_ID' is not set, when "
"using Custom Access Token.",
fault_type=consts.Custom_Token_Env_Var_Sub_Id_Missing_Fault_Type,
summary="Required environment variable 'AZURE_SUBSCRIPTION_ID' is not set, when "
"using Custom Access Token.",
)
raise ValidationError(
"Environment variable 'AZURE_SUBSCRIPTION_ID' should be set when custom access token "
"is enabled."
)
Loading
Loading