Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/v1alpha3/vspheremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (src *VSphereMachine) ConvertTo(dstRaw conversion.Hub) error {
return err
}

dst.Spec.Resources = restored.Spec.Resources
dst.Spec.AdditionalDisksGiB = restored.Spec.AdditionalDisksGiB
dst.Spec.TagIDs = restored.Spec.TagIDs
dst.Spec.PowerOffMode = restored.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha3/vspheremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Template.Spec.Resources = restored.Spec.Template.Spec.Resources
dst.Spec.Template.Spec.TagIDs = restored.Spec.Template.Spec.TagIDs
dst.Spec.Template.Spec.AdditionalDisksGiB = restored.Spec.Template.Spec.AdditionalDisksGiB
dst.Spec.Template.Spec.PowerOffMode = restored.Spec.Template.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha3/vspherevm_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (src *VSphereVM) ConvertTo(dstRaw conversion.Hub) error {
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Resources = restored.Spec.Resources
dst.Spec.TagIDs = restored.Spec.TagIDs
dst.Spec.AdditionalDisksGiB = restored.Spec.AdditionalDisksGiB
dst.Spec.PowerOffMode = restored.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/v1alpha4/vspheremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (src *VSphereMachine) ConvertTo(dstRaw conversion.Hub) error {
return err
}

dst.Spec.Resources = restored.Spec.Resources
dst.Spec.AdditionalDisksGiB = restored.Spec.AdditionalDisksGiB
dst.Spec.TagIDs = restored.Spec.TagIDs
dst.Spec.PowerOffMode = restored.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha4/vspheremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Template.Spec.Resources = restored.Spec.Template.Spec.Resources
dst.Spec.Template.Spec.TagIDs = restored.Spec.Template.Spec.TagIDs
dst.Spec.Template.Spec.AdditionalDisksGiB = restored.Spec.Template.Spec.AdditionalDisksGiB
dst.Spec.Template.Spec.PowerOffMode = restored.Spec.Template.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha4/vspherevm_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (src *VSphereVM) ConvertTo(dstRaw conversion.Hub) error {
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Resources = restored.Spec.Resources
dst.Spec.TagIDs = restored.Spec.TagIDs
dst.Spec.AdditionalDisksGiB = restored.Spec.AdditionalDisksGiB
dst.Spec.PowerOffMode = restored.Spec.PowerOffMode
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

Expand Down Expand Up @@ -167,6 +168,12 @@ type VirtualMachineCloneSpec struct {
// virtual machine is cloned.
// +optional
NumCoresPerSocket int32 `json:"numCoresPerSocket,omitempty"`

// resources is the definition of the VM's cpu and memory
// reservations, limits and shares.
// +optional
Resources VirtualMachineResources `json:"resources,omitempty,omitzero"`

// MemoryMiB is the size of a virtual machine's memory, in MiB.
// Defaults to the eponymous property value in the template from which the
// virtual machine is cloned.
Expand Down Expand Up @@ -211,6 +218,51 @@ type VirtualMachineCloneSpec struct {
DataDisks []VSphereDisk `json:"dataDisks,omitempty"`
}

// VirtualMachineResources is the definition of the VM's cpu and memory
// reservations, limits and shares.
// +kubebuilder:validation:MinProperties=1
type VirtualMachineResources struct {
// requests is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
// and memory (in bytes, rounded up to the nearest MiB) reservations
// +optional
Requests VirtualMachineResourceSpec `json:"requests,omitempty,omitzero"`
// limits is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
// and memory (in bytes, rounded up to the nearest MiB) limits
// +optional
Limits VirtualMachineResourceSpec `json:"limits,omitempty,omitzero"`
// shares is the definition of the VM's cpu and memory shares
// +optional
Shares VirtualMachineResourceShares `json:"shares,omitempty,omitzero"`
}

// VirtualMachineResourceSpec is the numerical definition of memory and cpu quantity for the
// given VM hardware policy.
// +kubebuilder:validation:MinProperties=1
type VirtualMachineResourceSpec struct {
// cpu is the definition of the cpu quantity for the given VM hardware policy
// +optional
CPU resource.Quantity `json:"cpu,omitempty"`

// memory is the definition of the memory quantity for the given VM hardware policy
// +optional
Memory resource.Quantity `json:"memory,omitempty"`
}

// VirtualMachineResourceShares is the numerical definition of memory and cpu shares for the
// given VM
// +kubebuilder:validation:MinProperties=1
type VirtualMachineResourceShares struct {
// cpu is the number of spu shares to assign to the VM
// +kubebuilder:validation:Minimum=1
// +optional
CPU int32 `json:"cpu,omitempty"`

// memory is the number of memory shares to assign to the VM
// +kubebuilder:validation:Minimum=1
// +optional
Memory int32 `json:"memory,omitempty"`
}

// VSphereDisk is an additional disk to add to the VM that is not part of the VM OVA template.
type VSphereDisk struct {
// Name is used to identify the disk definition. Name is required and needs to be unique so that it can be used to
Expand Down
51 changes: 51 additions & 0 deletions apis/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,77 @@ spec:
ResourcePool is the name, inventory path, managed object reference or the managed
object ID in which the virtual machine is created/located.
type: string
resources:
description: |-
resources is the definition of the VM's cpu and memory
reservations, limits and shares.
minProperties: 1
properties:
limits:
description: |-
limits is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
and memory (in bytes, rounded up to the nearest MiB) limits
minProperties: 1
properties:
cpu:
anyOf:
- type: integer
- type: string
description: cpu is the definition of the cpu quantity for
the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: memory is the definition of the memory quantity
for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
requests:
description: |-
requests is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
and memory (in bytes, rounded up to the nearest MiB) reservations
minProperties: 1
properties:
cpu:
anyOf:
- type: integer
- type: string
description: cpu is the definition of the cpu quantity for
the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: memory is the definition of the memory quantity
for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
shares:
description: shares is the definition of the VM's cpu and memory
shares
minProperties: 1
properties:
cpu:
description: cpu is the number of spu shares to assign to
the VM
format: int32
minimum: 1
type: integer
memory:
description: memory is the number of memory shares to assign
to the VM
format: int32
minimum: 1
type: integer
type: object
type: object
server:
description: |-
Server is the IP address or FQDN of the vSphere server on which
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,77 @@ spec:
ResourcePool is the name, inventory path, managed object reference or the managed
object ID in which the virtual machine is created/located.
type: string
resources:
description: |-
resources is the definition of the VM's cpu and memory
reservations, limits and shares.
minProperties: 1
properties:
limits:
description: |-
limits is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
and memory (in bytes, rounded up to the nearest MiB) limits
minProperties: 1
properties:
cpu:
anyOf:
- type: integer
- type: string
description: cpu is the definition of the cpu quantity
for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: memory is the definition of the memory
quantity for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
requests:
description: |-
requests is the definition of the VM's cpu (in hertz, rounded up to the nearest MHz)
and memory (in bytes, rounded up to the nearest MiB) reservations
minProperties: 1
properties:
cpu:
anyOf:
- type: integer
- type: string
description: cpu is the definition of the cpu quantity
for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: memory is the definition of the memory
quantity for the given VM hardware policy
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
shares:
description: shares is the definition of the VM's cpu
and memory shares
minProperties: 1
properties:
cpu:
description: cpu is the number of spu shares to assign
to the VM
format: int32
minimum: 1
type: integer
memory:
description: memory is the number of memory shares
to assign to the VM
format: int32
minimum: 1
type: integer
type: object
type: object
server:
description: |-
Server is the IP address or FQDN of the vSphere server on which
Expand Down
Loading