Skip to content
Open
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d418cda
Added namespace command in update aks
KarthikK123 Apr 27, 2022
4d19877
Added tests for namespace changes
KarthikK123 Apr 28, 2022
4d5cd56
Updated tests
KarthikK123 Apr 28, 2022
7ce1820
Updated tests
KarthikK123 Apr 28, 2022
61b22df
Updated tests
KarthikK123 Apr 29, 2022
40e4651
Added namespace resource in aks create and get-credentials
KarthikK123 Apr 25, 2022
5982c4a
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 4, 2022
29c8905
Added namespace sdk
KarthikK123 May 5, 2022
d27f8d7
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 5, 2022
0192946
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 5, 2022
965bff5
Removed accidental changes
KarthikK123 May 5, 2022
fd1ec44
Removed whitespace
KarthikK123 May 5, 2022
5793c61
Removed unnecessary changed
KarthikK123 May 5, 2022
bdabfcd
Removed whitespace diff
KarthikK123 May 5, 2022
89b0b0f
Added test recordings
May 9, 2022
814badc
Fixed linter issues
KarthikK123 May 9, 2022
7871739
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
May 9, 2022
65878ff
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 9, 2022
0baf16a
Fixed static analysis errors
KarthikK123 May 9, 2022
1237f81
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 9, 2022
91a3aaa
Removed unnecessary import
KarthikK123 May 9, 2022
0500fba
Removed unnecessary options list
KarthikK123 May 9, 2022
225eff8
Added test for get-credentials at namespace scope
KarthikK123 May 11, 2022
e476791
adding test recording
KarthikK123 May 11, 2022
60592e6
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 12, 2022
084a702
updated test recordings
KarthikK123 May 12, 2022
db99792
trigger pipelines
KarthikK123 May 16, 2022
4d67bbf
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 16, 2022
0b491b5
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 16, 2022
48f6548
Updated test recordings
KarthikK123 May 16, 2022
436e88e
trigger tests
KarthikK123 May 17, 2022
b029f40
Merge branch 'Azure:main' into kkanukollu/aks-namespaces
KarthikK123 May 17, 2022
668d845
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 17, 2022
4474c95
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 17, 2022
21cde94
Removed breaking changes
KarthikK123 May 17, 2022
e97c914
trigger pipeline
KarthikK123 May 17, 2022
58ef7f3
Updated help message for param
KarthikK123 May 18, 2022
17c8a72
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 18, 2022
d5fef40
Added tests to exclude because of feature flag registration
KarthikK123 May 18, 2022
d9003e9
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 18, 2022
b9f3f14
updated test recordings
KarthikK123 May 18, 2022
13433ec
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 18, 2022
c7cb557
Updated test recordings
KarthikK123 May 19, 2022
e57e811
Updated tests
KarthikK123 May 19, 2022
597fe38
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 May 19, 2022
4d17d8d
Updated test recording
KarthikK123 May 19, 2022
903aec0
Updated tests
KarthikK123 May 19, 2022
8c66662
Updated test recordings
KarthikK123 May 19, 2022
a1b0671
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 20, 2022
e628697
Updated test recordings
KarthikK123 May 20, 2022
f719b8f
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 May 20, 2022
fc3482b
Updated test recordings
KarthikK123 May 20, 2022
152bb95
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 Jun 6, 2022
b2ac00a
Added option to disable namespace resource
KarthikK123 Jun 6, 2022
b45b6ba
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 Jun 6, 2022
764ccbd
Fixed linter issue
KarthikK123 Jun 6, 2022
3e681b9
Removed accidental changes
KarthikK123 Jun 6, 2022
c62d51e
updated test recordings
KarthikK123 Jun 7, 2022
d0bc4b1
Updated test to cover disable-namespace command
KarthikK123 Jun 7, 2022
417c873
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 Jun 7, 2022
ead3b59
Updated test recordings
KarthikK123 Jun 7, 2022
f5ce8b1
Updated help messages
KarthikK123 Jun 8, 2022
6bddded
Merge branch 'kkanukollu/aks-namespaces' of https://github.com/Karthi…
KarthikK123 Jun 8, 2022
d038834
Updated help message
KarthikK123 Jun 8, 2022
5949011
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 Jun 15, 2022
63733c5
Addressed review comments
KarthikK123 Jul 7, 2022
be32baa
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 Jul 7, 2022
bbdb72f
Updated test recordings
KarthikK123 Jul 7, 2022
cbf966a
Updated test to allow mocking of sleep
KarthikK123 Jul 8, 2022
2224f0e
Added validation for mutually exclusive parameters
KarthikK123 Jul 11, 2022
c2815de
Updated tests
KarthikK123 Jul 11, 2022
eeb650b
Updated test recordings
KarthikK123 Jul 11, 2022
282ca45
Moved validation to validators.py
KarthikK123 Jul 12, 2022
8746571
Fixed static analysis error
KarthikK123 Jul 12, 2022
8da5bca
Fixed static analysis error
KarthikK123 Jul 12, 2022
ea89244
Fixed static analysis error
KarthikK123 Jul 12, 2022
9bd067b
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 Oct 26, 2022
de088df
Merge branch 'main' into kkanukollu/aks-namespaces
KarthikK123 Jan 24, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"test_aks_create_with_csi_driver_v2",
"test_aks_create_and_update_csi_driver_to_v2",
"test_aks_create_with_azurekeyvaultkms_private_key_vault",
"test_aks_update_with_azurekeyvaultkms_private_key_vault"
"test_aks_update_with_azurekeyvaultkms_private_key_vault",
"test_aks_create_with_namespace_enabled",
"test_aks_update_enable_namespace",
"test_aks_get_credentials_at_namespace_scope"
]
}
}
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def load_arguments(self, _):
c.argument('message_of_the_day')
c.argument('gpu_instance_profile', arg_type=get_enum_type(gpu_instance_profiles))
c.argument('workload_runtime', arg_type=get_enum_type(workload_runtimes), default=CONST_WORKLOAD_RUNTIME_OCI_CONTAINER)
c.argument('enable_namespace_resources', action="store_true", help='Enable sync of namespaces as Azure Resource Manager resources')
# no validation for aks create because it already only supports Linux.
c.argument('enable_custom_ca_trust', action='store_true')

