feat: add load-balancer-backend-pool-type to create and update api (#5355)
* feat: add load-balancer-backend-pool-type to create and update api * chore: update version Co-authored-by: Qi Ni <nicky@devbox.aqncfxt3tzze5ecj2ea1rtv10c.cx.internal.cloudapp.net>
This commit is contained in:
Родитель
7bfb799d7f
Коммит
373cc11e87
|
@ -64,6 +64,9 @@ aks create:
|
|||
load_balancer_outbound_ports:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
load_balancer_backend_pool_type:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
nat_gateway_idle_timeout:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
|
@ -176,6 +179,9 @@ aks update:
|
|||
load_balancer_outbound_ports:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
load_balancer_backend_pool_type:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
nat_gateway_idle_timeout:
|
||||
rule_exclusions:
|
||||
- option_length_too_long
|
||||
|
|
|
@ -12,6 +12,11 @@ To release a new version, please select a new version number (usually plus 1 to
|
|||
Pending
|
||||
+++++++
|
||||
|
||||
0.5.103
|
||||
+++++++
|
||||
|
||||
* Add load-balancer-backend-pool-type to create and update api.
|
||||
|
||||
0.5.102
|
||||
+++++++
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING = "userDefinedRouting"
|
|||
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY = "managedNATGateway"
|
||||
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY = "userAssignedNATGateway"
|
||||
|
||||
# load balancer backend pool type
|
||||
CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP = "nodeIP"
|
||||
CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IPCONFIGURATION = "nodeIPConfiguration"
|
||||
|
||||
# private dns zone mode
|
||||
CONST_PRIVATE_DNS_ZONE_SYSTEM = "system"
|
||||
CONST_PRIVATE_DNS_ZONE_NONE = "none"
|
||||
|
|
|
@ -157,6 +157,10 @@ helps['aks create'] = """
|
|||
type: int
|
||||
short-summary: Load balancer idle timeout in minutes.
|
||||
long-summary: Desired idle timeout for load balancer outbound flows, default is 30 minutes. Please specify a value in the range of [4, 100].
|
||||
- name: --load-balancer-backend-pool-type
|
||||
type: string
|
||||
short-summary: Load balancer backend pool type.
|
||||
long-summary: Load balancer backend pool type, supported values are nodeIP and nodeIPConfiguration.
|
||||
- name: --nat-gateway-managed-outbound-ip-count
|
||||
type: int
|
||||
short-summary: NAT gateway managed outbound IP count.
|
||||
|
@ -620,6 +624,10 @@ helps['aks update'] = """
|
|||
type: int
|
||||
short-summary: Load balancer idle timeout in minutes.
|
||||
long-summary: Desired idle timeout for load balancer outbound flows, default is 30 minutes. Please specify a value in the range of [4, 100].
|
||||
- name: --load-balancer-backend-pool-type
|
||||
type: string
|
||||
short-summary: Load balancer backend pool type.
|
||||
long-summary: Load balancer backend pool type, supported values are nodeIP and nodeIPConfiguration.
|
||||
- name: --nat-gateway-managed-outbound-ip-count
|
||||
type: int
|
||||
short-summary: NAT gateway managed outbound IP count.
|
||||
|
|
|
@ -23,20 +23,20 @@ def set_load_balancer_sku(sku, kubernetes_version):
|
|||
|
||||
|
||||
def update_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, profile, models):
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, backend_pool_type, profile, models):
|
||||
"""parse and update an existing load balancer profile"""
|
||||
if not is_load_balancer_profile_provided(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout):
|
||||
outbound_ip_prefixes, outbound_ports, backend_pool_type, idle_timeout):
|
||||
return profile
|
||||
return configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, profile, models)
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, backend_pool_type, profile, models)
|
||||
|
||||
|
||||
def create_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, models):
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, backend_pool_type, models):
|
||||
"""parse and build load balancer profile"""
|
||||
if not is_load_balancer_profile_provided(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout):
|
||||
outbound_ip_prefixes, outbound_ports, backend_pool_type, idle_timeout):
|
||||
return None
|
||||
|
||||
if isinstance(models, SimpleNamespace):
|
||||
|
@ -45,11 +45,11 @@ def create_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv
|
|||
ManagedClusterLoadBalancerProfile = models.get("ManagedClusterLoadBalancerProfile")
|
||||
profile = ManagedClusterLoadBalancerProfile()
|
||||
return configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, profile, models)
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, backend_pool_type, profile, models)
|
||||
|
||||
|
||||
def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, profile, models):
|
||||
outbound_ip_prefixes, outbound_ports, idle_timeout, backend_pool_type, profile, models):
|
||||
"""configure a load balancer with customer supplied values"""
|
||||
if not profile:
|
||||
return profile
|
||||
|
@ -109,17 +109,20 @@ def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_
|
|||
profile.allocated_outbound_ports = outbound_ports
|
||||
if idle_timeout:
|
||||
profile.idle_timeout_in_minutes = idle_timeout
|
||||
if backend_pool_type:
|
||||
profile.backend_pool_type = backend_pool_type
|
||||
return profile
|
||||
|
||||
|
||||
def is_load_balancer_profile_provided(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips,
|
||||
ip_prefixes, outbound_ports, idle_timeout):
|
||||
ip_prefixes, outbound_ports, backend_pool_type, idle_timeout):
|
||||
return any([managed_outbound_ip_count,
|
||||
managed_outbound_ipv6_count,
|
||||
outbound_ips,
|
||||
ip_prefixes,
|
||||
outbound_ports,
|
||||
idle_timeout])
|
||||
idle_timeout,
|
||||
backend_pool_type])
|
||||
|
||||
|
||||
def _get_load_balancer_outbound_ips(load_balancer_outbound_ips, models):
|
||||
|
|
|
@ -93,6 +93,7 @@ from azext_aks_preview._validators import (
|
|||
validate_k8s_version,
|
||||
validate_linux_host_name,
|
||||
validate_load_balancer_idle_timeout,
|
||||
validate_load_balancer_backend_pool_type,
|
||||
validate_load_balancer_outbound_ip_prefixes,
|
||||
validate_load_balancer_outbound_ips,
|
||||
validate_load_balancer_outbound_ports,
|
||||
|
@ -212,6 +213,7 @@ def load_arguments(self, _):
|
|||
c.argument('load_balancer_outbound_ip_prefixes', validator=validate_load_balancer_outbound_ip_prefixes)
|
||||
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('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))
|
||||
|
@ -345,6 +347,7 @@ def load_arguments(self, _):
|
|||
c.argument('load_balancer_outbound_ip_prefixes', validator=validate_load_balancer_outbound_ip_prefixes)
|
||||
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('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('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels))
|
||||
|
|
|
@ -22,7 +22,11 @@ from azure.cli.core.commands.validators import validate_tag
|
|||
from azure.cli.core.util import CLIError
|
||||
from knack.log import get_logger
|
||||
|
||||
from azext_aks_preview._consts import ADDONS
|
||||
from azext_aks_preview._consts import (
|
||||
ADDONS,
|
||||
CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP,
|
||||
CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IPCONFIGURATION,
|
||||
)
|
||||
from azext_aks_preview._helpers import _fuzzy_match
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
@ -309,6 +313,14 @@ def validate_load_balancer_idle_timeout(namespace):
|
|||
"--load-balancer-idle-timeout must be in the range [4,100]")
|
||||
|
||||
|
||||
def validate_load_balancer_backend_pool_type(namespace):
|
||||
"""validate load balancer backend pool type"""
|
||||
if namespace.load_balancer_backend_pool_type is not None:
|
||||
if namespace.load_balancer_backend_pool_type not in [CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP, CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IPCONFIGURATION]:
|
||||
raise InvalidArgumentValueError(
|
||||
f"Invalid Load Balancer Backend Pool Type {namespace.load_balancer_backend_pool_type}, supported values are nodeIP and nodeIPConfiguration")
|
||||
|
||||
|
||||
def validate_nat_gateway_managed_outbound_ip_count(namespace):
|
||||
"""validate NAT gateway profile managed outbound IP count"""
|
||||
if namespace.nat_gateway_managed_outbound_ip_count is not None:
|
||||
|
|
|
@ -560,6 +560,7 @@ def aks_create(
|
|||
load_balancer_outbound_ip_prefixes=None,
|
||||
load_balancer_outbound_ports=None,
|
||||
load_balancer_idle_timeout=None,
|
||||
load_balancer_backend_pool_type=None,
|
||||
nat_gateway_managed_outbound_ip_count=None,
|
||||
nat_gateway_idle_timeout=None,
|
||||
outbound_type=None,
|
||||
|
@ -716,6 +717,7 @@ def aks_update(
|
|||
load_balancer_outbound_ip_prefixes=None,
|
||||
load_balancer_outbound_ports=None,
|
||||
load_balancer_idle_timeout=None,
|
||||
load_balancer_backend_pool_type=None,
|
||||
nat_gateway_managed_outbound_ip_count=None,
|
||||
nat_gateway_idle_timeout=None,
|
||||
auto_upgrade_channel=None,
|
||||
|
|
|
@ -356,6 +356,20 @@ class AKSPreviewManagedClusterContext(AKSManagedClusterContext):
|
|||
|
||||
return count_ipv6
|
||||
|
||||
def get_load_balancer_backend_pool_type(self) -> str:
|
||||
"""Obtain the value of load_balancer_backend_pool_type.
|
||||
|
||||
:return: string
|
||||
"""
|
||||
# read the original value passed by the command
|
||||
load_balancer_backend_pool_type = self.raw_param.get(
|
||||
"load_balancer_backend_pool_type"
|
||||
)
|
||||
|
||||
# this parameter does not need dynamic completion
|
||||
# this parameter does not need validation
|
||||
return load_balancer_backend_pool_type
|
||||
|
||||
def _get_enable_pod_security_policy(self, enable_validation: bool = False) -> bool:
|
||||
"""Internal function to obtain the value of enable_pod_security_policy.
|
||||
|
||||
|
@ -2037,7 +2051,7 @@ class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
|
|||
network_profile.ip_families = ip_families
|
||||
|
||||
# recreate the load balancer profile if load_balancer_managed_outbound_ipv6_count is not None
|
||||
if self.context.get_load_balancer_managed_outbound_ipv6_count() is not None:
|
||||
if self.context.get_load_balancer_managed_outbound_ipv6_count() is not None or self.context.get_load_balancer_backend_pool_type() is not None:
|
||||
network_profile.load_balancer_profile = create_load_balancer_profile(
|
||||
self.context.get_load_balancer_managed_outbound_ip_count(),
|
||||
self.context.get_load_balancer_managed_outbound_ipv6_count(),
|
||||
|
@ -2045,6 +2059,7 @@ class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
|
|||
self.context.get_load_balancer_outbound_ip_prefixes(),
|
||||
self.context.get_load_balancer_outbound_ports(),
|
||||
self.context.get_load_balancer_idle_timeout(),
|
||||
self.context.get_load_balancer_backend_pool_type(),
|
||||
models=self.models.load_balancer_models,
|
||||
)
|
||||
|
||||
|
@ -2475,6 +2490,7 @@ class AKSPreviewManagedClusterUpdateDecorator(AKSManagedClusterUpdateDecorator):
|
|||
outbound_ip_prefixes=self.context.get_load_balancer_outbound_ip_prefixes(),
|
||||
outbound_ports=self.context.get_load_balancer_outbound_ports(),
|
||||
idle_timeout=self.context.get_load_balancer_idle_timeout(),
|
||||
backend_pool_type=self.context.get_load_balancer_backend_pool_type(),
|
||||
profile=mc.network_profile.load_balancer_profile,
|
||||
models=self.models.load_balancer_models,
|
||||
)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -3628,6 +3628,34 @@ class AzureKubernetesServiceScenarioTest(ScenarioTest):
|
|||
# delete
|
||||
self.cmd(
|
||||
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])
|
||||
|
||||
@AllowLargeResponse()
|
||||
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='centraluseuap', preserve_default_location=True)
|
||||
def test_aks_create_or_update_with_load_balancer_backend_pool_type(self, resource_group, resource_group_location):
|
||||
_, create_version = self._get_versions(resource_group_location)
|
||||
aks_name = self.create_random_name('cliakstest', 16)
|
||||
self.kwargs.update({
|
||||
'resource_group': resource_group,
|
||||
'name': aks_name,
|
||||
'location': resource_group_location,
|
||||
'k8s_version': create_version,
|
||||
'ssh_key_value': self.generate_ssh_keys(),
|
||||
})
|
||||
|
||||
# create
|
||||
create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \
|
||||
'--ssh-key-value={ssh_key_value} ' \
|
||||
'--kubernetes-version={k8s_version} ' \
|
||||
'--load-balancer-backend-pool-type=nodeIP'
|
||||
self.cmd(create_cmd, checks=[
|
||||
self.check('networkProfile.loadBalancerProfile.backendPoolType', 'nodeIP'),
|
||||
])
|
||||
|
||||
# update
|
||||
update_cmd = 'aks update -g {resource_group} -n {name} --load-balancer-backend-pool-type=nodeIP'
|
||||
self.cmd(update_cmd, checks=[
|
||||
self.check('networkProfile.loadBalancerProfile.backendPoolType', 'nodeIP'),
|
||||
])
|
||||
|
||||
@AllowLargeResponse()
|
||||
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='centraluseuap')
|
||||
|
|
|
@ -31,8 +31,9 @@ class TestLoadBalancer(unittest.TestCase):
|
|||
outbound_ip_prefixes = None
|
||||
outbound_ports = 80
|
||||
idle_timeout = 3600
|
||||
backend_pool_type = "nodeIP"
|
||||
|
||||
# store all the models used by load balancer
|
||||
# store all the models used by load balancer
|
||||
ManagedClusterLoadBalancerProfile = (
|
||||
self.load_balancer_models.ManagedClusterLoadBalancerProfile
|
||||
)
|
||||
|
@ -66,6 +67,7 @@ class TestLoadBalancer(unittest.TestCase):
|
|||
outbound_ip_prefixes,
|
||||
outbound_ports,
|
||||
idle_timeout,
|
||||
backend_pool_type,
|
||||
profile,
|
||||
self.load_balancer_models,
|
||||
)
|
||||
|
@ -76,6 +78,7 @@ class TestLoadBalancer(unittest.TestCase):
|
|||
self.assertEqual(p.outbound_ip_prefixes, None)
|
||||
self.assertEqual(p.allocated_outbound_ports, 80)
|
||||
self.assertEqual(p.idle_timeout_in_minutes, 3600)
|
||||
self.assertEqual(p.backend_pool_type, "nodeIP")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -28,6 +28,7 @@ from azext_aks_preview._consts import (
|
|||
CONST_INGRESS_APPGW_WATCH_NAMESPACE,
|
||||
CONST_KUBE_DASHBOARD_ADDON_NAME,
|
||||
CONST_LOAD_BALANCER_SKU_STANDARD,
|
||||
CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP,
|
||||
CONST_MONITORING_ADDON_NAME,
|
||||
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID,
|
||||
CONST_MONITORING_USING_AAD_MSI_AUTH,
|
||||
|
@ -439,6 +440,20 @@ class AKSPreviewManagedClusterContextTestCase(unittest.TestCase):
|
|||
mc_3 = self.models.ManagedCluster(location="test_location", network_profile=network_profile_3)
|
||||
ctx_3.attach_mc(mc_3)
|
||||
self.assertEqual(ctx_3.get_load_balancer_managed_outbound_ipv6_count(), 20)
|
||||
|
||||
def test_get_load_balancer_backend_pool_type(self):
|
||||
ctx = AKSPreviewManagedClusterContext(
|
||||
self.cmd,
|
||||
AKSManagedClusterParamDict(
|
||||
{
|
||||
"load_balancer_backend_pool_type": "nodeIP",
|
||||
}
|
||||
),
|
||||
self.models,
|
||||
decorator_mode=DecoratorMode.CREATE,
|
||||
)
|
||||
self.assertEqual(ctx.get_load_balancer_backend_pool_type(), "nodeIP")
|
||||
|
||||
|
||||
def test_get_enable_pod_security_policy(self):
|
||||
# default
|
||||
|
@ -3317,6 +3332,7 @@ class AKSPreviewManagedClusterCreateDecoratorTestCase(unittest.TestCase):
|
|||
"load_balancer_outbound_ip_prefixes": None,
|
||||
"load_balancer_outbound_ports": None,
|
||||
"load_balancer_idle_timeout": None,
|
||||
"load_balancer_backend_pool_type": "nodeIP",
|
||||
"outbound_type": None,
|
||||
"network_plugin": None,
|
||||
"pod_cidr": None,
|
||||
|
@ -3346,7 +3362,8 @@ class AKSPreviewManagedClusterCreateDecoratorTestCase(unittest.TestCase):
|
|||
load_balancer_profile_1 = self.models.load_balancer_models.ManagedClusterLoadBalancerProfile(
|
||||
managed_outbound_i_ps=self.models.load_balancer_models.ManagedClusterLoadBalancerProfileManagedOutboundIPs(
|
||||
count_ipv6=3,
|
||||
)
|
||||
),
|
||||
backend_pool_type=CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP,
|
||||
)
|
||||
network_profile_1.load_balancer_profile = load_balancer_profile_1
|
||||
ground_truth_mc_1 = self.models.ManagedCluster(location="test_location", network_profile=network_profile_1)
|
||||
|
|
|
@ -9,7 +9,7 @@ from codecs import open as open1
|
|||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = "0.5.102"
|
||||
VERSION = "0.5.103"
|
||||
CLASSIFIERS = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
|
|
Загрузка…
Ссылка в новой задаче