New-AzAksCluster

Create a new managed Kubernetes cluster.

The cmdlet may call below Microsoft Graph API according to input parameters:

  • POST /servicePrincipals

Syntax

New-AzAksCluster
   [-NodeVmSetType <String>]
   [-NodeVnetSubnetID <String>]
   [-NodeMaxPodCount <Int32>]
   [-NodeSetPriority <String>]
   [-NodePoolMode <String>]
   [-NodeScaleSetEvictionPolicy <String>]
   [-AddOnNameToBeEnabled <String[]>]
   [-WorkspaceResourceId <String>]
   [-SubnetName <String>]
   [-EnableRbac]
   [-WindowsProfileAdminUserName <String>]
   [-WindowsProfileAdminUserPassword <SecureString>]
   [-NetworkPlugin <String>]
   [-NetworkPolicy <String>]
   [-PodCidr <String>]
   [-ServiceCidr <String>]
   [-DnsServiceIP <String>]
   [-DockerBridgeCidr <String>]
   [-NodePoolLabel <Hashtable>]
   [-AksCustomHeader <Hashtable>]
   [-LoadBalancerSku <String>]
   [-Force]
   [-GenerateSshKey]
   [-EnableNodePublicIp]
   [-NodePublicIPPrefixID <String>]
   [-AvailabilityZone <String[]>]
   [-NodeResourceGroup <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>]
   [-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>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [-SubscriptionId <String>]
   [<CommonParameters>]

Description

Create a new Azure Kubernetes Service(AKS) cluster.

Examples

New an AKS with default params.

New-AzAksCluster -ResourceGroupName myResourceGroup -Name myCluster

Create Windows Server container on an AKS.

To create Windows Server container on an AKS, you must specify at least four following parameters when creating the AKS, and the value for NetworkPlugin and NodeVmSetType must be azure and VirtualMachineScaleSets respectively. -WindowsProfileAdminUserName *** -WindowsProfileAdminUserPassword *** -NetworkPlugin azure -NodeVmSetType VirtualMachineScaleSets

$cred = ConvertTo-SecureString -AsPlainText "Password!!123" -Force
New-AzAksCluster -ResourceGroupName myResourceGroup -Name myCluster -WindowsProfileAdminUserName azureuser -WindowsProfileAdminUserPassword $cred -NetworkPlugin azure -NodeVmSetType VirtualMachineScaleSets
New-AzAksNodePool -ResourceGroupName myResourceGroup -ClusterName myCluster -Name win1 -OsType Windows -VmSetType VirtualMachineScaleSets

Parameters

-AcrNameToAttach

Grant the 'acrpull' role of the specified ACR to AKS Service Principal, e.g. myacr

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AddOnNameToBeEnabled

Add-on names to be enabled when cluster is created.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AksCustomHeader

Aks custom headers used for building Kubernetes network.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ApiServerAccessAuthorizedIpRange

The IP ranges authorized to access the Kubernetes API server.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ApiServerAccessPrivateDnsZone

The private DNS zone mode for the cluster.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AssignIdentity

ResourceId of user assign managed identity for cluster.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AutoUpgradeChannel

The upgrade channel for auto upgrade. For more information see https://docs.microsoft.com/azure/aks/upgrade-cluster#set-auto-upgrade-channel.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-AvailabilityZone

Availability zones for cluster. Must use VirtualMachineScaleSets AgentPoolType.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DisableLocalAccount

Local accounts should be disabled on the Managed Cluster.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DiskEncryptionSetID

The resource ID of the disk encryption set to use for enabling encryption.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DnsNamePrefix

The DNS name prefix for the cluster. The length must be <= 9 if users plan to add windows container.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DnsServiceIP

DNS service IP used for building Kubernetes network.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DockerBridgeCidr

Docker bridge cidr used for building Kubernetes network.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableApiServerAccessPrivateCluster

Whether to create the cluster as a private cluster or not.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableApiServerAccessPrivateClusterPublicFQDN

Whether to create additional public FQDN for private cluster or not.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableManagedIdentity

Using a managed identity to manage cluster resource group.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableNodeAutoScaling

Whether to enable auto-scaler

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableNodePublicIp

Whether to enable public IP for nodes.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-EnableRbac

Whether to enable Kubernetes Role-Based Access

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Force

Create cluster even if it already exists

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-FqdnSubdomain

The FQDN subdomain of the private cluster with custom private dns zone.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-GenerateSshKey

Generate ssh key file to {HOME}/.ssh/id_rsa.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-HttpProxy

The HTTP proxy server endpoint to use.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-HttpProxyConfigNoProxyEndpoint

The endpoints that should not go through proxy.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-HttpProxyConfigTrustedCa

Alternative CA cert to use for connecting to proxy servers.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-HttpsProxy

The HTTPS proxy server endpoint to use

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-KubernetesVersion

The version of Kubernetes to use for creating the cluster.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LinuxProfileAdminUserName

User name for the Linux Virtual Machines.

Type:String
Aliases:AdminUserName
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerAllocatedOutboundPort

The desired number of allocated SNAT ports per VM.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerIdleTimeoutInMinute

Desired outbound flow idle timeout in minutes.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerManagedOutboundIpCount

Desired managed outbound IPs count for the cluster load balancer.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerOutboundIp

Desired outbound IP resources for the cluster load balancer.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerOutboundIpPrefix

Desired outbound IP Prefix resources for the cluster load balancer.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-LoadBalancerSku

The load balancer sku for the managed cluster.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Location

Azure location for the cluster. Defaults to the location of the resource group.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Name

Kubernetes managed cluster Name.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NetworkPlugin

Network plugin used for building Kubernetes network.

Type:String
Position:Named
Default value:azure
Accept pipeline input:False
Accept wildcard characters:False

-NetworkPolicy

Network policy used for building Kubernetes network.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeCount

The default number of nodes for the node pools.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeMaxCount

Maximum number of nodes for auto-scaling

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeMaxPodCount

Maximum number of pods that can run on node.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeMinCount

Minimum number of nodes for auto-scaling.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeName

Unique name of the agent pool profile in the context of the subscription and resource group.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeOsDiskSize

Size in GB of the OS disk for each node in the node pool. Minimum 30 GB.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodePoolLabel

Node pool labels used for building Kubernetes network.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodePoolMode

NodePoolMode represents mode of an node pool.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodePublicIPPrefixID

The resource Id of public IP prefix for node pool.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeResourceGroup

The resource group containing agent pool.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeScaleSetEvictionPolicy

ScaleSetEvictionPolicy to be used to specify eviction policy for low priority virtual machine scale set. Default to Delete.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeSetPriority

ScaleSetPriority to be used to specify virtual machine scale set priority. Default to regular.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeVmSetType

AgentPoolType represents types of an agent pool. Possible values include: 'VirtualMachineScaleSets', 'AvailabilitySet'

Type:String
Position:Named
Default value:VirtualMachineScaleSets
Accept pipeline input:False
Accept wildcard characters:False

-NodeVmSize

The size of the Virtual Machine. Default value is Standard_D2_v2.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-NodeVnetSubnetID

VNet SubnetID specifies the VNet's subnet identifier.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-PodCidr

Pod cidr used for building Kubernetes network.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Resource Group Name.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ServiceCidr

Service cidr used for building Kubernetes network.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ServicePrincipalIdAndSecret

The client id and client secret associated with the AAD application / service principal.

Type:PSCredential
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SshKeyValue

SSH key file value or key file path. Defaults to {HOME}/.ssh/id_rsa.pub.

Type:String
Aliases:SshKeyPath
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SubnetName

Subnet name of VirtualNode addon.

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionId

The ID of the subscription. By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user. Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Tag

Tags to be applied to the resource

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WindowsProfileAdminUserName

The administrator username to use for Windows VMs.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WindowsProfileAdminUserPassword

The administrator password to use for Windows VMs, its length must be at least 12, containing at least one lower case character, i.e. [a-z], one [A-Z] and one special character [!@#$%^&*()].

Type:SecureString
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WorkspaceResourceId

Resource Id of the workspace of Monitoring addon.

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

Inputs

None

Outputs

PSKubernetesCluster