Skip to content

Commit

Permalink
{aks} add outbound type none and block (Azure#7977)
Browse files Browse the repository at this point in the history
Signed-off-by: Fan Shang Xiang <[email protected]>
  • Loading branch information
MartinForReal authored Sep 14, 2024
1 parent ad5fe47 commit f73734b
Show file tree
Hide file tree
Showing 9 changed files with 2,374 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

Pending
9.0.0b2
+++++++
* Add block to supported outbound type
* Vendor new SDK and bump API version to 2024-07-02-preview.

9.0.0b1
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
CONST_ARTIFACT_SOURCE_CACHE = "Cache"

CONST_OUTBOUND_TYPE_NONE = "none"
CONST_OUTBOUND_TYPE_BLOCK = "block"

# IMDS restriction consts
CONST_IMDS_RESTRICTION_ENABLED = "None"
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
- name: --outbound-type
type: string
short-summary: How outbound traffic will be configured for a cluster.
long-summary: Select between loadBalancer, userDefinedRouting, managedNATGateway and userAssignedNATGateway. If not set, defaults to type loadBalancer. Requires --vnet-subnet-id to be provided with a preconfigured route table and --load-balancer-sku to be Standard.
long-summary: Select between loadBalancer, userDefinedRouting, managedNATGateway, userAssignedNATGateway, none and block. If not set, defaults to type loadBalancer. Requires --vnet-subnet-id to be provided with a preconfigured route table and --load-balancer-sku to be Standard.
- name: --enable-addons -a
type: string
short-summary: Enable the Kubernetes addons in a comma-separated list.
Expand Down Expand Up @@ -883,7 +883,7 @@
- name: --outbound-type
type: string
short-summary: How outbound traffic will be configured for a cluster.
long-summary: This option will change the way how the outbound connections are managed in the AKS cluster. Available options are loadbalancer, managedNATGateway, userAssignedNATGateway, userDefinedRouting. For custom vnet, loadbalancer, userAssignedNATGateway and userDefinedRouting are supported. For aks managed vnet, loadbalancer, managedNATGateway and userDefinedRouting are supported.
long-summary: This option will change the way how the outbound connections are managed in the AKS cluster. Available options are loadbalancer, managedNATGateway, userAssignedNATGateway, userDefinedRouting, none and block. For custom vnet, loadbalancer, userAssignedNATGateway and userDefinedRouting are supported. For aks managed vnet, loadbalancer, managedNATGateway and userDefinedRouting are supported.
- name: --enable-pod-security-policy
type: bool
short-summary: Enable pod security policy.
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
CONST_ARTIFACT_SOURCE_DIRECT,
CONST_ARTIFACT_SOURCE_CACHE,
CONST_OUTBOUND_TYPE_NONE,
CONST_OUTBOUND_TYPE_BLOCK,
CONST_APP_ROUTING_ANNOTATION_CONTROLLED_NGINX,
CONST_APP_ROUTING_EXTERNAL_NGINX,
CONST_APP_ROUTING_INTERNAL_NGINX,
Expand Down Expand Up @@ -281,6 +282,7 @@
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_NONE,
CONST_OUTBOUND_TYPE_BLOCK,
]
auto_upgrade_channels = [
CONST_RAPID_UPGRADE_CHANNEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
CONST_DNS_ZONE_CONTRIBUTOR_ROLE,
CONST_ARTIFACT_SOURCE_CACHE,
CONST_OUTBOUND_TYPE_NONE,
CONST_OUTBOUND_TYPE_BLOCK,
CONST_IMDS_RESTRICTION_ENABLED,
CONST_IMDS_RESTRICTION_DISABLED,
)
Expand Down Expand Up @@ -427,7 +428,8 @@ def _get_outbound_type(
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
CONST_OUTBOUND_TYPE_NONE]
CONST_OUTBOUND_TYPE_NONE,
CONST_OUTBOUND_TYPE_BLOCK,]
):
outbound_type = CONST_OUTBOUND_TYPE_LOAD_BALANCER
skuName = self.get_sku_name()
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,53 @@ def test_aks_create_and_update_with_managed_nat_gateway_outbound(
],
)

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="eastus2euap", preserve_default_location=True,
)
def test_aks_create_with_block_and_update_to_none_outbound(
self, resource_group, resource_group_location
):
aks_name = self.create_random_name("cliakstest", 16)
self.kwargs.update(
{
"resource_group": resource_group,
"name": aks_name,
"ssh_key_value": self.generate_ssh_keys(),
}
)

create_cmd = (
"aks create --resource-group={resource_group} --name={name} "
"--vm-set-type VirtualMachineScaleSets -c 1 "
"--aks-custom-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkIsolatedClusterPreview,AKSHTTPCustomFeatures=Microsoft.ContainerService/EnableAPIServerVnetIntegrationPreview,AKSHTTPCustomFeatures=Microsoft.ContainerService/EnableOutboundTypeNoneAndBlock "
"--outbound-type block "
"--bootstrap-artifact-source Cache "
"-k 1.30 "
"--enable-apiserver-vnet-integration "
"--ssh-key-value={ssh_key_value}"
)
self.cmd(
create_cmd,
checks=[
self.check("provisioningState", "Succeeded"),
self.check("networkProfile.outboundType", "block"),
],
)

update_cmd = (
"aks update --resource-group={resource_group} --name={name} "
"--aks-custom-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkIsolatedClusterPreview,AKSHTTPCustomFeatures=Microsoft.ContainerService/EnableAPIServerVnetIntegrationPreview "
"--outbound-type none "
)
self.cmd(
update_cmd,
checks=[
self.check("provisioningState", "Succeeded"),
self.check("networkProfile.outboundType", "none"),
],
)

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="eastus"
Expand Down Expand Up @@ -1162,7 +1209,7 @@ def test_aks_addon_show_all_disabled(self, resource_group, resource_group_locati
"-a open-service-mesh -o json"
)

with self.assertRaisesRegexp(
with self.assertRaisesRegex(
CLIError, 'Addon "open-service-mesh" is not enabled in this cluster.'
):
self.cmd(show_cmd)
Expand Down Expand Up @@ -1510,7 +1557,7 @@ def test_aks_addon_update_all_disabled(
)

update_cmd = "aks addon update --addon confcom --resource-group={resource_group} --name={name} -o json"
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
CLIError, 'Addon "confcom" is not enabled in this cluster.'
):
self.cmd(update_cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ class OutboundType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
outbound behavior. Please refer to
https://azure.microsoft.com/en-us/updates/default-outbound-access-for-vms-in-azure-will-be-retired-transition-to-a-new-method-of-internet-access/"""

BLOCK = "block"
"""The AKS cluster will proactively block outbound connections. All AKS nodes follows Azure VM default
outbound behavior. Please refer to
https://azure.microsoft.com/en-us/updates/default-outbound-access-for-vms-in-azure-will-be-retired-transition-to-a-new-method-of-internet-access/"""

class PodIPAllocationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The IP allocation mode for pods in the agent pool. Must be used with podSubnetId. The default
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "9.0.0b1"
VERSION = "9.0.0b2"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit f73734b

Please sign in to comment.