Everyone who has deployed NSX for vSphere must have configured the VXLAN Transport Parameters.
Nothing really fancy about this and pretty straight forward. But, what if you want to limit the number of VTEPs for NSX due to a specific requirement of the deployment? The number of VTEPs is not editable in the UI as described in the NSX documentation:
The number of VTEPs is not editable in the UI. The VTEP number is set to match the number of dvUplinks on the vSphere Distributed Switch being prepared.
So when you configure the VXLAN Transport Parameters for a host that is connected to a vSphere Distributed Switch (vDS) with 6 dvUplinks it will automatically create 6 VMkernel interfaces.
But but… (due to questionable requirements) we need it only with 2 VMkernel interfaces on a vDS with 6 dvUplinks, how can we solve this? Well fire up your PowerNSX.
Limit the number of VTEPs for NSX with PowerNSX
Not familiar with PowerNSX? Well you should be, PowerNSX is a PowerShell module that contains PowerShell functions that can call the VMware NSX for vSphere API. It will make you life so much more easier and is almost indispensable when consistency and speed is key. Here you can find how to install PowerNSX and here you can find how to use PowerNSX.
Please alter the script below to match your environment.
$Cluster = "%CLUSTERNAME%"
$vDS = Get-Cluster $Cluster | Get-Host | Get-VDSwitch
$IPPool = Get-NsxIpPool "%IPPool%"
$VLANID = "%VLANID%"
$VTEPcount = "2"
New-NsxVdsContext -VirtualDistributedSwitch $vDS -Teaming "LOADBALANCE_SRCID" -Mtu 9000
New-NsxClusterVxlanConfig -Cluster $Cluster -VirtualDistributedSwitch $vDS -IpPool $IPPool -VlanId $VLANID -VtepCount $VTEPcount
After the script has run successfully, the result will be only 2 VMkernel interfaces instead of the “default” 6 VMkernel interfaces:
Don’t forget to configure the uplink assignment on the VTEP portgroup afterwards and set the uplinks to “Active” where the VTEP VLANs are configured on and the rest to “Unused”.
Thanks to Alexander Ries for helping with the script.