@@ -5469,6 +5469,37 @@ def get_bootstrap_container_registry_resource_id(self) -> Union[str, None]:
54695469 """
54705470 return self .raw_param .get ("bootstrap_container_registry_resource_id" )
54715471
5472+ def _get_enable_static_egress_gateway (self , enable_validation : bool = False ) -> bool :
5473+ """Internal function to obtain the value of enable_static_egress_gateway.
5474+ When enabled, if both enable_static_egress_gateway and disable_static_egress_gateway are
5475+ specified, raise a MutuallyExclusiveArgumentError.
5476+ :return: bool
5477+ """
5478+ enable_static_egress_gateway = self .raw_param .get ("enable_static_egress_gateway" )
5479+ # This parameter does not need dynamic completion.
5480+ if enable_validation :
5481+ if enable_static_egress_gateway and self .get_disable_static_egress_gateway ():
5482+ raise MutuallyExclusiveArgumentError (
5483+ "Cannot specify --enable-static-egress-gateway and "
5484+ "--disable-static-egress-gateway at the same time. "
5485+ )
5486+
5487+ return enable_static_egress_gateway
5488+
5489+ def get_enable_static_egress_gateway (self ) -> bool :
5490+ """Obtain the value of enable_static_egress_gateway.
5491+ :return: bool
5492+ """
5493+ return self ._get_enable_static_egress_gateway (enable_validation = True )
5494+
5495+ def get_disable_static_egress_gateway (self ) -> bool :
5496+ """Obtain the value of disable_static_egress_gateway.
5497+ :return: bool
5498+ """
5499+ # Note: No need to check for mutually exclusive parameter with enable-static-egress-gateway here
5500+ # because it's already checked in get_enable_static_egress_gateway
5501+ return self .raw_param .get ("disable_static_egress_gateway" )
5502+
54725503
54735504class AKSManagedClusterCreateDecorator (BaseAKSManagedClusterDecorator ):
54745505 def __init__ (
@@ -6787,6 +6818,25 @@ def set_up_bootstrap_profile(self, mc: ManagedCluster) -> ManagedCluster:
67876818
67886819 return mc
67896820
6821+ def set_up_static_egress_gateway (self , mc : ManagedCluster ) -> ManagedCluster :
6822+ self ._ensure_mc (mc )
6823+
6824+ if self .context .get_enable_static_egress_gateway ():
6825+ if not mc .network_profile :
6826+ raise UnknownError (
6827+ "Unexpectedly get an empty network profile in the process of "
6828+ "updating enable-static-egress-gateway config."
6829+ )
6830+ if mc .network_profile .static_egress_gateway_profile is None :
6831+ mc .network_profile .static_egress_gateway_profile = (
6832+ self .models .ManagedClusterStaticEgressGatewayProfile () # pylint: disable=no-member
6833+ )
6834+ # set enabled
6835+ mc .network_profile .static_egress_gateway_profile .enabled = True
6836+
6837+ # Default is disabled so no need to worry about that here
6838+ return mc
6839+
67906840 def construct_mc_profile_default (self , bypass_restore_defaults : bool = False ) -> ManagedCluster :
67916841 """The overall controller used to construct the default ManagedCluster profile.
67926842
@@ -6871,6 +6921,8 @@ def construct_mc_profile_default(self, bypass_restore_defaults: bool = False) ->
68716921 mc = self .set_up_node_resource_group_profile (mc )
68726922 # set up bootstrap profile
68736923 mc = self .set_up_bootstrap_profile (mc )
6924+ # set up static egress gateway profile
6925+ mc = self .set_up_static_egress_gateway (mc )
68746926
68756927 # DO NOT MOVE: keep this at the bottom, restore defaults
68766928 if not bypass_restore_defaults :
@@ -8700,6 +8752,35 @@ def update_bootstrap_profile(self, mc: ManagedCluster) -> ManagedCluster:
87008752
87018753 return mc
87028754
8755+ def update_static_egress_gateway (self , mc : ManagedCluster ) -> ManagedCluster :
8756+ """Update static egress gateway addon for the ManagedCluster object.
8757+ :return: the ManagedCluster object
8758+ """
8759+ self ._ensure_mc (mc )
8760+
8761+ if self .context .get_enable_static_egress_gateway ():
8762+ if not mc .network_profile :
8763+ raise UnknownError (
8764+ "Unexpectedly get an empty network profile in the process of updating static-egress-gateway config."
8765+ )
8766+ if mc .network_profile .static_egress_gateway_profile is None :
8767+ mc .network_profile .static_egress_gateway_profile = (
8768+ self .models .ManagedClusterStaticEgressGatewayProfile () # pylint: disable=no-member
8769+ )
8770+ mc .network_profile .static_egress_gateway_profile .enabled = True
8771+
8772+ if self .context .get_disable_static_egress_gateway ():
8773+ if not mc .network_profile :
8774+ raise UnknownError (
8775+ "Unexpectedly get an empty network profile in the process of updating static-egress-gateway config."
8776+ )
8777+ if mc .network_profile .static_egress_gateway_profile is None :
8778+ mc .network_profile .static_egress_gateway_profile = (
8779+ self .models .ManagedClusterStaticEgressGatewayProfile () # pylint: disable=no-member
8780+ )
8781+ mc .network_profile .static_egress_gateway_profile .enabled = False
8782+ return mc
8783+
87038784 def update_mc_profile_default (self ) -> ManagedCluster :
87048785 """The overall controller used to update the default ManagedCluster profile.
87058786
@@ -8783,6 +8864,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
87838864 mc = self .update_node_resource_group_profile (mc )
87848865 # update bootstrap profile
87858866 mc = self .update_bootstrap_profile (mc )
8867+ # update static egress gateway
8868+ mc = self .update_static_egress_gateway (mc )
87868869 # update kubernetes version and orchestrator version
87878870 mc = self .update_kubernetes_version_and_orchestrator_version (mc )
87888871 return mc
0 commit comments