Skip to content

Commit

Permalink
Vmss OrchestrationMode (#15349)
Browse files Browse the repository at this point in the history
* orchestration mode

* Orchestration mode updated test/ recording

* changelog

Co-authored-by: Beisi Zhou <[email protected]>
  • Loading branch information
grizzlytheodore and BethanyZhou authored Jun 25, 2021
1 parent 817efd1 commit 31d712f
Show file tree
Hide file tree
Showing 10 changed files with 1,687 additions and 1,139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2596,19 +2596,55 @@ function Test-VirtualMachineScaleSetOrchestrationVM
$vmssName = 'vmssOrchestrationMode' + $rgname;
$vmName = 'vm' + $rgname;
$domainName = 'domain' + $rgname;

$adminUsername = 'Foo12';
$adminPassword = $PLACEHOLDER;

$securePassword = ConvertTo-SecureString $adminPassword -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $securePassword);

$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$vneid = $vnet.Id
$subnetId = $vnet.Subnets[0].Id;

$VmssConfigWithoutVmProfile = new-azvmssconfig -location $loc -platformfaultdomain 1
$VmssWithoutVmProfile = new-azvmss -resourcegroupname $rgname -vmscalesetname $vmssName -virtualmachinescaleset $VmssConfigWithoutVmProfile

$vm = new-azvm -resourcegroupname $rgname -location $loc -name $vmname -credential $cred -domainnamelabel $domainName -vmssid $VmssWithoutVmProfile.id

Assert-AreEqual $VmssWithoutVmProfile.id $vm.virtualmachinescaleset.id
$ipConfig = New-AzVmssIpConfig -Name 'test' -SubnetId $subnetId

$vmssConfig = New-AzVmssConfig `
-Location $loc `
-SkuCapacity 2 `
-SkuName "Standard_DS1_v2" `
-OrchestrationMode 'Flexible' `
-PlatformFaultDomainCount 2

Set-AzVmssStorageProfile $vmssConfig `
-OsDiskCreateOption "FromImage" `
-ImageReferencePublisher "Canonical" `
-ImageReferenceOffer "UbuntuServer" `
-ImageReferenceSku "18.04-LTS" `
-ImageReferenceVersion "latest"

Set-AzVmssOsProfile $vmssConfig `
-AdminUsername $cred.UserName `
-AdminPassword $cred.Password `
-ComputerNamePrefix $vmname

Add-AzVmssNetworkInterfaceConfiguration `
-VirtualMachineScaleSet $vmssConfig `
-Name 'test' `
-Primary $true `
-IPConfiguration $ipConfig `
-networkApiVersion "2020-11-01"

