diff --git a/apis/hive/v1/vsphere/machinepools.go b/apis/hive/v1/vsphere/machinepools.go index 71e67294ba8..4afbe4965ce 100644 --- a/apis/hive/v1/vsphere/machinepools.go +++ b/apis/hive/v1/vsphere/machinepools.go @@ -8,6 +8,11 @@ type MachinePool struct { // +optional ResourcePool string `json:"resourcePool,omitempty"` + // Cluster is the name of the cluster virtual machines will be cloned into. + // If it is not present, the value in the ClusterDeployment will be used. + // +optional + Cluster string `json:"cluster,omitempty"` + // NumCPUs is the total number of virtual processor cores to assign a vm. NumCPUs int32 `json:"cpus"` diff --git a/pkg/controller/machinepool/vsphereactuator.go b/pkg/controller/machinepool/vsphereactuator.go index 074021145ea..6b2c689e40e 100644 --- a/pkg/controller/machinepool/vsphereactuator.go +++ b/pkg/controller/machinepool/vsphereactuator.go @@ -64,6 +64,11 @@ func (a *VSphereActuator) GenerateMachineSets(cd *hivev1.ClusterDeployment, pool }, } + vCenterCluster := cd.Spec.Platform.VSphere.Cluster + if pool.Spec.Platform.VSphere.Cluster != "" { + vCenterCluster = pool.Spec.Platform.VSphere.Cluster + } + // Fake an install config as we do with other actuators. We only populate what we know is needed today. // WARNING: changes to use more of installconfig in the MachineSets function can break here. Hopefully // will be caught by unit tests. @@ -89,7 +94,7 @@ func (a *VSphereActuator) GenerateMachineSets(cd *hivev1.ClusterDeployment, pool Datacenter: cd.Spec.Platform.VSphere.Datacenter, Datastore: setDatastorePath(cd.Spec.Platform.VSphere.DefaultDatastore, cd.Spec.Platform.VSphere.Datacenter, logger), Folder: setFolderPath(cd.Spec.Platform.VSphere.Folder, cd.Spec.Platform.VSphere.Datacenter, logger), - ComputeCluster: setComputeClusterPath(cd.Spec.Platform.VSphere.Cluster, cd.Spec.Platform.VSphere.Datacenter, logger), + ComputeCluster: setComputeClusterPath(vCenterCluster, cd.Spec.Platform.VSphere.Datacenter, logger), Networks: []string{cd.Spec.Platform.VSphere.Network}, Template: a.osImage, ResourcePool: pool.Spec.Platform.VSphere.ResourcePool,