Expand Down Expand Up @@ -396,6 +397,8 @@ def load_arguments(self, _):
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', action='store_true')
c.argument('enable_file_driver', action='store_true')
c.argument('enable_namespace_resources', action='store_true', help='Enable sync of namespaces as Azure Resource Manager resources')
c.argument('disable_namespace_resources', action='store_true', help='Disable sync of namespaces as Azure Resource Manager resources')
c.argument('disable_file_driver', action='store_true')
c.argument('enable_blob_driver', action='store_true')
c.argument('disable_blob_driver', action='store_true')
Expand Down Expand Up @@ -598,6 +601,7 @@ def load_arguments(self, _):
default=os.path.join(os.path.expanduser('~'), '.kube', 'config'))
c.argument('public_fqdn', default=False, action='store_true')
c.argument('credential_format', options_list=['--format'], arg_type=get_enum_type(credential_formats))
c.argument('namespace_name', options_list=['--namespace'], help='User only having access to namespace resource can use this parameter to specify the namespace name.')

with self.argument_context('aks pod-identity') as c:
c.argument('cluster_name', help='The cluster name.')
Expand Down
18 changes: 16 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ def aks_create(
gpu_instance_profile=None,
workload_runtime=None,
enable_custom_ca_trust=False,
enable_namespace_resources=False,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down Expand Up @@ -779,6 +780,8 @@ def aks_update(
apiserver_subnet_id=None,
enable_keda=False,
disable_keda=False,
enable_namespace_resources=False,
disable_namespace_resources=False
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down Expand Up @@ -839,6 +842,7 @@ def aks_get_credentials(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
name,
namespace_name=None,
admin=False,
user='clusterUser',
path=os.path.join(os.path.expanduser(
Expand All @@ -856,12 +860,22 @@ def aks_get_credentials(cmd, # pylint: disable=unused-argument
if admin:
raise InvalidArgumentValueError("--format can only be specified when requesting clusterUser credential.")
if admin:
if namespace_name is not None:
raise InvalidArgumentValueError("--namespace is not valid for admin credentials")
credentialResults = client.list_cluster_admin_credentials(
resource_group_name, name, serverType)
else:
if user.lower() == 'clusteruser':
credentialResults = client.list_cluster_user_credentials(
resource_group_name, name, serverType, credential_format)
if namespace_name is not None:
from azext_aks_preview.vendored_sdks.namespace_client import NamespaceClient
from azure.cli.core.commands.client_factory import get_mgmt_service_client

client = get_mgmt_service_client(cmd.cli_ctx, NamespaceClient)
credentialResults = client.list_user_credential(resource_group_name, "Microsoft.ContainerService", "managedClusters", name, namespace_name)

else:
credentialResults = client.list_cluster_user_credentials(
resource_group_name, name, serverType, credential_format)
elif user.lower() == 'clustermonitoringuser':
credentialResults = client.list_cluster_monitoring_user_credentials(
resource_group_name, name, serverType)
Expand Down
86 changes: 86 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,67 @@ def get_disable_keda(self) -> bool:
"""
return self._get_disable_keda(enable_validation=True)

def _get_enable_namespace_resources(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_namespace_resources.

This function supports the option of enable_validation. When enabled, if both enable_namespace_resources and disable_namespace_resources are
specified, raise a MutuallyExclusiveArgumentError.

:return: bool
"""
# Read the original value passed by the command.
enable_namespace_resources = self.raw_param.get("enable_namespace_resources")

# This parameter does not need dynamic completion.
if enable_validation:
if enable_namespace_resources and self._get_disable_namespace_resources(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-namespace-resources and --disable-namespace-resources at the same time."
)

return enable_namespace_resources

def get_enable_namespace_resources(self) -> bool:
"""Obtain the value of enable_namespace_resources.

This function will verify the parameter by default. If both enable_namespace_resources and disable_namespace_resources are specified, raise a
MutuallyExclusiveArgumentError.

:return: bool
"""
return self._get_enable_namespace_resources(enable_validation=True)

def _get_disable_namespace_resources(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_namespace_resources.

This function supports the option of enable_validation. When enabled, if both enable_namespace_resources and disable_namespace_resources are
specified, raise a MutuallyExclusiveArgumentError.

:return: bool
"""
# Read the original value passed by the command.
disable_namespace_resources = self.raw_param.get("disable_namespace_resources")

# This option is not supported in create mode, hence we do not read the property value from the `mc` object.
# This parameter does not need dynamic completion.
if enable_validation:
if disable_namespace_resources and self._get_enable_namespace_resources(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-namespace-resources and --disable-namespace-resources at the same time."
)

return disable_namespace_resources

def get_disable_namespace_resources(self) -> bool:
"""Obtain the value of disable_namespace_resources.

This function will verify the parameter by default. If both enable_namespace_resources and disable_namespace_resources are specified, raise a
MutuallyExclusiveArgumentError.

:return: bool
"""
return self._get_disable_namespace_resources(enable_validation=True)


class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
def __init__(
Expand Down Expand Up @@ -1621,6 +1682,14 @@ def set_up_workload_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedClus

return mc

def set_up_enable_namespace_resource(self, mc: ManagedCluster) -> ManagedCluster:
"""Sets the property to enable namespace as an ARM resource
:return: the ManagedCluster object
"""
if self.context.raw_param.get("enable_namespace_resources"):
mc.enable_namespace_resources = True
return mc

def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) -> ManagedCluster:
"""The overall controller used to construct the default ManagedCluster profile.

Expand Down Expand Up @@ -1657,6 +1726,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_ingress_web_app_routing(mc)
# set up workload auto scaler profile
mc = self.set_up_workload_auto_scaler_profile(mc)
# set up the enableNamespaceResources properties
mc = self.set_up_enable_namespace_resource(mc)

# DO NOT MOVE: keep this at the bottom, restore defaults
mc = self._restore_defaults_in_mc(mc)
Expand Down Expand Up @@ -1930,6 +2001,19 @@ def update_workload_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedClus

return mc

def update_enable_namespace_resources(self, mc: ManagedCluster) -> ManagedCluster:
"""Sets the property to enable namespace as an ARM resource
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

if self.context.get_enable_namespace_resources():
mc.enable_namespace_resources = True

if self.context.get_disable_namespace_resources():
mc.enable_namespace_resources = False
return mc

def update_mc_profile_preview(self) -> ManagedCluster:
"""The overall controller used to update the preview ManagedCluster profile.

Expand Down Expand Up @@ -1962,5 +2046,7 @@ def update_mc_profile_preview(self) -> ManagedCluster:
mc = self.update_storage_profile(mc)
# update workload auto scaler profile
mc = self.update_workload_auto_scaler_profile(mc)
# update the enbaleNamespaceResources property
mc = self.update_enable_namespace_resources(mc)

return mc
Loading