Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ aks create:
enable_private_cluster:
rule_exclusions:
- option_length_too_long
enable_application_load_balancer:
rule_exclusions:
- option_length_too_long
load_balancer_idle_timeout:
rule_exclusions:
- option_length_too_long
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* Add add-on support for `ApplicationLoadBalancer` (Application Gateway for Containers)
- `az aks applicationloadbalancer enable`: Enable Application Load Balancer add-on for an existing cluster.
- `az aks applicationloadbalancer disable`: Disable Application Load Balancer add-on for an existing cluster.
- `az aks applicationloadbalancer update`: Update Application Load Balancer add-on for an existing cluster.

19.0.0b16
+++++++
Expand Down
9 changes: 8 additions & 1 deletion src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
CONST_DISK_DRIVER_V2 = "v2"

# consts for addons
# application load balancer (Application Gateway for Containers)
CONST_APPLICATION_LOAD_BALANCER_ADDON_NAME = "applicationLoadBalancer"

# http application routing
CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME = "httpApplicationRouting"

Expand Down Expand Up @@ -225,6 +228,7 @@

# all supported addons
ADDONS = {
"application-load-balancer": CONST_APPLICATION_LOAD_BALANCER_ADDON_NAME,
"http_application_routing": CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME,
"monitoring": CONST_MONITORING_ADDON_NAME,
"virtual-node": CONST_VIRTUAL_NODE_ADDON_NAME,
Expand Down Expand Up @@ -255,7 +259,10 @@
"- enable Azure policy. The Azure Policy add-on for AKS enables at-scale enforcements and safeguards on "
"your clusters in a centralized, consistent manner.\nLearn more at aka.ms/aks/policy."
),
CONST_INGRESS_APPGW_ADDON_NAME: "- enable Application Gateway Ingress Controller addon (PREVIEW).",
CONST_APPLICATION_LOAD_BALANCER_ADDON_NAME: (
"- enable Application Load Balancer (Application Gateway for Containers) addon (PREVIEW)."
),
CONST_INGRESS_APPGW_ADDON_NAME: "- enable Application Gateway Ingress Controller addon.",
CONST_CONFCOM_ADDON_NAME: "- enable confcom addon, this will enable SGX device plugin by default (PREVIEW).",
CONST_OPEN_SERVICE_MESH_ADDON_NAME: "- enable Open Service Mesh addon (PREVIEW).",
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME: "- enable Azure Keyvault Secrets Provider addon.",
Expand Down
38 changes: 34 additions & 4 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
- monitoring : turn on Log Analytics monitoring. Uses the Log Analytics Default Workspace if it exists, else creates one. Specify "--workspace-resource-id" to use an existing workspace. If monitoring addon is enabled --no-wait argument will have no effect
- virtual-node : enable AKS Virtual Node. Requires --aci-subnet-name to provide the name of an existing subnet for the Virtual Node to use. aci-subnet-name must be in the same vnet which is specified by --vnet-subnet-id (required as well).
- azure-policy : enable Azure policy. The Azure Policy add-on for AKS enables at-scale enforcements and safeguards on your clusters in a centralized, consistent manner. Required if enabling deployment safeguards. Learn more at aka.ms/aks/policy.
- ingress-appgw : enable Application Gateway Ingress Controller addon (PREVIEW).
- application-load-balancer : enable the Application Load Balancer (Application Gateway for Containers) addon (PREVIEW).
- ingress-appgw : enable Application Gateway Ingress Controller addon.
- confcom : enable confcom addon, this will enable SGX device plugin by default(PREVIEW).
- open-service-mesh : enable Open Service Mesh addon (PREVIEW).
- gitops : enable GitOps (PREVIEW).
Expand Down Expand Up @@ -635,6 +636,9 @@
Auto: A standard set of Karpenter NodePools are provisioned.
None: No Karpenter NodePools are provisioned.
WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted by that action.
- name: --enable-application-load-balancer
type: bool
short-summary: Enable Application Load Balancer (Application Gateway for Containers) addon.
- name: --enable-app-routing
type: bool
short-summary: Enable Application Routing addon.
Expand Down Expand Up @@ -2779,7 +2783,8 @@
virtual-node - enable AKS Virtual Node. Requires --subnet-name to provide the name of an existing subnet for the Virtual Node to use.
azure-policy - enable Azure policy. The Azure Policy add-on for AKS enables at-scale enforcements and safeguards on your clusters in a centralized, consistent manner.
Learn more at aka.ms/aks/policy.
ingress-appgw - enable Application Gateway Ingress Controller addon (PREVIEW).
application-load-balancer - enable the Application Load Balancer (Application Gateway for Containers) addon (PREVIEW).
ingress-appgw - enable Application Gateway Ingress Controller addon.
open-service-mesh - enable Open Service Mesh addon (PREVIEW).
gitops - enable GitOps (PREVIEW).
azure-keyvault-secrets-provider - enable Azure Keyvault Secrets Provider addon.
Expand Down Expand Up @@ -2939,7 +2944,8 @@
virtual-node - enable AKS Virtual Node. Requires --subnet-name to provide the name of an existing subnet for the Virtual Node to use.
azure-policy - enable Azure policy. The Azure Policy add-on for AKS enables at-scale enforcements and safeguards on your clusters in a centralized, consistent manner.
Learn more at aka.ms/aks/policy.
ingress-appgw - enable Application Gateway Ingress Controller addon (PREVIEW).
application-load-balancer - enable the Application Load Balancer (Application Gateway for Containers) addon (PREVIEW).
ingress-appgw - enable Application Gateway Ingress Controller addon.
open-service-mesh - enable Open Service Mesh addon (PREVIEW).
gitops - enable GitOps (PREVIEW).
azure-keyvault-secrets-provider - enable Azure Keyvault Secrets Provider addon.
Expand Down Expand Up @@ -3612,9 +3618,33 @@
text: az aks mesh disable-istio-cni --resource-group MyResourceGroup --name MyManagedCluster
"""

helps['aks applicationloadbalancer'] = """
type: group
short-summary: Commands to manage Application Load Balancer (Application Gateway for Containers) addon.
long-summary: A group of commands to manage Application Load Balancer (Application Gateway for Containers) in given cluster.
"""

helps['aks applicationloadbalancer enable'] = """
type: command
short-summary: Enable Application Load Balancer (Application Gateway for Containers) addon.
long-summary: This command enables Application Load Balancer in given cluster.
"""

helps['aks applicationloadbalancer update'] = """
type: command
short-summary: Update Application Load Balancer (Application Gateway for Containers) addon.
long-summary: This command is used to make a put operation on the Application Load Balancer in a given cluster.
"""

helps['aks applicationloadbalancer disable'] = """
type: command
short-summary: Disable Application Load Balancer (Application Gateway for Containers) addon.
long-summary: This command disables Application Load Balancer (Application Gateway for Containers) in given cluster.
"""

helps['aks approuting'] = """
type: group
short-summary: Commands to manage App Routing aadon.
short-summary: Commands to manage App Routing addon.
long-summary: A group of commands to manage App Routing in given cluster.
"""

Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ def load_arguments(self, _):
c.argument("enable_secret_rotation", action="store_true")
c.argument("rotation_poll_interval")
c.argument("enable_sgxquotehelper", action="store_true")
c.argument("enable_application_load_balancer", action="store_true", is_preview=True)
c.argument("enable_app_routing", action="store_true", is_preview=True)
c.argument(
"app_routing_default_nginx_controller",
Expand Down
18 changes: 18 additions & 0 deletions src/aks-preview/azext_aks_preview/addonconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ def update_addons(
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="managed_clusters",
)
ManagedClusterIngressProfileApplicationLoadBalancer = cmd.get_models(
"ManagedClusterIngressProfileApplicationLoadBalancer",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="managed_clusters",
)
ManagedClusterIngressProfileWebAppRouting = cmd.get_models(
"ManagedClusterIngressProfileWebAppRouting",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
Expand All @@ -261,6 +266,19 @@ def update_addons(

# for each addons argument
for addon_arg in addon_args:
if addon_arg == "applicationloadbalancer":
# application load balancer settings are in ingress profile, not addon profile
if instance.ingress_profile is None:
instance.ingress_profile = ManagedClusterIngressProfile()
if instance.ingress_profile.application_load_balancer is None:
instance.ingress_profile.application_load_balancer = (
ManagedClusterIngressProfileApplicationLoadBalancer()
)

instance.ingress_profile.application_load_balancer.enabled = enable

continue

if addon_arg == "web_application_routing":
# web app routing settings are in ingress profile, not addon profile, so deal
# with it separately
Expand Down
8 changes: 8 additions & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@ def load_command_table(self, _):
g.custom_command("complete", "aks_mesh_upgrade_complete", supports_no_wait=True)
g.custom_command("rollback", "aks_mesh_upgrade_rollback", supports_no_wait=True)

# AKS applicationloadbalancer (Application Gateway for Containers) commands
with self.command_group(
"aks applicationloadbalancer", managed_clusters_sdk, client_factory=cf_managed_clusters
) as g:
g.custom_command("enable", "aks_applicationloadbalancer_enable")
g.custom_command("disable", "aks_applicationloadbalancer_disable", confirmation=True)
g.custom_command("update", "aks_applicationloadbalancer_update")

# AKS approuting commands
with self.command_group(
"aks approuting", managed_clusters_sdk, client_factory=cf_managed_clusters
Expand Down
106 changes: 106 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ def aks_create(
enable_sgxquotehelper=False,
enable_secret_rotation=False,
rotation_poll_interval=None,
enable_application_load_balancer=False,
enable_app_routing=False,
app_routing_default_nginx_controller=None,
# nodepool paramerters
Expand Down Expand Up @@ -2663,6 +2664,12 @@ def aks_addon_list(cmd, client, resource_group_name, name):
mc.ingress_profile.web_app_routing and
mc.ingress_profile.web_app_routing.enabled
)
elif addon_name == "application-load-balancer":
enabled = bool(
mc.ingress_profile and
mc.ingress_profile.application_load_balancer and
mc.ingress_profile.application_load_balancer.enabled
)
else:
if addon_name == "virtual-node":
addon_key += os_type
Expand Down Expand Up @@ -2699,6 +2706,20 @@ def aks_addon_show(cmd, client, resource_group_name, name, addon):
"config": mc.ingress_profile.web_app_routing,
}

# application-load-balancer is a special case, the configuration is stored in a separate profile
if addon == "application-load-balancer":
if (
not mc.ingress_profile and
not mc.ingress_profile.application_load_balancer and
not mc.ingress_profile.application_load_balancer.enabled
):
raise InvalidArgumentValueError(f'Addon "{addon}" is not enabled in this cluster.')
return {
"name": addon,
"api_key": addon_key,
"config": mc.ingress_profile.application_load_balancer,
}

# normal addons
if not mc.addon_profiles or addon_key not in mc.addon_profiles or not mc.addon_profiles[addon_key].enabled:
raise InvalidArgumentValueError(f'Addon "{addon}" is not enabled in this cluster.')
Expand Down Expand Up @@ -3096,6 +3117,11 @@ def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="managed_clusters",
)
ManagedClusterIngressProfileApplicationLoadBalancer = cmd.get_models(
"ManagedClusterIngressProfileApplicationLoadBalancer",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="managed_clusters",
)
ManagedClusterIngressProfileWebAppRouting = cmd.get_models(
"ManagedClusterIngressProfileWebAppRouting",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
Expand All @@ -3111,6 +3137,16 @@ def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements

# for each addons argument
for addon_arg in addon_args:
if addon_arg == "applicationloadbalancer":
# application load balancer routing settings are in ingress profile, not addon profile
if instance.ingress_profile is None:
instance.ingress_profile = ManagedClusterIngressProfile()
if instance.ingress_profile.application_load_balancer is None:
instance.ingress_profile.application_load_balancer = ManagedClusterIngressProfileApplicationLoadBalancer()
instance.ingress_profile.application_load_balancer.enabled = enable

continue

if addon_arg == "web_application_routing":
# web app routing settings are in ingress profile, not addon profile, so deal
# with it separately
Expand Down Expand Up @@ -4115,6 +4151,47 @@ def _aks_mesh_update(
return aks_update_decorator.update_mc(mc)


def aks_applicationloadbalancer_enable(
cmd,
client,
resource_group_name,
name
):
return _aks_applicationloadbalancer_update(
cmd,
client,
resource_group_name,
name,
enable_application_load_balancer=True)


def aks_applicationloadbalancer_disable(
cmd,
client,
resource_group_name,
name
):
return _aks_applicationloadbalancer_update(
cmd,
client,
resource_group_name,
name,
enable_application_load_balancer=False)


def aks_applicationloadbalancer_update(
cmd,
client,
resource_group_name,
name
):
return _aks_applicationloadbalancer_update(
cmd,
client,
resource_group_name,
name)


def aks_approuting_enable(
cmd,
client,
Expand Down Expand Up @@ -4247,6 +4324,35 @@ def aks_approuting_zone_list(
raise CLIError('App routing addon is not enabled')


# pylint: disable=unused-argument
def _aks_applicationloadbalancer_update(
cmd,
client,
resource_group_name,
name,
enable_application_load_balancer=None
):
from azure.cli.command_modules.acs._consts import DecoratorEarlyExitException
from azext_aks_preview.managed_cluster_decorator import AKSPreviewManagedClusterUpdateDecorator

raw_parameters = locals()

aks_update_decorator = AKSPreviewManagedClusterUpdateDecorator(
cmd=cmd,
client=client,
raw_parameters=raw_parameters,
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
)

try:
mc = aks_update_decorator.fetch_mc()
mc = aks_update_decorator.update_application_load_balancer_profile(mc)
except DecoratorEarlyExitException:
return None

return aks_update_decorator.update_mc(mc)


# pylint: disable=unused-argument
def _aks_approuting_update(
cmd,
Expand Down
Loading
Loading