|
44 | 44 | CONST_IMDS_RESTRICTION_DISABLED, |
45 | 45 | CONST_AVAILABILITY_SET, |
46 | 46 | CONST_VIRTUAL_MACHINES, |
| 47 | + CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD, |
| 48 | + CONST_MANAGED_GATEWAY_INSTALLATION_DISABLED, |
47 | 49 | CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH, |
48 | 50 | CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE |
49 | 51 | ) |
@@ -3567,6 +3569,20 @@ def get_disable_upstream_kubescheduler_user_configuration(self) -> bool: |
3567 | 3569 | ) |
3568 | 3570 | return disable_upstream_kubescheduler_user_configuration |
3569 | 3571 |
|
| 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 | + |
3570 | 3586 |
|
3571 | 3587 | # pylint: disable=too-many-public-methods |
3572 | 3588 | class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator): |
@@ -3953,6 +3969,25 @@ def set_up_ingress_web_app_routing(self, mc: ManagedCluster) -> ManagedCluster: |
3953 | 3969 |
|
3954 | 3970 | return mc |
3955 | 3971 |
|
| 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 | + |
3956 | 3991 | def set_up_workload_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedCluster: |
3957 | 3992 | """Set up workload auto-scaler profile for the ManagedCluster object. |
3958 | 3993 |
|
@@ -4600,6 +4635,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) -> |
4600 | 4635 | mc = self.set_up_creationdata_of_cluster_snapshot(mc) |
4601 | 4636 | # set up app routing profile |
4602 | 4637 | 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) |
4603 | 4640 | # set up workload auto scaler profile |
4604 | 4641 | mc = self.set_up_workload_auto_scaler_profile(mc) |
4605 | 4642 | # set up vpa |
@@ -6608,6 +6645,36 @@ def _update_dns_zone_resource_ids(self, mc: ManagedCluster, dns_zone_resource_id |
6608 | 6645 | else: |
6609 | 6646 | raise CLIError('App Routing must be enabled to modify DNS zone resource IDs.\n') |
6610 | 6647 |
|
| 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 | + |
6611 | 6678 | def update_node_provisioning_profile(self, mc: ManagedCluster) -> ManagedCluster: |
6612 | 6679 | """Updates the nodeProvisioningProfile field of the managed cluster |
6613 | 6680 |
|
@@ -7069,6 +7136,8 @@ def update_mc_profile_preview(self) -> ManagedCluster: |
7069 | 7136 | mc = self.update_nat_gateway_profile(mc) |
7070 | 7137 | # update kube proxy config |
7071 | 7138 | mc = self.update_kube_proxy_config(mc) |
| 7139 | + # update ingress profile gateway api |
| 7140 | + mc = self.update_ingress_profile_gateway_api(mc) |
7072 | 7141 | # update custom ca trust certificates |
7073 | 7142 | mc = self.update_custom_ca_trust_certificates(mc) |
7074 | 7143 | # update run command |
|
0 commit comments