VMware NSX Controller Cluster creation with PowerShell

VMware NSX Controller Cluster creation with PowerShell

VMware NSX Controller Cluster creation with PowerShell

VMware NSX Controller Cluster creation with PowerShell – In this blog post we would explore how to create a controller cluster using GUI and also ways to automate it using the Invoke-WebRequest cmdlet.

First and foremost you need to have the NSX appliance registered with your vcenter server, on more details on how to go about this, refer to one of my previous blog post.

Once you have the vcenter server registered, head over to the “Networking and security” plugin, under the installation tab, click on the nsx manager and create IP Pools.

Once you have the IP pools created, click on the “+” sign to add controller nodes and feed in the required parameters

VMware NSX Controller Cluster

Thats it, you have created your first controller node, now as per nsx standards you need to have a 3 node controller node cluster, this also helps ins preventing a split brain scenario, follow the above steps and create the remaining too.

It painful isnt it ?? manually creating the nodes ? here’s where the magic of automation using powershell and nsx apis comes into our help.

As you don’t have any controller nodes in your nsx environment, you would need to query the ippool id, as that is a mandatory property for the API invoke,

If you look closely at the API guide for NSX, you would be able to see the below GET request can be used to get these details

Next lets use the Invoke-WebRequest cmdlet to invoke the API call and extract the IP Pools.

The output of the above script-block would give you the ip pool id’s

Wow, now this is great!, some cool stuff you can achieve if you integrate powershell.

Next lets create the API request for creating a new controller, again if you look into the API guide you would see an example on how to Add a controller.

Ok, so now lets make the body tag similar to the one we have above and use Invoke-WebRequest cmdlet to create the controller.

Another thing to note is that the body part needs the exact id of the object, for example if you put the name of the datastore like ‘IO_Intensive’, the request will fail and you need to key in the related datastore ID.

This can be extracted by looking up the Managed Object Reference (MoRef) for the vcenter server objects, similar to the way we extracted the ip pool id.

As you can see below if you want to use “Storage 1 (3)” as the datastore where the controller node needs to be created, you should use the datastore id of “datastore-3273” in the above script block. you can use the similar technique to extract the moref’s for the other vcenter objects too.

Once you execute the above scriptblock, you would see the NSX controller created in your NSX tab in web client.

VMware NSX Controller Cluster

I hope you enjoyed this blogpost and found the information useful.

Do check out some of my other Posts on NSX

Please follow and like us:

Share this post

4 thoughts on “VMware NSX Controller Cluster creation with PowerShell

Post Comment