VMware Cloud on AWS has the ability to add new clusters to an existing SDDC. This is most useful for workload separation. A cluster could be specified as the failover resource, a development environment, and so forth. However, as of Version 1.6, there’s a new reason to add new clusters to an SDDC: custom core counts! The ability to control the CPU count for hosts in a cluster is extremely important when it comes to running mission-critical applications that happen to be licensed per-core. Even better, it is extremely easy to automate the lifecycle of a cluster with PowerCLI.
Let’s check out some examples of how we can manage clusters within the VMware Cloud on AWS service.
Environment Setup
As part of this blog, I will be using a previously deployed SDDC and will begin by working with the low-level VMC module to perform these tasks. We will start by opening a PowerShell session and authenticating to the VMware Cloud on AWS service with our API Token. Then, we need to identify a couple services to use. These services will be the following:
- com.vmware.vmc.orgs
- com.vmware.vmc.orgs.sddcs
- com.vmware.vmc.orgs.sddcs.clusters
- com.vmware.vmc.orgs.tasks
One last setup requirement, we will need to grab IDs for the Organization and SDDC which we’ll be working with.
We can summarize the above criteria with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 |
# Connect to the VMware Cloud on AWS Service Connect-VMC -RefreshToken "xxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxx" # Reference Orgs service and populate a variable with the desired Org $orgSvc = Get-VmcService -Name com.vmware.vmc.orgs $org = $orgSvc.List() | select -first 1 # Reference Sddcs service and populate a variable with the desired SDDC $sddcSvc = Get-VmcService -Name com.vmware.vmc.orgs.sddcs $sddc = $sddcSvc.List($org.Id) | select -first 1 # Reference Clusters service $sddcClusterSvc = Get-VmcService -Name com.vmware.vmc.orgs.sddcs.clusters # Reference Tasks service $taskSvc = Get-VmcService -Name com.vmware.vmc.orgs.tasks |
If any of these commands seem foreign, please check out the following blog post for more information: Getting Started with the VMware Cloud on AWS Module
SDDC Cluster Service Overview
We will be using the SDDC Clusters service, and therefore the sddcClusterSvc variable. In order to discover the actions we can perform with the Clusters service, we will take the output from the sddcClusterSvc variable and pipeline that into the Get-Member cmdlet:
1 |
$sddcClusterSvc | Get-Member |
Here we can see that there are two methods available, create and delete. As part of this blog post, we will walk through the usage of these two methods in the following sections. However, there’s a method or two that are missing, get and list. We can pull that information directly from the get method on the SDDC itself. The cluster information is available by referencing the resource_config property, then the clusters property.
To pull out some basic cluster information, we can use the following command:
1 |
$sddc.resource_config.clusters | select cluster_id, cluster_name, cluster_state |
Cluster Creation
For the first example, we have been tasked with creating a new cluster within our SDDC.
In order to populate the parameters for the create method, we will make use of the Help property for the SDDC Cluster service stored in the sddcClusterSvc variable. We can identify all of the parameters required for the create method, including an Org ID, SDDC ID, and the cluster configuration specification, with the following command:
1 |
$sddcClusterSvc.Help.create |
We already have our Org ID and SDDC ID stored in a variable. Next, we need to create a cluster config spec for the new cluster. If we take the prior command and append the ‘cluster_config’ property, we can view all of the properties available to populate the spec. Then, by again using ‘Get-Member’, we can see that the cluster_config has a method of create which we can use to create the object for that particular specification.
We’ll then store the spec in a variable named sddcClusterCreateSpec. Based on the prior screenshot, there’s only one required property. This property is for the desired number of hosts for the new cluster. We’ll populate that property with a value of ‘1’, then run our create method to start the creation of the new cluster.
Putting the above together, we can create a new cluster with a single host using the following code:
1 2 3 4 5 6 |
# Create Cluster Config spec and populating the required properties $sddcClusterCreateSpec = $sddcClusterSvc.Help.create.cluster_config.Create() $sddcClusterCreateSpec.num_hosts = 1 # Perform the Create action and output some basic information from the returned task $sddcClusterTask = $sddcClusterSvc.Create($org.Id, $sddc.Id, $sddcClusterCreateSpec) $sddcClusterTask | Select-Object Id,Task_Type,Status,Created |
If we login to the VMware Cloud on AWS Cloud Console, we should see the following in our SDDC’s Summary tab:
Cluster Creation – Custom Core Count
For the second example, we have been tasked with creating another new cluster within our SDDC. However, this time, we only want a specific core count to be available. We will use our prior example and add-on to the specification by setting the host_cpu_cores_count to be a value of 8, 16, 36, or 48, depending on the host type. We can do this by adding the following command to the existing workflow:
1 |
$sddcClusterCreateSpec.host_cpu_cores_count = 8 |
Putting the prior example together with the above command, we can create a new cluster with a single host that’s been configured with a CPU core count of 8 using the following code:
1 2 3 4 5 6 7 |
# Create Cluster Config spec and populating the required properties $sddcClusterCreateSpec = $sddcClusterSvc.Help.create.cluster_config.Create() $sddcClusterCreateSpec.host_cpu_cores_count = 8 $sddcClusterCreateSpec.num_hosts = 1 # Perform the Create action and output some basic information from the returned task $sddcClusterTask = $sddcClusterSvc.Create($org.Id, $sddc.Id, $sddcClusterCreateSpec) $sddcClusterTask | Select-Object Id,Task_Type,Status,Created |
Cluster Removal
For the third example, we have been tasked with deleting the first cluster we created, Cluster-2. Making use of the Help property from the SDDC Cluster service, we can run the following command to find out what parameters the delete method requires:
1 |
$sddcClusterSvc.Help.delete |
We can see that we have three parameters to enter: Org ID, SDDC ID, and Cluster ID. We still have the first two stored in variables, so we need to obtain the Cluster ID. If we remember back to the SDDC Cluster Service Overview section, there’s no list or get methods for the SDDC Cluster service. Therefore, we need to refresh our sddc variable and return back the updated list of clusters to obtain the ID. We can do that with the following commands:
1 2 |
$sddc = $sddcSvc.List($org.Id) $sddc.resource_config.clusters | select cluster_id, cluster_name, cluster_state |
We will then store the cluster information for only Cluster-2, by filtering the cluster_name property with a where statement and storing it in a variable by the name of cluster. Then, we’re ready to run the delete method. We can do that with the following commands:
1 2 |
$cluster = $sddc.resource_config.clusters | where {$_.cluster_name -eq 'Cluster-2'} $sddcClusterTask = $sddcClusterSvc.delete($org.id, $sddc.id, $cluster.cluster_id) |
Putting the above together, we can delete the newly created Cluster-2 with the following code:
1 2 3 4 5 6 |
# Update SDDC variable and filter the clusters for only Cluster-2 $sddc = $sddcSvc.List($org.Id) $cluster = $sddc.resource_config.clusters | where {$_.cluster_name -eq 'Cluster-2'} # Perform the Delete action and output some basic information from the returned task $sddcClusterTask = $sddcClusterSvc.delete($org.id, $sddc.id, $cluster.cluster_id) $sddcClusterTask | Select-Object Id,Task_Type,Status,Created |
VMC Community Module Update
Another option to perform the above tasks is with the VMware.VMC community module, which is available on the PowerCLI Community Repository as well as the PowerShell Gallery. I have updated the module to include the following advanced functions:
- Get-VMCSDDCCluster
- New-VMCSDDCCluster
- Remove-VMCSDDCCluster
The only difference between the above sections and these functions, these functions expect names instead of IDs as input. Otherwise, they work exactly as you would expect. An example of them in use:
Summary
VMware Cloud on AWS based SDDCs can contain multiple clusters, which is beneficial for a couple reasons. First, workload separation. A cluster could be specified as the failover resource, a development environment, and more. Second, and new as of Version 1.6, these clusters can be deployed with a specific amount of CPU cores. This control is certainly important when it comes to running mission-critical applications that happen to be licensed per-core. All of the cluster actions are available via the VMware Cloud on AWS APIs, and therefore PowerCLI as well! This blog post walked us through how to identify the deployed clusters, deploy new clusters, and remove clusters which are no longer needed.
Let us know in the comments how you’re making use of additional clusters in your automation workflows!