Skip to content

Commit

Permalink
vSphere - add host and vm based zonal
Browse files Browse the repository at this point in the history
New feature gate VSphereHostVMGroupZonal
Add RegionType and ZoneType fields to VSpherePlatformFailureDomainSpec to specify region and zone failure domain types.
Add VSphereFailureDomainAffinity type that contains three fields required for vm-host zonal: VMGroup, HostGroup and VMHostRule.
Add VSphereFailureDomainAffinity to VSpherePlatformTopology
Create additional unit tests to cover the introduction of vm-host zonal provisioning types.
Add VMGroup in a machine(s) workspace.
  • Loading branch information
jcpowermac committed Oct 3, 2024
1 parent 0b90db1 commit 906bb28
Show file tree
Hide file tree
Showing 52 changed files with 9,220 additions and 100 deletions.

Large diffs are not rendered by default.

75 changes: 73 additions & 2 deletions config/v1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,22 @@ type VSpherePlatformLoadBalancer struct {
Type PlatformLoadBalancerType `json:"type,omitempty"`
}

// VSpherePlatformFailureDomainSpec holds the region and zone failure domain and
// the vCenter topology of that failure domain.
// The VSphereFailureDomainType is a string representation of a failure domain
// type. There are three supportable types: HostGroup, ComputeCluster and Datacenter
type VSphereFailureDomainType string

const (
// HostGroupFailureDomain is a failure domain for a vCenter vm-host group.
HostGroupFailureDomain VSphereFailureDomainType = "HostGroup"
// ComputeClusterFailureDomain is a failure domain for a vCenter compute cluster.
ComputeClusterFailureDomain VSphereFailureDomainType = "ComputeCluster"
// DatacenterFailureDomain is a failure domain for a vCenter datacenter.
DatacenterFailureDomain VSphereFailureDomainType = "Datacenter"
)

