|
42 | 42 | CONST_DNS_ZONE_CONTRIBUTOR_ROLE, |
43 | 43 | CONST_ARTIFACT_SOURCE_CACHE, |
44 | 44 | CONST_NONE_UPGRADE_CHANNEL, |
| 45 | + CONST_AVAILABILITY_SET, |
| 46 | + CONST_VIRTUAL_MACHINES, |
45 | 47 | ) |
46 | 48 | from azure.cli.command_modules.acs._helpers import ( |
47 | 49 | check_is_managed_aad_cluster, |
@@ -2250,7 +2252,7 @@ def _get_outbound_type( |
2250 | 2252 | "for more details." |
2251 | 2253 | ) |
2252 | 2254 | if isBasicSKULb: |
2253 | | - if outbound_type is not None: |
| 2255 | + if not read_from_mc and outbound_type is not None: # outbound type was default to loadbalancer for BLB creation |
2254 | 2256 | raise InvalidArgumentValueError( |
2255 | 2257 | "{outbound_type} doesn't support basic load balancer sku".format(outbound_type=outbound_type) |
2256 | 2258 | ) |
@@ -5500,6 +5502,12 @@ def get_disable_static_egress_gateway(self) -> bool: |
5500 | 5502 | # because it's already checked in get_enable_static_egress_gateway |
5501 | 5503 | return self.raw_param.get("disable_static_egress_gateway") |
5502 | 5504 |
|
| 5505 | + def get_migrate_vmas_to_vms(self) -> bool: |
| 5506 | + """Obtain the value of migrate_vmas_to_vms. |
| 5507 | + :return: bool |
| 5508 | + """ |
| 5509 | + return self.raw_param.get("migrate_vmas_to_vms") |
| 5510 | + |
5503 | 5511 |
|
5504 | 5512 | class AKSManagedClusterCreateDecorator(BaseAKSManagedClusterDecorator): |
5505 | 5513 | def __init__( |
@@ -8781,6 +8789,34 @@ def update_static_egress_gateway(self, mc: ManagedCluster) -> ManagedCluster: |
8781 | 8789 | mc.network_profile.static_egress_gateway_profile.enabled = False |
8782 | 8790 | return mc |
8783 | 8791 |
|
| 8792 | + def update_vmas_to_vms(self, mc: ManagedCluster) -> ManagedCluster: |
| 8793 | + """Update the agent pool profile type from VMAS to VMS and LB sku to standard |
| 8794 | + :return: the ManagedCluster object |
| 8795 | + """ |
| 8796 | + self._ensure_mc(mc) |
| 8797 | + |
| 8798 | + if self.context.get_migrate_vmas_to_vms(): |
| 8799 | + msg = ( |
| 8800 | + "\nWARNING: This operation will be disruptive to your workload while underway. " |
| 8801 | + "Do you wish to continue?" |
| 8802 | + ) |
| 8803 | + if not self.context.get_yes() and not prompt_y_n(msg, default="n"): |
| 8804 | + raise DecoratorEarlyExitException() |
| 8805 | + # Ensure we have valid vmas AP |
| 8806 | + if len(mc.agent_pool_profiles) == 1 and mc.agent_pool_profiles[0].type == CONST_AVAILABILITY_SET: |
| 8807 | + mc.agent_pool_profiles[0].type = CONST_VIRTUAL_MACHINES |
| 8808 | + else: |
| 8809 | + raise ArgumentUsageError('This is not a valid VMAS cluster with {} agent pool profiles and {} agent pool type, we cannot proceed with the migration.'.format(len(mc.agent_pool_profiles), mc.agent_pool_profiles[0].type)) |
| 8810 | + |
| 8811 | + if mc.network_profile.load_balancer_sku == CONST_LOAD_BALANCER_SKU_BASIC: |
| 8812 | + mc.network_profile.load_balancer_sku = CONST_LOAD_BALANCER_SKU_STANDARD |
| 8813 | + |
| 8814 | + # Set agent pool profile count and vm_size to None |
| 8815 | + mc.agent_pool_profiles[0].count = None |
| 8816 | + mc.agent_pool_profiles[0].vm_size = None |
| 8817 | + |
| 8818 | + return mc |
| 8819 | + |
8784 | 8820 | def update_mc_profile_default(self) -> ManagedCluster: |
8785 | 8821 | """The overall controller used to update the default ManagedCluster profile. |
8786 | 8822 |
|
@@ -8868,6 +8904,8 @@ def update_mc_profile_default(self) -> ManagedCluster: |
8868 | 8904 | mc = self.update_static_egress_gateway(mc) |
8869 | 8905 | # update kubernetes version and orchestrator version |
8870 | 8906 | mc = self.update_kubernetes_version_and_orchestrator_version(mc) |
| 8907 | + # update VMAS to VMS |
| 8908 | + mc = self.update_vmas_to_vms(mc) |
8871 | 8909 | return mc |
8872 | 8910 |
|
8873 | 8911 | def update_kubernetes_version_and_orchestrator_version(self, mc: ManagedCluster) -> ManagedCluster: |
|
0 commit comments