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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

0.5.126
+++++++
* Add `--nrg-lockdown-restriction-level <restriction level>` option for chosing the node resource group restriction level in `aks create` and `aks update`

0.5.125
+++++++
* Update the minimum required cli core version to `2.44.0`.
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL = "node-image"
CONST_NONE_UPGRADE_CHANNEL = "none"

# consts for nrg-lockdown restriction level
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_READONLY = "ReadOnly"
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_UNRESTRICTED = "Unrestricted"

# network plugin
CONST_NETWORK_PLUGIN_KUBENET = "kubenet"
CONST_NETWORK_PLUGIN_AZURE = "azure"
Expand Down
8 changes: 8 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@
- name: --node-resource-group
type: string
short-summary: The node resource group is the resource group where all customer's resources will be created in, such as virtual machines.
- name: --nrg-lockdown-restriction-level
type: string
short-summary: Restriction level on the managed node resource group.
long-summary: The restriction level of permissions allowed on the cluster's managed node resource group, supported values are Unrestricted, and ReadOnly (recommended ReadOnly).
- name: --uptime-sla
type: bool
short-summary: Enable a paid managed cluster service with a financially backed SLA.
Expand Down Expand Up @@ -683,6 +687,10 @@
type: bool
short-summary: Disable pod security policy
long-summary: PodSecurityPolicy is deprecated. See https://aka.ms/aks/psp for details.
- name: --nrg-lockdown-restriction-level
type: string
short-summary: Restriction level on the managed node resource.
long-summary: The restriction level of permissions allowed on the cluster's managed node resource group, supported values are Unrestricted, and ReadOnly (recommended ReadOnly).
- name: --attach-acr
type: string
short-summary: Grant the 'acrpull' role assignment to the ACR specified by name or resource ID.
Expand Down
8 changes: 8 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
CONST_NODEPOOL_MODE_SYSTEM,
CONST_NODEPOOL_MODE_USER,
CONST_NONE_UPGRADE_CHANNEL,
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_READONLY,
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_UNRESTRICTED,
CONST_OS_DISK_TYPE_EPHEMERAL,
CONST_OS_DISK_TYPE_MANAGED,
CONST_OS_SKU_CBLMARINER,
Expand Down Expand Up @@ -190,6 +192,10 @@
CONST_NODE_IMAGE_UPGRADE_CHANNEL,
CONST_NONE_UPGRADE_CHANNEL,
]
nrg_lockdown_restriction_levels = [
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_READONLY,
CONST_NRG_LOCKDOWN_RESTRICTION_LEVEL_UNRESTRICTED,
]