$VmssFlex = New-AzVmss `
-ResourceGroupName $rgname `
-Name $vmssName `
-VirtualMachineScaleSet $vmssConfig

$vm = new-azvm -resourcegroupname $rgname -location $loc -name $vmname -credential $cred -domainnamelabel $domainName -vmssid $VmssFlex.id

Assert-AreEqual $VmssFlex.id $vm.virtualmachinescaleset.id
Assert-AreEqual $VmssFlex.orchestrationMode "Flexible"

# Test PlatformFaultDomainCount parameter
$vmssNameSimple = $vmssname + "Simple";
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
-->
## Upcoming Release
* Added optional parameter `-OrchestrationMode` to `New-AzVmss` and `New-AzVmssConfig`
* Updated the following cmdlets to work when the resource uses a remote image source using AKS or Shared Image Gallery.
- `Update-AzVm`
- `Update-AzVmss`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public string ResourceGroupName
public PSExtendedLocation ExtendedLocation { get; set; }
public IDictionary<string, string> Tags { get; set; }
public PSVirtualMachineScaleSetVMProfile VirtualMachineProfile { get; set; }

public string OrchestrationMode { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,14 @@ public partial class NewAzureRmVmssConfigCommand : Microsoft.Azure.Commands.Reso
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
public SwitchParameter EncryptionAtHost { get; set; }
public SwitchParameter EncryptionAtHost { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the orchestration mode for the virtual machine scale set.")]
[PSArgumentCompleter("Uniform", "Flexible")]
public string OrchestrationMode { get; set; }

protected override void ProcessRecord()
{
Expand Down Expand Up @@ -652,7 +659,8 @@ private void Run()
ProximityPlacementGroup = vProximityPlacementGroup,
AdditionalCapabilities = vAdditionalCapabilities,
ScaleInPolicy = vScaleInPolicy,
Identity = vIdentity
Identity = vIdentity,
OrchestrationMode = this.IsParameterBound(c => c.OrchestrationMode) ? this.OrchestrationMode : null
};

WriteObject(vVirtualMachineScaleSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void ExecuteCmdlet()
"Consider using \"latest\" as the image version. This allows VMSS to auto upgrade when a newer version is available.");
}

if (parameters?.OrchestrationMode == OrchestrationMode.Flexible)
if (parameters?.OrchestrationMode == "Flexible")
{
if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkInterfaceConfigurations != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ public partial class NewAzureRmVmss : ComputeAutomationBaseCmdlet
HelpMessage = "Fault Domain count for each placement group.")]
public int PlatformFaultDomainCount { get; set; }

[Parameter(
Mandatory = false,
ParameterSetName = SimpleParameterSet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the orchestration mode for the virtual machine scale set.")]
[PSArgumentCompleter("Uniform", "Flexible")]
public string OrchestrationMode { get; set; }

const int FirstPortRangeStart = 50000;

sealed class Parameters : IParameters<VirtualMachineScaleSet>
Expand Down Expand Up @@ -334,7 +342,8 @@ public async Task<ResourceConfig<VirtualMachineScaleSet>> CreateConfigAsync()
doNotRunExtensionsOnOverprovisionedVMs: _cmdlet.SkipExtensionsOnOverprovisionedVMs.IsPresent,
encryptionAtHost : _cmdlet.EncryptionAtHost.IsPresent,
platformFaultDomainCount: _cmdlet.IsParameterBound(c => c.PlatformFaultDomainCount) ? _cmdlet.PlatformFaultDomainCount : (int?)null,
edgeZone: _cmdlet.EdgeZone
edgeZone: _cmdlet.EdgeZone,
orchestrationMode: _cmdlet.IsParameterBound(c => c.OrchestrationMode) ? _cmdlet.OrchestrationMode : null
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
bool doNotRunExtensionsOnOverprovisionedVMs,
bool encryptionAtHost,
int? platformFaultDomainCount,
string edgeZone
string edgeZone,
string orchestrationMode
)
=> Strategy.CreateResourceConfig(
resourceGroup: resourceGroup,
Expand Down Expand Up @@ -139,7 +140,8 @@ string edgeZone
{
Rules = scaleInPolicy
},
DoNotRunExtensionsOnOverprovisionedVMs = doNotRunExtensionsOnOverprovisionedVMs ? true : (bool?)null
DoNotRunExtensionsOnOverprovisionedVMs = doNotRunExtensionsOnOverprovisionedVMs ? true : (bool?)null,
OrchestrationMode = orchestrationMode
});
}
}
20 changes: 17 additions & 3 deletions src/Compute/Compute/help/New-AzVmss.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ New-AzVmss [[-ResourceGroupName] <String>] [-VMScaleSetName] <String> [-AsJob] [
[-DataDiskSizeInGb <Int32[]>] [-ProximityPlacementGroupId <String>] [-HostGroupId <String>]
[-Priority <String>] [-EvictionPolicy <String>] [-MaxPrice <Double>] [-ScaleInPolicy <String[]>]
[-SkipExtensionsOnOverprovisionedVMs] [-EncryptionAtHost] [-PlatformFaultDomainCount <Int32>]
[-DefaultProfile <IAzureContextContainer>] [-SinglePlacementGroup] [-WhatIf] [-Confirm] [<CommonParameters>]
[-OrchestrationMode <String>] [-DefaultProfile <IAzureContextContainer>] [-SinglePlacementGroup] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -470,6 +471,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -OrchestrationMode
Specifies the orchestration mode for the virtual machine scale set. Possible values: Uniform, Flexible
```yaml
Type: System.String
Parameter Sets: SimpleParameterSet
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -PlatformFaultDomainCount
Fault Domain count for each placement group.
Expand Down Expand Up @@ -861,5 +877,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
[Stop-AzVmss](./Stop-AzVmss.md)

[Update-AzVmss](./Update-AzVmss.md)


24 changes: 20 additions & 4 deletions src/Compute/Compute/help/New-AzVmssConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ New-AzVmssConfig [[-Overprovision] <Boolean>] [[-Location] <String>] [-EdgeZone
[-BootDiagnostic <BootDiagnostics>] [-LicenseType <String>] [-Priority <String>] [-EvictionPolicy <String>]
[-MaxPrice <Double>] [-TerminateScheduledEvents] [-TerminateScheduledEventNotBeforeTimeoutInMinutes <Int32>]
[-ProximityPlacementGroupId <String>] [-ScaleInPolicy <String[]>] [-EncryptionAtHost]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-OrchestrationMode <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### ExplicitIdentityParameterSet
Expand All @@ -44,8 +45,8 @@ New-AzVmssConfig [[-Overprovision] <Boolean>] [[-Location] <String>] [-EdgeZone
[-BootDiagnostic <BootDiagnostics>] [-LicenseType <String>] [-Priority <String>] [-EvictionPolicy <String>]
[-MaxPrice <Double>] [-TerminateScheduledEvents] [-TerminateScheduledEventNotBeforeTimeoutInMinutes <Int32>]
[-ProximityPlacementGroupId <String>] [-ScaleInPolicy <String[]>] -IdentityType <ResourceIdentityType>
[-IdentityId <String[]>] [-EncryptionAtHost] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-IdentityId <String[]>] [-EncryptionAtHost] [-OrchestrationMode <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -371,6 +372,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -OrchestrationMode
Specifies the orchestration mode for the virtual machine scale set. Possible values: Uniform, Flexible
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -OsProfile
Specifies the operating system profile object that contains the operating system properties for the VMSS configuration.
You can use the **Set-AzVmssOsProfile** cmdlet to set this object.
Expand Down Expand Up @@ -807,4 +823,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

[Add-AzVmssExtension](./Add-AzVmssExtension.md)

[New-AzVmss](./New-AzVmss.md)
[New-AzVmss](./New-AzVmss.md)

0 comments on commit 31d712f

Please sign in to comment.