Skip to content

Commit 50024df

Browse files
committed
{aks} add outbound type none and block
Signed-off-by: Fan Shang Xiang <fanshangxiang@gmail.com>
1 parent ad5fe47 commit 50024df

File tree

9 files changed

+1962
-6
lines changed

9 files changed

+1962
-6
lines changed

src/aks-preview/HISTORY.rst

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Pending
1313
+++++++
1414
* Vendor new SDK and bump API version to 2024-07-02-preview.
1515

16+
9.0.0b2
17+
+++++++
18+
* Add block to supported outbound type
19+
1620
9.0.0b1
1721
+++++++
1822
* [BREAKING CHANGE]: Remove support for `az aks update --ssh-access` command to avoid misleading. To update existing cluster's SSH access, please use `az aks nodepool update --ssh-access` to update node pool's SSH access one by one.

src/aks-preview/azext_aks_preview/_consts.py

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
CONST_ARTIFACT_SOURCE_CACHE = "Cache"
323323

324324
CONST_OUTBOUND_TYPE_NONE = "none"
325+
CONST_OUTBOUND_TYPE_BLOCK = "block"
325326

326327
# IMDS restriction consts
327328
CONST_IMDS_RESTRICTION_ENABLED = "None"

src/aks-preview/azext_aks_preview/_help.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
- name: --outbound-type
181181
type: string
182182
short-summary: How outbound traffic will be configured for a cluster.
183-
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.
183+
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.
184184
- name: --enable-addons -a
185185
type: string
186186
short-summary: Enable the Kubernetes addons in a comma-separated list.
@@ -883,7 +883,7 @@
883883
- name: --outbound-type
884884
type: string
885885
short-summary: How outbound traffic will be configured for a cluster.
886-
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.
886+
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.
887887
- name: --enable-pod-security-policy
888888
type: bool
889889
short-summary: Enable pod security policy.

src/aks-preview/azext_aks_preview/_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
CONST_ARTIFACT_SOURCE_DIRECT,
123123
CONST_ARTIFACT_SOURCE_CACHE,
124124
CONST_OUTBOUND_TYPE_NONE,
125+
CONST_OUTBOUND_TYPE_BLOCK,
125126
CONST_APP_ROUTING_ANNOTATION_CONTROLLED_NGINX,
126127
CONST_APP_ROUTING_EXTERNAL_NGINX,
127128
CONST_APP_ROUTING_INTERNAL_NGINX,
@@ -281,6 +282,7 @@
281282
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
282283
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
283284
CONST_OUTBOUND_TYPE_NONE,
285+
CONST_OUTBOUND_TYPE_BLOCK,
284286
]
285287
auto_upgrade_channels = [
286288
CONST_RAPID_UPGRADE_CHANNEL,

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
CONST_DNS_ZONE_CONTRIBUTOR_ROLE,
3737
CONST_ARTIFACT_SOURCE_CACHE,
3838
CONST_OUTBOUND_TYPE_NONE,
39+
CONST_OUTBOUND_TYPE_BLOCK,
3940
CONST_IMDS_RESTRICTION_ENABLED,
4041
CONST_IMDS_RESTRICTION_DISABLED,
4142
)
@@ -427,7 +428,8 @@ def _get_outbound_type(
427428
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
428429
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
429430
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
430-
CONST_OUTBOUND_TYPE_NONE]
431+
CONST_OUTBOUND_TYPE_NONE,
432+
CONST_OUTBOUND_TYPE_BLOCK,]
431433
):
432434
outbound_type = CONST_OUTBOUND_TYPE_LOAD_BALANCER
433435
skuName = self.get_sku_name()

src/aks-preview/azext_aks_preview/tests/latest/recordings/test_aks_create_with_block_and_update_to_none_outbound.yaml

+1,896
Large diffs are not rendered by default.

src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py

+49-2
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,53 @@ def test_aks_create_and_update_with_managed_nat_gateway_outbound(
258258
],
259259
)
260260

261+
@AllowLargeResponse()
262+
@AKSCustomResourceGroupPreparer(
263+
random_name_length=17, name_prefix="clitest", location="eastus2euap"
264+
)
265+
def test_aks_create_with_block_and_update_to_none_outbound(
266+
self, resource_group, resource_group_location
267+
):
268+
aks_name = self.create_random_name("cliakstest", 16)
269+
self.kwargs.update(
270+
{
271+
"resource_group": resource_group,
272+
"name": aks_name,
273+
"ssh_key_value": self.generate_ssh_keys(),
274+
}
275+
)
276+
277+
create_cmd = (
278+
"aks create --resource-group={resource_group} --name={name} "
279+
"--vm-set-type VirtualMachineScaleSets -c 1 "
280+
"--aks-custom-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkIsolatedClusterPreview "
281+
"--outbound-type block "
282+
"--bootstrap-artifact-source Cache "
283+
"-k 1.30 "
284+
"--enable-apiserver-vnet-integration "
285+
"--ssh-key-value={ssh_key_value}"
286+
)
287+
self.cmd(
288+
create_cmd,
289+
checks=[
290+
self.check("provisioningState", "Succeeded"),
291+
self.check("networkProfile.outboundType", "block"),
292+
],
293+
)
294+
295+
update_cmd = (
296+
"aks update --resource-group={resource_group} --name={name} "
297+
"--aks-custom-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkIsolatedClusterPreview "
298+
"--outbound-type none "
299+
)
300+
self.cmd(
301+
update_cmd,
302+
checks=[
303+
self.check("provisioningState", "Succeeded"),
304+
self.check("networkProfile.outboundType", "none"),
305+
],
306+
)
307+
261308
@AllowLargeResponse()
262309
@AKSCustomResourceGroupPreparer(
263310
random_name_length=17, name_prefix="clitest", location="eastus"
@@ -1162,7 +1209,7 @@ def test_aks_addon_show_all_disabled(self, resource_group, resource_group_locati
11621209
"-a open-service-mesh -o json"
11631210
)
11641211

1165-
with self.assertRaisesRegexp(
1212+
with self.assertRaisesRegex(
11661213
CLIError, 'Addon "open-service-mesh" is not enabled in this cluster.'
11671214
):
11681215
self.cmd(show_cmd)
@@ -1510,7 +1557,7 @@ def test_aks_addon_update_all_disabled(
15101557
)
15111558

15121559
update_cmd = "aks addon update --addon confcom --resource-group={resource_group} --name={name} -o json"
1513-
with self.assertRaisesRegexp(
1560+
with self.assertRaisesRegex(
15141561
CLIError, 'Addon "confcom" is not enabled in this cluster.'
15151562
):
15161563
self.cmd(update_cmd)

src/aks-preview/azext_aks_preview/vendored_sdks/azure_mgmt_preview_aks/v2024_07_02_preview/models/_container_service_client_enums.py

+4
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ class OutboundType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
550550
outbound behavior. Please refer to
551551
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/"""
552552

553+
BLOCK = "block"
554+
"""The AKS cluster will proactively block outbound connections. All AKS nodes follows Azure VM default
555+
outbound behavior. Please refer to
556+
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/"""
553557

554558
class PodIPAllocationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
555559
"""The IP allocation mode for pods in the agent pool. Must be used with podSubnetId. The default

src/aks-preview/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from setuptools import setup, find_packages
1111

12-
VERSION = "9.0.0b1"
12+
VERSION = "9.0.0b2"
1313

1414
CLASSIFIERS = [
1515
"Development Status :: 4 - Beta",

0 commit comments

Comments
 (0)