Skip to content

Commit 78a9f91

Browse files
committed
Missing update and passing test
1 parent 5998eb8 commit 78a9f91

File tree

6 files changed

+2331
-132
lines changed

6 files changed

+2331
-132
lines changed

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,12 @@
14211421
- name: --disable-gateway-api
14221422
type: bool
14231423
short-summary: Disable managed installation of Gateway API CRDs.
1424+
- name: --enable-application-load-balancer
1425+
type: bool
1426+
short-summary: Enable Application Load Balancer (Application Gateway for Containers) addon.
1427+
- name: --disable-application-load-balancer
1428+
type: bool
1429+
short-summary: Disable Application Load Balancer (Application Gateway for Containers) addon.
14241430
examples:
14251431
- name: Reconcile the cluster back to its current state.
14261432
text: az aks update -g MyResourceGroup -n MyManagedCluster

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,18 @@ def load_arguments(self, _):
17661766
action="store_true",
17671767
help="Disable managed installation of Gateway API CRDs."
17681768
)
1769+
c.argument(
1770+
"enable_application_load_balancer",
1771+
action="store_true",
1772+
is_preview=True,
1773+
help="Enable Application Load Balancer (Application Gateway for Containers)."
1774+
)
1775+
c.argument(
1776+
"disable_application_load_balancer",
1777+
action="store_true",
1778+
is_preview=True,
1779+
help="Disable Application Load Balancer (Application Gateway for Containers)."
1780+
)
17691781

17701782
with self.argument_context("aks upgrade") as c:
17711783
c.argument("kubernetes_version", completer=get_k8s_upgrades_completion_list)

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,9 @@ def aks_update(
14001400
# managed gateway installation
14011401
enable_gateway_api=False,
14021402
disable_gateway_api=False,
1403+
# application load balancer
1404+
enable_application_load_balancer=False,
1405+
disable_application_load_balancer=False,
14031406
):
14041407
# DO NOT MOVE: get all the original parameters and save them as a dictionary
14051408
raw_parameters = locals()

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,13 @@ def get_enable_application_load_balancer(self) -> bool:
34153415
"""
34163416
return self.raw_param.get("enable_application_load_balancer")
34173417

3418+
def get_disable_application_load_balancer(self) -> bool:
3419+
"""Obtain the value of disable_application_load_balancer.
3420+
3421+
:return: bool
3422+
"""
3423+
return self.raw_param.get("disable_application_load_balancer")
3424+
34183425
def get_enable_app_routing(self) -> bool:
34193426
"""Obtain the value of enable_app_routing.
34203427
@@ -6645,25 +6652,37 @@ def update_application_load_balancer_profile(self, mc: ManagedCluster) -> Manage
66456652

66466653
# get parameters from context
66476654
enable_application_load_balancer = self.context.get_enable_application_load_balancer()
6655+
disable_application_load_balancer = self.context.get_disable_application_load_balancer()
6656+
6657+
# Check for mutually exclusive arguments
6658+
if enable_application_load_balancer and disable_application_load_balancer:
6659+
raise MutuallyExclusiveArgumentError(
6660+
"Cannot specify --enable-application-load-balancer and "
6661+
"--disable-application-load-balancer at the same time."
6662+
)
66486663

66496664
# update ManagedCluster object with application load balancer settings
6650-
mc.ingress_profile = (
6651-
mc.ingress_profile or
6652-
self.models.ManagedClusterIngressProfile() # pylint: disable=no-member
6653-
)
6654-
mc.ingress_profile.application_load_balancer = (
6655-
mc.ingress_profile.application_load_balancer or
6656-
self.models.ManagedClusterIngressProfileApplicationLoadBalancer() # pylint: disable=no-member
6657-
)
6658-
if enable_application_load_balancer is not None:
6659-
if mc.ingress_profile.application_load_balancer.enabled == enable_application_load_balancer:
6660-
error_message = (
6661-
"Application Load Balancer (Application Gateway for Containers) is already enabled.\n"
6662-
if enable_application_load_balancer
6663-
else "Application Load Balancer (Application Gateway for Containers) is already disabled.\n"
6664-
)
6665-
raise CLIError(error_message)
6666-
mc.ingress_profile.application_load_balancer.enabled = enable_application_load_balancer
6665+
if enable_application_load_balancer or disable_application_load_balancer:
6666+
mc.ingress_profile = (
6667+
mc.ingress_profile or
6668+
self.models.ManagedClusterIngressProfile() # pylint: disable=no-member
6669+
)
6670+
mc.ingress_profile.application_load_balancer = (
6671+
mc.ingress_profile.application_load_balancer or
6672+
self.models.ManagedClusterIngressProfileApplicationLoadBalancer() # pylint: disable=no-member
6673+
)
6674+
if enable_application_load_balancer:
6675+
if mc.ingress_profile.application_load_balancer.enabled:
6676+
raise CLIError(
6677+
"Application Load Balancer (Application Gateway for Containers) is already enabled.\n"
6678+
)
6679+
mc.ingress_profile.application_load_balancer.enabled = True
6680+
elif disable_application_load_balancer:
6681+
if mc.ingress_profile.application_load_balancer.enabled is False:
6682+
raise CLIError(
6683+
"Application Load Balancer (Application Gateway for Containers) is already disabled.\n"
6684+
)
6685+
mc.ingress_profile.application_load_balancer.enabled = False
66676686

66686687
return mc
66696688

@@ -7312,6 +7331,8 @@ def update_mc_profile_preview(self) -> ManagedCluster:
73127331
mc = self.update_nat_gateway_profile(mc)
73137332
# update kube proxy config
73147333
mc = self.update_kube_proxy_config(mc)
7334+
# update application load balancer profile
7335+
mc = self.update_application_load_balancer_profile(mc)
73157336
# update ingress profile gateway api
73167337
mc = self.update_ingress_profile_gateway_api(mc)
73177338
# update custom ca trust certificates

0 commit comments

Comments
 (0)