1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 06:46:36 +01:00

Added vSphere multi disk support

This commit is contained in:
vr4manta
2025-01-21 07:11:49 -05:00
parent 11f83d61d9
commit 84d548c626
7 changed files with 7477 additions and 7592 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1149,6 +1149,38 @@ spec:
cores to assign a vm.
format: int32
type: integer
dataDisks:
description: DataDisks are additional disks to add to the
VM that are not part of the VM's OVA template.
items:
description: DataDisk defines a data disk to add to the
VM that is not part of the VM OVA template.
properties:
name:
description: |-
name is used to identify the disk definition. name is required needs to be unique so that it can be used to
clearly identify purpose of the disk.
example: images_1
maxLength: 80
pattern: ^[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
sizeGiB:
description: |-
sizeGiB is the size of the disk in GiB.
The maximum supported size is 16384 GiB.
format: int32
maximum: 16384
minimum: 1
type: integer
required:
- name
- sizeGiB
type: object
maxItems: 29
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
memoryMB:
description: Memory is the size of a VM's memory in MB.
format: int64
@@ -2215,6 +2247,38 @@ spec:
cores to assign a vm.
format: int32
type: integer
dataDisks:
description: DataDisks are additional disks to add to the
VM that are not part of the VM's OVA template.
items:
description: DataDisk defines a data disk to add to the
VM that is not part of the VM OVA template.
properties:
name:
description: |-
name is used to identify the disk definition. name is required needs to be unique so that it can be used to
clearly identify purpose of the disk.
example: images_1
maxLength: 80
pattern: ^[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
sizeGiB:
description: |-
sizeGiB is the size of the disk in GiB.
The maximum supported size is 16384 GiB.
format: int32
maximum: 16384
minimum: 1
type: integer
required:
- name
- sizeGiB
type: object
maxItems: 29
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
memoryMB:
description: Memory is the size of a VM's memory in MB.
format: int64
@@ -5009,6 +5073,38 @@ spec:
cores to assign a vm.
format: int32
type: integer
dataDisks:
description: DataDisks are additional disks to add to the
VM that are not part of the VM's OVA template.
items:
description: DataDisk defines a data disk to add to the
VM that is not part of the VM OVA template.
properties:
name:
description: |-
name is used to identify the disk definition. name is required needs to be unique so that it can be used to
clearly identify purpose of the disk.
example: images_1
maxLength: 80
pattern: ^[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
sizeGiB:
description: |-
sizeGiB is the size of the disk in GiB.
The maximum supported size is 16384 GiB.
format: int32
maximum: 16384
minimum: 1
type: integer
required:
- name
- sizeGiB
type: object
maxItems: 29
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
memoryMB:
description: Memory is the size of a VM's memory in MB.
format: int64

View File

@@ -156,6 +156,19 @@ func GenerateMachines(ctx context.Context, clusterID string, config *types.Insta
return nil, fmt.Errorf("unable to find failure domain for machine %s", machine.Name)
}
// If we have additional disks to add to VM, lets iterate through them and add to CAPV machine
if len(providerSpec.DataDisks) > 0 {
dataDisks := []capv.VSphereDisk{}
for _, disk := range providerSpec.DataDisks {
newDisk := capv.VSphereDisk{
Name: disk.Name,
SizeGiB: disk.SizeGiB,
}
dataDisks = append(dataDisks, newDisk)
}
vsphereMachine.Spec.DataDisks = dataDisks
}
vsphereMachine.SetGroupVersionKind(capv.GroupVersion.WithKind("VSphereMachine"))
capvMachines = append(capvMachines, vsphereMachine)

View File

@@ -342,6 +342,15 @@ func provider(clusterID string, vcenter *vsphere.VCenter, failureDomain vsphere.
networkDeviceSpec[i] = machineapi.NetworkDeviceSpec{NetworkName: network}
}
dataDisks := []machineapi.VSphereDisk{}
for _, curDisk := range mpool.DataDisks {
newDisk := machineapi.VSphereDisk{
Name: curDisk.Name,
SizeGiB: curDisk.SizeGiB,
}
dataDisks = append(dataDisks, newDisk)
}
vSphereMachineProviderSpec := &machineapi.VSphereMachineProviderSpec{
TypeMeta: metav1.TypeMeta{
APIVersion: machineapi.SchemeGroupVersion.String(),
@@ -365,6 +374,7 @@ func provider(clusterID string, vcenter *vsphere.VCenter, failureDomain vsphere.
NumCoresPerSocket: mpool.NumCoresPerSocket,
MemoryMiB: mpool.MemoryMiB,
DiskGiB: mpool.OSDisk.DiskSizeGB,
DataDisks: dataDisks,
}
if failureDomain.ZoneType == vsphere.HostGroupFailureDomain {

View File

@@ -629,7 +629,8 @@ func checkMachineReady(machine *clusterv1.Machine, requirePublicIP bool) (bool,
logrus.Debugf("Machine %s has not yet provisioned: %s", machine.Name, machine.Status.Phase)
return false, nil
} else if machine.Status.Phase == string(clusterv1.MachinePhaseFailed) {
msg := ptr.Deref(machine.Status.FailureMessage, "machine.Status.FailureMessage was not set")
//TODO: We need to update this to use non deprecated field
msg := ptr.Deref(machine.Status.FailureMessage, "machine.Status.FailureMessage was not set") //nolint:staticcheck
return false, fmt.Errorf("machine %s failed to provision: %s", machine.Name, msg)
}
logrus.Debugf("Machine %s has status: %s", machine.Name, machine.Status.Phase)

View File

@@ -24,6 +24,14 @@ type MachinePool struct {
// +optional
OSDisk `json:"osDisk"`
// DataDisks are additional disks to add to the VM that are not part of the VM's OVA template.
//
// +optional
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=29
DataDisks []DataDisk `json:"dataDisks"`
// Zones defines available zones
// Zones is available in TechPreview.
//
@@ -39,6 +47,23 @@ type OSDisk struct {
DiskSizeGB int32 `json:"diskSizeGB"`
}
// DataDisk defines a data disk to add to the VM that is not part of the VM OVA template.
type DataDisk struct {
// name is used to identify the disk definition. name is required needs to be unique so that it can be used to
// clearly identify purpose of the disk.
// +kubebuilder:example=images_1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9]([-_a-zA-Z0-9]*[a-zA-Z0-9])?$"
// +required
Name string `json:"name"`
// sizeGiB is the size of the disk in GiB.
// The maximum supported size is 16384 GiB.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=16384
// +required
SizeGiB int32 `json:"sizeGiB"`
}
// Set sets the values from `required` to `p`.
func (p *MachinePool) Set(required *MachinePool) {
if required == nil || p == nil {
@@ -64,4 +89,8 @@ func (p *MachinePool) Set(required *MachinePool) {
if len(required.Zones) > 0 {
p.Zones = required.Zones
}
if len(required.DataDisks) > 0 {
p.DataDisks = required.DataDisks
}
}

View File

@@ -23,6 +23,9 @@ func GatedFeatures(c *types.InstallConfig) []featuregates.GatedInstallConfigFeat
}
}
cpDef := c.ControlPlane.Platform.VSphere
computeDefs := c.Compute
return []featuregates.GatedInstallConfigFeature{
{
FeatureGateName: features.FeatureGateVSphereStaticIPs,
@@ -55,5 +58,26 @@ func GatedFeatures(c *types.InstallConfig) []featuregates.GatedInstallConfigFeat
return false
}(v),
},
{
FeatureGateName: features.FeatureGateVSphereMultiDisk,
Condition: cpDef != nil && len(cpDef.DataDisks) > 0, // Here we need to check disk count
Field: field.NewPath("controlPlane", "platform", "vsphere", "dataDisks"),
},
{
FeatureGateName: features.FeatureGateVSphereMultiDisk,
Condition: hasDataDisks(computeDefs), // Here we need to check disk count
Field: field.NewPath("compute", "platform", "vsphere", "dataDisks"),
},
}
}
func hasDataDisks(pool []types.MachinePool) bool {
foundDataDisks := false
for _, machine := range pool {
if machine.Platform.VSphere != nil && len(machine.Platform.VSphere.DataDisks) > 0 {
foundDataDisks = true
break
}
}
return foundDataDisks
}