Skip to content

Commit e572f0a

Browse files
authored
Add CLI for Managed Gateway API Installation (#9077)
1 parent 363f221 commit e572f0a

File tree

10 files changed

+4529
-2
lines changed

10 files changed

+4529
-2
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* Added `--enable-gateway-api` to `az aks create` to enable managed Gateway API installation
15+
* Added `--enable-gateway-api` and `--disable-gateway-api` to `az aks update` to enable/disable managed Gateway API installation
1416

1517
19.0.0b3
1618
+++++++

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@
218218
CONST_APP_ROUTING_INTERNAL_NGINX = "Internal"
219219
CONST_APP_ROUTING_NONE_NGINX = "None"
220220

221+
# managed gateway api installation
222+
CONST_MANAGED_GATEWAY_INSTALLATION_DISABLED = "Disabled"
223+
CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD = "Standard"
224+
221225
# all supported addons
222226
ADDONS = {
223227
"http_application_routing": CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME,

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@
686686
- name: --enable-upstream-kubescheduler-user-configuration
687687
type: bool
688688
short-summary: Enable user-defined scheduler configuration for kube-scheduler upstream on the cluster
689+
- name: --enable-gateway-api
690+
type: bool
691+
short-summary: Enable managed installation of Gateway API CRDs from the standard release channel. Requires at least one managed Gateway API ingress provider to be enabled.
689692
examples:
690693
- name: Create a Kubernetes cluster with an existing SSH public key.
691694
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
@@ -775,6 +778,8 @@
775778
text: az aks create -g MyResourceGroup -n MyManagedCluster --vm-set-type VirtualMachines --vm-sizes "VMSize1,VMSize2" --node-count 3
776779
- name: Create a kubernetes cluster with a fully managed system node pool
777780
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-managed-system-pool
781+
- name: Create a kubernetes cluster with the Azure Service Mesh addon enabled with a managed installation of Gateway API CRDs from the standard release channel.
782+
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-azure-service-mesh --enable-gateway-api
778783
779784
"""
780785

@@ -1392,6 +1397,12 @@
13921397
- name: --disable-upstream-kubescheduler-user-configuration
13931398
type: bool
13941399
short-summary: Disable user-defined scheduler configuration for kube-scheduler upstream on the cluster
1400+
- name: --enable-gateway-api
1401+
type: bool
1402+
short-summary: Enable managed installation of Gateway API CRDs from the standard release channel. Requires at least one managed Gateway API ingress provider to be enabled.
1403+
- name: --disable-gateway-api
1404+
type: bool
1405+
short-summary: Disable managed installation of Gateway API CRDs.
13951406
examples:
13961407
- name: Reconcile the cluster back to its current state.
13971408
text: az aks update -g MyResourceGroup -n MyManagedCluster
@@ -1461,6 +1472,10 @@
14611472
text: az aks update -g MyResourceGroup -n MyManagedCluster --disable-azure-monitor-logs
14621473
- name: Update a kubernetes cluster to clear any namespaces excluded from safeguards. Assumes azure policy addon is already enabled
14631474
text: az aks update -g MyResourceGroup -n MyManagedCluster --safeguards-excluded-ns ""
1475+
- name: Update a kubernetes cluster to enable a managed installation of Gateway API CRDs from the standard release channel.
1476+
text: az aks update -g MyResourceGroup -n MyManagedCluster --enable-gateway-api
1477+
- name: Update a kubernetes cluster to disable the managed installation of Gateway API CRDs.
1478+
text: az aks update -g MyResourceGroup -n MyManagedCluster --disable-gateway-api
14641479
- name: Enable OpenTelemetry metrics collection on an existing cluster
14651480
text: az aks update -g MyResourceGroup -n MyManagedCluster --enable-opentelemetry-metrics
14661481
- name: Enable OpenTelemetry logs collection on an existing cluster

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,11 @@ def load_arguments(self, _):
11801180
is_preview=True,
11811181
deprecate_info=c.deprecate(target="--enable-managed-system-pool", hide=True))
11821182
c.argument("enable_upstream_kubescheduler_user_configuration", action="store_true", is_preview=True)
1183+
c.argument(
1184+
"enable_gateway_api",
1185+
action="store_true",
1186+
help="Enable managed installation of Gateway API CRDs from the standard release channel."
1187+
)
11831188

11841189
with self.argument_context("aks update") as c:
11851190
# managed cluster paramerters
@@ -1718,6 +1723,16 @@ def load_arguments(self, _):
17181723
c.argument("enable_http_proxy", action="store_true", is_preview=True)
17191724
c.argument("enable_upstream_kubescheduler_user_configuration", action="store_true", is_preview=True)
17201725
c.argument("disable_upstream_kubescheduler_user_configuration", action="store_true", is_preview=True)
1726+
c.argument(
1727+
"enable_gateway_api",
1728+
action="store_true",
1729+
help="Enable managed installation of Gateway API CRDs from the standard release channel."
1730+
)
1731+
c.argument(
1732+
"disable_gateway_api",
1733+
action="store_true",
1734+
help="Disable managed installation of Gateway API CRDs."
1735+
)
17211736

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

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ def aks_create(
11511151
# managed system pool
11521152
enable_managed_system_pool=False,
11531153
enable_upstream_kubescheduler_user_configuration=False,
1154+
# managed gateway installation
1155+
enable_gateway_api=False
11541156
):
11551157
# DO NOT MOVE: get all the original parameters and save them as a dictionary
11561158
raw_parameters = locals()
@@ -1386,6 +1388,9 @@ def aks_update(
13861388
migrate_vmas_to_vms=False,
13871389
enable_upstream_kubescheduler_user_configuration=False,
13881390
disable_upstream_kubescheduler_user_configuration=False,
1391+
# managed gateway installation
1392+
enable_gateway_api=False,
1393+
disable_gateway_api=False,
13891394
):
13901395
# DO NOT MOVE: get all the original parameters and save them as a dictionary
13911396
raw_parameters = locals()

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
CONST_IMDS_RESTRICTION_DISABLED,
4545
CONST_AVAILABILITY_SET,
4646
CONST_VIRTUAL_MACHINES,
47+
CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD,
48+
CONST_MANAGED_GATEWAY_INSTALLATION_DISABLED,
4749
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
4850
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
4951
)
@@ -3567,6 +3569,20 @@ def get_disable_upstream_kubescheduler_user_configuration(self) -> bool:
35673569
)
35683570
return disable_upstream_kubescheduler_user_configuration
35693571

3572+
def get_enable_gateway_api(self) -> bool:
3573+
"""Obtain the value of enable_gateway_api.
3574+
3575+
:return: bool
3576+
"""
3577+
return self.raw_param.get("enable_gateway_api", False)
3578+
3579+
def get_disable_gateway_api(self) -> bool:
3580+
"""Obtain the value of disable_gateway_api.
3581+
3582+
:return: bool
3583+
"""
3584+
return self.raw_param.get("disable_gateway_api", False)
3585+
35703586

35713587
# pylint: disable=too-many-public-methods
35723588
class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
@@ -3953,6 +3969,25 @@ def set_up_ingress_web_app_routing(self, mc: ManagedCluster) -> ManagedCluster:
39533969

39543970
return mc
39553971

3972+
def set_up_ingress_profile_gateway_api(self, mc: ManagedCluster) -> ManagedCluster:
3973+
"""Set up Gateway API configuration in ingress profile for the ManagedCluster object.
3974+
3975+
:return: the ManagedCluster object
3976+
"""
3977+
self._ensure_mc(mc)
3978+
3979+
if self.context.get_enable_gateway_api():
3980+
if mc.ingress_profile is None:
3981+
mc.ingress_profile = self.models.ManagedClusterIngressProfile() # pylint: disable=no-member
3982+
if mc.ingress_profile.gateway_api is None:
3983+
mc.ingress_profile.gateway_api = (
3984+
self.models.ManagedClusterIngressProfileGatewayConfiguration( # pylint: disable=no-member
3985+
installation=CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD
3986+
)
3987+
)
3988+
3989+
return mc
3990+
39563991
def set_up_workload_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedCluster:
39573992
"""Set up workload auto-scaler profile for the ManagedCluster object.
39583993
@@ -4600,6 +4635,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
46004635
mc = self.set_up_creationdata_of_cluster_snapshot(mc)
46014636
# set up app routing profile
46024637
mc = self.set_up_ingress_web_app_routing(mc)
4638+
# set up gateway api profile
4639+
mc = self.set_up_ingress_profile_gateway_api(mc)
46034640
# set up workload auto scaler profile
46044641
mc = self.set_up_workload_auto_scaler_profile(mc)
46054642
# set up vpa
@@ -6608,6 +6645,36 @@ def _update_dns_zone_resource_ids(self, mc: ManagedCluster, dns_zone_resource_id
66086645
else:
66096646
raise CLIError('App Routing must be enabled to modify DNS zone resource IDs.\n')
66106647

6648+
def update_ingress_profile_gateway_api(self, mc: ManagedCluster) -> ManagedCluster:
6649+
"""Update Gateway API configuration in ingress profile for the ManagedCluster object.
6650+
6651+
:return: the ManagedCluster object
6652+
"""
6653+
self._ensure_mc(mc)
6654+
6655+
enable_gateway_api = self.context.get_enable_gateway_api()
6656+
disable_gateway_api = self.context.get_disable_gateway_api()
6657+
6658+
# Check for mutually exclusive arguments
6659+
if enable_gateway_api and disable_gateway_api:
6660+
raise MutuallyExclusiveArgumentError(
6661+
"Cannot specify --enable-gateway-api and --disable-gateway-api at the same time."
6662+
)
6663+
6664+
if enable_gateway_api or disable_gateway_api:
6665+
if mc.ingress_profile is None:
6666+
mc.ingress_profile = self.models.ManagedClusterIngressProfile() # pylint: disable=no-member
6667+
if mc.ingress_profile.gateway_api is None:
6668+
mc.ingress_profile.gateway_api = (
6669+
self.models.ManagedClusterIngressProfileGatewayConfiguration() # pylint: disable=no-member
6670+
)
6671+
if enable_gateway_api:
6672+
mc.ingress_profile.gateway_api.installation = CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD
6673+
elif disable_gateway_api:
6674+
mc.ingress_profile.gateway_api.installation = CONST_MANAGED_GATEWAY_INSTALLATION_DISABLED
6675+
6676+
return mc
6677+
66116678
def update_node_provisioning_profile(self, mc: ManagedCluster) -> ManagedCluster:
66126679
"""Updates the nodeProvisioningProfile field of the managed cluster
66136680
@@ -7069,6 +7136,8 @@ def update_mc_profile_preview(self) -> ManagedCluster:
70697136
mc = self.update_nat_gateway_profile(mc)
70707137
# update kube proxy config
70717138
mc = self.update_kube_proxy_config(mc)
7139+
# update ingress profile gateway api
7140+
mc = self.update_ingress_profile_gateway_api(mc)
70727141
# update custom ca trust certificates
70737142
mc = self.update_custom_ca_trust_certificates(mc)
70747143
# update run command

0 commit comments

Comments
 (0)