# consts for maintenance configuration
schedule_types = [
Expand Down Expand Up @@ -254,6 +260,7 @@ def load_arguments(self, _):
c.argument('load_balancer_outbound_ports', type=int, validator=validate_load_balancer_outbound_ports)
c.argument('load_balancer_idle_timeout', type=int, validator=validate_load_balancer_idle_timeout)
c.argument('load_balancer_backend_pool_type', validator=validate_load_balancer_backend_pool_type)
c.argument('nrg_lockdown_restriction_level', arg_type=get_enum_type(nrg_lockdown_restriction_levels))
c.argument('nat_gateway_managed_outbound_ip_count', type=int, validator=validate_nat_gateway_managed_outbound_ip_count)
c.argument('nat_gateway_idle_timeout', type=int, validator=validate_nat_gateway_idle_timeout)
c.argument('outbound_type', arg_type=get_enum_type(outbound_types))
Expand Down Expand Up @@ -396,6 +403,7 @@ def load_arguments(self, _):
c.argument('load_balancer_outbound_ports', type=int, validator=validate_load_balancer_outbound_ports)
c.argument('load_balancer_idle_timeout', type=int, validator=validate_load_balancer_idle_timeout)
c.argument('load_balancer_backend_pool_type', validator=validate_load_balancer_backend_pool_type)
c.argument('nrg_lockdown_restriction_level', arg_type=get_enum_type(nrg_lockdown_restriction_levels))
c.argument('nat_gateway_managed_outbound_ip_count', type=int, validator=validate_nat_gateway_managed_outbound_ip_count)
c.argument('nat_gateway_idle_timeout', type=int, validator=validate_nat_gateway_idle_timeout)
c.argument('kube_proxy_config')
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def aks_create(
attach_acr=None,
skip_subnet_role_assignment=False,
node_resource_group=None,
nrg_lockdown_restriction_level=None,
enable_defender=False,
defender_config=None,
disk_driver_version=None,
Expand Down Expand Up @@ -781,6 +782,7 @@ def aks_update(
gmsa_root_domain_name=None,
attach_acr=None,
detach_acr=None,
nrg_lockdown_restriction_level=None,
enable_defender=False,
disable_defender=False,
defender_config=None,
Expand Down
50 changes: 50 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 @@ -467,6 +467,26 @@ def get_load_balancer_backend_pool_type(self) -> str:
# this parameter does not need validation
return load_balancer_backend_pool_type

def get_nrg_lockdown_restriction_level(self) -> Union[str, None]:
"""Obtain the value of nrg_lockdown_restriction_level.
:return: string or None
"""
# read the original value passed by the command
nrg_lockdown_restriction_level = self.raw_param.get("nrg_lockdown_restriction_level")

# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
if self.decorator_mode == DecoratorMode.CREATE:
Comment thread
charliedmcb marked this conversation as resolved.
if (
self.mc and
self.mc.node_resource_group_profile and
self.mc.node_resource_group_profile.restriction_level is not None
):
nrg_lockdown_restriction_level = self.mc.node_resource_group_profile.restriction_level

# this parameter does not need dynamic completion
# this parameter does not need validation
return nrg_lockdown_restriction_level

def get_kube_proxy_config(self) -> Union[Dict, ContainerServiceNetworkProfileKubeProxyConfig, None]:
"""Obtain the value of kube_proxy_config.

Expand Down Expand Up @@ -2120,6 +2140,19 @@ def set_up_kube_proxy_config(self, mc: ManagedCluster) -> ManagedCluster:
mc.network_profile.kube_proxy_config = self.context.get_kube_proxy_config()
return mc

def set_up_node_resource_group_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up node resource group profile for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

node_resource_group_profile = None
nrg_lockdown_restriction_level = self.context.get_nrg_lockdown_restriction_level()
if nrg_lockdown_restriction_level:
node_resource_group_profile = self.models.ManagedClusterNodeResourceGroupProfile(restriction_level=nrg_lockdown_restriction_level)
mc.node_resource_group_profile = node_resource_group_profile
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 @@ -2153,6 +2186,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
mc = self.set_up_kube_proxy_config(mc)
# set up custom ca trust certificates
mc = self.set_up_custom_ca_trust_certificates(mc)
# set up node resource group profile
mc = self.set_up_node_resource_group_profile(mc)

# DO NOT MOVE: keep this at the bottom, restore defaults
mc = self._restore_defaults_in_mc(mc)
Expand Down Expand Up @@ -2658,6 +2693,19 @@ def update_linux_profile(self, mc: ManagedCluster) -> ManagedCluster:
)
return mc

def update_node_resource_group_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Update node resource group profile for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

nrg_lockdown_restriction_level = self.context.get_nrg_lockdown_restriction_level()
if nrg_lockdown_restriction_level is not None:
if mc.node_resource_group_profile is None:
mc.node_resource_group_profile = self.models.ManagedClusterNodeResourceGroupProfile()
mc.node_resource_group_profile.restriction_level = nrg_lockdown_restriction_level
return mc

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

Expand Down Expand Up @@ -2695,5 +2743,7 @@ def update_mc_profile_preview(self) -> ManagedCluster:
mc = self.update_kube_proxy_config(mc)
# update custom ca trust certificates
mc = self.update_custom_ca_trust_certificates(mc)
# update node resource group profile
mc = self.update_node_resource_group_profile(mc)

return mc
Loading