// VSpherePlatformFailureDomainSpec holds the region and zone failure domain and the vCenter topology of that failure domain.
// +kubebuilder:validation:XValidation:rule="has(self.zoneAffinity) && self.zoneAffinity.type == 'HostGroup' ? has(self.regionAffinity) && self.regionAffinity.type == 'ComputeCluster' : true",message="when zoneAffinity type is HostGroup, regionAffinity type must be ComputeCluster"
// +kubebuilder:validation:XValidation:rule="has(self.zoneAffinity) && self.zoneAffinity.type == 'ComputeCluster' ? has(self.regionAffinity) && self.regionAffinity.type == 'Datacenter' : true",message="when zoneAffinity type is ComputeCluster, regionAffinity type must be Datacenter"
type VSpherePlatformFailureDomainSpec struct {
// name defines the arbitrary but unique name
// of a failure domain.
Expand All @@ -1174,6 +1188,22 @@ type VSpherePlatformFailureDomainSpec struct {
// +kubebuilder:validation:Required
Zone string `json:"zone"`

// affinity holds the VMGroup and the HostGroup names in vCenter corresponds to
// a vm-host group of type Virtual Machine and Host respectively. Is also
// contains the VMHostRule which is an affinity vm-host rule in vCenter.
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:Optional
// +optional
RegionAffinity VSphereFailureDomainAffinity `json:"regionAffinity,omitempty"`

// affinity holds the VMGroup and the HostGroup names in vCenter corresponds to
// a vm-host group of type Virtual Machine and Host respectively. Is also
// contains the VMHostRule which is an affinity vm-host rule in vCenter.
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:Optional
// +optional
ZoneAffinity VSphereFailureDomainAffinity `json:"zoneAffinity,omitempty"`

// server is the fully-qualified domain name or the IP address of the vCenter server.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Expand Down Expand Up @@ -1263,6 +1293,47 @@ type VSpherePlatformTopology struct {
Template string `json:"template,omitempty"`
}

// VSphereFailureDomainAffinity contains the vCenter cluster vm-host group (virtual machine and host types)
// and the vm-host affinity rule that together creates a affinity configuration for vm-host based zonal.
// This configuration within vCenter creates the required association between a failure domain, virtual machines
// and ESXi hosts to create a vm-host based zone.
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'HostGroup' ? has(self.hostGroup) : true",message="when type is HostGroup, hostGroup field must be defined"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type != 'HostGroup' ? !has(self.hostGroup) : true",message="when hostGroup field is defined, type must be HostGroup"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'HostGroup' ? has(self.vmGroup) : true",message="when type is HostGroup, vmGroup field must be defined"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type != 'HostGroup' ? !has(self.vmGroup) : true",message="when vmGroup field is defined, type must be HostGroup"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'HostGroup' ? has(self.vmHostRule) : true",message="when type is HostGroup, vmHostRule field must be defined"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type != 'HostGroup' ? !has(self.vmHostRule) : true",message="when vmHostRule field is defined, type must be HostGroup"
// +union
type VSphereFailureDomainAffinity struct {
// +kubebuilder:validation:Optional
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum=HostGroup;ComputeCluster;Datacenter
// +unionDiscriminator
Type VSphereFailureDomainType `json:"type"`
// vmGroup is the name of the vm-host group of type virtual machine within vCenter for this failure domain.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:MaxLength=80
// +optional
// +unionMember,optional
VMGroup string `json:"vmGroup,omitempty"`

// hostGroup is the name of the vm-host group of type host within vCenter for this failure domain.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:MaxLength=80
// +optional
// +unionMember,optional
HostGroup string `json:"hostGroup,omitempty"`

// vmHostRule is the name of the affinity vm-host rule within vCenter for this failure domain.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:MaxLength=80
// +optional
// +unionMember,optional
VMHostRule string `json:"vmHostRule,omitempty"`
}

// VSpherePlatformVCenterSpec stores the vCenter connection fields.
// This is used by the vSphere CCM.
type VSpherePlatformVCenterSpec struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,9 @@ spec:
failureDomains contains the definition of region, zone and the vCenter topology.
If this is omitted failure domains (regions and zones) will not be used.
items:
description: |-
VSpherePlatformFailureDomainSpec holds the region and zone failure domain and
the vCenter topology of that failure domain.
description: VSpherePlatformFailureDomainSpec holds the
region and zone failure domain and the vCenter topology
of that failure domain.
properties:
name:
description: |-
Expand All @@ -627,6 +627,65 @@ spec:
maxLength: 80
minLength: 1
type: string
regionAffinity:
description: |-
affinity holds the VMGroup and the HostGroup names in vCenter corresponds to
a vm-host group of type Virtual Machine and Host respectively. Is also
contains the VMHostRule which is an affinity vm-host rule in vCenter.
properties:
hostGroup:
description: |-
hostGroup is the name of the vm-host group of type host within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
type:
description: |-
The VSphereFailureDomainType is a string representation of a failure domain
type. There are three supportable types: HostGroup, ComputeCluster and Datacenter
enum:
- HostGroup
- ComputeCluster
- Datacenter
type: string
vmGroup:
description: |-
vmGroup is the name of the vm-host group of type virtual machine within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
vmHostRule:
description: |-
vmHostRule is the name of the affinity vm-host rule within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
type: object
x-kubernetes-validations:
- message: when type is HostGroup, hostGroup field must
be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.hostGroup) : true'
- message: when hostGroup field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.hostGroup) : true'
- message: when type is HostGroup, vmGroup field must
be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.vmGroup) : true'
- message: when vmGroup field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.vmGroup) : true'
- message: when type is HostGroup, vmHostRule field
must be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.vmHostRule) : true'
- message: when vmHostRule field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.vmHostRule) : true'
server:
anyOf:
- format: ipv4
Expand Down Expand Up @@ -727,13 +786,83 @@ spec:
maxLength: 80
minLength: 1
type: string
zoneAffinity:
description: |-
affinity holds the VMGroup and the HostGroup names in vCenter corresponds to
a vm-host group of type Virtual Machine and Host respectively. Is also
contains the VMHostRule which is an affinity vm-host rule in vCenter.
properties:
hostGroup:
description: |-
hostGroup is the name of the vm-host group of type host within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
type:
description: |-
The VSphereFailureDomainType is a string representation of a failure domain
type. There are three supportable types: HostGroup, ComputeCluster and Datacenter
enum:
- HostGroup
- ComputeCluster
- Datacenter
type: string
vmGroup:
description: |-
vmGroup is the name of the vm-host group of type virtual machine within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
vmHostRule:
description: |-
vmHostRule is the name of the affinity vm-host rule within vCenter for this failure domain.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
type: string
type: object
x-kubernetes-validations:
- message: when type is HostGroup, hostGroup field must
be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.hostGroup) : true'
- message: when hostGroup field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.hostGroup) : true'
- message: when type is HostGroup, vmGroup field must
be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.vmGroup) : true'
- message: when vmGroup field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.vmGroup) : true'
- message: when type is HostGroup, vmHostRule field
must be defined
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.vmHostRule) : true'
- message: when vmHostRule field is defined, type must
be HostGroup
rule: 'has(self.type) && self.type != ''HostGroup''
? !has(self.vmHostRule) : true'
required:
- name
- region
- server
- topology
- zone
type: object
x-kubernetes-validations:
- message: when zoneAffinity type is HostGroup, regionAffinity
type must be ComputeCluster
rule: 'has(self.zoneAffinity) && self.zoneAffinity.type
== ''HostGroup'' ? has(self.regionAffinity) && self.regionAffinity.type
== ''ComputeCluster'' : true'
- message: when zoneAffinity type is ComputeCluster, regionAffinity
type must be Datacenter
rule: 'has(self.zoneAffinity) && self.zoneAffinity.type
== ''ComputeCluster'' ? has(self.regionAffinity) &&
self.regionAffinity.type == ''Datacenter'' : true'
type: array
x-kubernetes-list-map-keys:
- name
Expand Down
Loading

0 comments on commit 906bb28

Please sign in to comment.