Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] support HostGroupID #20796

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,12 @@ public void TestAadProfile()
{
TestRunner.RunTestScript("Test-AadProfile");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestHostGroupID()
{
TestRunner.RunTestScript("Test-HostGroupID");
}
}
}
47 changes: 47 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1037,3 +1037,50 @@ function Test-AadProfile {
#Remove-AzADGroup -DisplayName $AdGroupName
}
}

function Test-HostGroupID {
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = 'eastus'

try {
New-AzResourceGroup -Name $resourceGroupName -Location $location

#prepare a Dedicated Host and a user-assigned Identity
#$hostGroup = New-AzHostGroup -ResourceGroupName $resourceGroupName -Name $hostGroupName -Location $location -PlatformFaultDomain 1 -SupportAutomaticPlacement $true
#$hostSku = (Get-AzComputeResourceSku -Location $location | where ResourceType -eq "hostGroups/hosts")[0].Name
#New-AzHost -ResourceGroupName $resourceGroupName -HostGroupName $hostGroupName -Name $hostName -Location $location -Sku DSv3-Type1
#$azHost = Get-AzHost -ResourceGroupName $resourceGroupName -HostGroupName $hostGroupName -Name $hostName -InstanceView
#$nodeVmSize = ($azHost.InstanceView.AvailableCapacity.AllocatableVMs | Sort-Object -Property Count -Descending)[0].VmSize

#$identity = New-AzUserAssignedIdentity -ResourceGroupName $resourceGroupName -Name $identityName -Location $location
#$roleAssignment = New-AzRoleAssignment -ObjectId $identity.PrincipalId -RoleDefinitionName Contributor -Scope $hostGroup.Id

#$hostGroupId = $hostGroup.Id
#$identityId = identity.Id

$hostGroupId = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/AKS_TEST_RG/providers/Microsoft.Compute/hostGroups/aks_test_hostgroup"
$identityId = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/aks_test_rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aks_test_mi"
$nodeVmSize = "Standard_D2s_v3"

# create aks cluster with default nodepool
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -NodeHostGroupID $hostGroupId -EnableManagedIdentity -AssignIdentity $identityId
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual $hostGroupId $cluster.AgentPoolProfiles[0].hostGroupID
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual $hostGroupId $pools[0].hostGroupID

# create the 2nd nodepool
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name pool2 -VmSize $nodeVmSize -Count 1 -HostGroupID $hostGroupId
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual $hostGroupId $cluster.AgentPoolProfiles[0].hostGroupID
Assert-AreEqual $hostGroupId $cluster.AgentPoolProfiles[1].hostGroupID
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual $hostGroupId $pools[0].hostGroupID
Assert-AreEqual $hostGroupId $pools[1].hostGroupID
}
finally {
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Aks/Aks/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->
## Upcoming Release
* Added parameter `-AadProfile` for `New-AzAksCluster` and `Set-AzAksCluster`
* Added parameter `-NodeHostGroupID` for `New-AzAksCluster` and parameter `-HostGroupID` for `New-AzAksNodePool`

## Version 5.2.0
* Added parameter `-EnableEncryptionAtHost` for `New-AzAksCluster` and `New-AzAksNodePool`
Expand Down
6 changes: 6 additions & 0 deletions src/Aks/Aks/Commands/NewAzureRmAks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
[Parameter(Mandatory = false, HelpMessage = "The name of the Edge Zone.")]
public string EdgeZone { get; set; }

[Parameter(Mandatory = false, HelpMessage = "The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.")]
public string NodeHostGroupID { get; set; }

private AcsServicePrincipal acsServicePrincipal;

public override void ExecuteCmdlet()
Expand Down Expand Up @@ -569,6 +572,9 @@ private ManagedClusterAgentPoolProfile GetAgentPoolProfile()
{
defaultAgentPoolProfile.GpuInstanceProfile = GpuInstanceProfile;
}
if (this.IsParameterBound(c => c.NodeHostGroupID)) {
defaultAgentPoolProfile.HostGroupID = NodeHostGroupID;
}

defaultAgentPoolProfile.Mode = NodePoolMode;

Expand Down
7 changes: 7 additions & 0 deletions src/Aks/Aks/Commands/NewAzureRmAksNodePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public class NewAzureRmAksNodePool : NewOrUpdateAgentPoolBase
[PSArgumentCompleter("MIG1g", "MIG2g", "MIG3g", "MIG4g", "MIG7g")]
public string GpuInstanceProfile { get; set; }

[Parameter(Mandatory = false, HelpMessage = "The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.")]
public string HostGroupID { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down Expand Up @@ -281,6 +284,10 @@ private AgentPool GetAgentPool()
{
agentPool.GpuInstanceProfile = GpuInstanceProfile;
}
if (this.IsParameterBound(c => c.HostGroupID))
{
agentPool.HostGroupID = HostGroupID;
}

return agentPool;
}
Expand Down
41 changes: 28 additions & 13 deletions src/Aks/Aks/help/New-AzAksCluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-EnableEncryptionAtHost] [-EnableUltraSSD]
[-NodeLinuxOSConfig <LinuxOSConfig>] [-NodeKubeletConfig <KubeletConfig>] [-NodeMaxSurge <String>]
[-PPG <String>] [-EnableFIPS] [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>]
[-GpuInstanceProfile <String>] [-EnableUptimeSLA] [-EdgeZone <String>] [-ResourceGroupName] <String>
[-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>] [-Location <String>]
[-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>] [-KubernetesVersion <String>]
[-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>] [-EnableNodeAutoScaling]
[-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>] [-NodePoolLabel <Hashtable>]
[-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>] [-AsJob] [-Tag <Hashtable>]
[-LoadBalancerAllocatedOutboundPort <Int32>] [-LoadBalancerManagedOutboundIpCount <Int32>]
[-LoadBalancerOutboundIp <String[]>] [-LoadBalancerOutboundIpPrefix <String[]>]
[-LoadBalancerIdleTimeoutInMinute <Int32>] [-ApiServerAccessAuthorizedIpRange <String[]>]
[-EnableApiServerAccessPrivateCluster] [-ApiServerAccessPrivateDnsZone <String>]
[-EnableApiServerAccessPrivateClusterPublicFQDN] [-FqdnSubdomain <String>] [-EnableManagedIdentity]
[-AssignIdentity <String>] [-AutoUpgradeChannel <String>] [-DiskEncryptionSetID <String>]
[-DisableLocalAccount] [-HttpProxy <String>] [-HttpsProxy <String>]
[-GpuInstanceProfile <String>] [-EnableUptimeSLA] [-EdgeZone <String>] [-NodeHostGroupID <String>]
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
[-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
[-LoadBalancerManagedOutboundIpCount <Int32>] [-LoadBalancerOutboundIp <String[]>]
[-LoadBalancerOutboundIpPrefix <String[]>] [-LoadBalancerIdleTimeoutInMinute <Int32>]
[-ApiServerAccessAuthorizedIpRange <String[]>] [-EnableApiServerAccessPrivateCluster]
[-ApiServerAccessPrivateDnsZone <String>] [-EnableApiServerAccessPrivateClusterPublicFQDN]
[-FqdnSubdomain <String>] [-EnableManagedIdentity] [-AssignIdentity <String>] [-AutoUpgradeChannel <String>]
[-DiskEncryptionSetID <String>] [-DisableLocalAccount] [-HttpProxy <String>] [-HttpsProxy <String>]
[-HttpProxyConfigNoProxyEndpoint <String[]>] [-HttpProxyConfigTrustedCa <String>]
[-AksCustomHeader <Hashtable>] [-AadProfile <ManagedClusterAADProfile>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
Expand Down Expand Up @@ -862,6 +862,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -NodeHostGroupID
The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -NodeKubeletConfig
The Kubelet configuration on the agent pool nodes.

Expand Down
31 changes: 23 additions & 8 deletions src/Aks/Aks/help/New-AzAksNodePool.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ New-AzAksNodePool -ResourceGroupName <String> -ClusterName <String> -Name <Strin
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-LinuxOSConfig <LinuxOSConfig>] [-KubeletConfig <KubeletConfig>]
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-GpuInstanceProfile <String>]
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
[-HostGroupID <String>] [-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>]
[-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>]
[-AksCustomHeader <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[-SubscriptionId <String>] [<CommonParameters>]
```

### ParentObjectParameterSet
Expand All @@ -34,10 +34,10 @@ New-AzAksNodePool -Name <String> -ClusterObject <PSKubernetesCluster> [-Count <I
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-LinuxOSConfig <LinuxOSConfig>] [-KubeletConfig <KubeletConfig>]
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-GpuInstanceProfile <String>]
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
[-HostGroupID <String>] [-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>]
[-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>]
[-AksCustomHeader <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -282,6 +282,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -HostGroupID
The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -KubeletConfig
The Kubelet configuration on the agent pool nodes.

Expand Down