Skip to content

Commit

Permalink
{aks} add outbound type none and block
Browse files Browse the repository at this point in the history
Signed-off-by: Fan Shang Xiang <[email protected]>
  • Loading branch information
MartinForReal committed Sep 13, 2024
1 parent ad5fe47 commit d08e0b6
Show file tree
Hide file tree
Showing 8 changed files with 1,960 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Pending
* [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.
* Remove dependency on `msrestazure.azure_exceptions` and `msrestazure.tools`.

8.0.0b2
* Add block to supported outbound type

8.0.0b1
+++++++
* [BREAKING CHANGE]: Remove enable/disable node restriction feature, since it is always enabled and not changeable since k8s version 1.24.0
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"
)
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 "
"--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 "
"--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

0 comments on commit d08e0b6

Please sign in to comment.