Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPLAT-1743: vSphere - add host and vm based zonal #1999

Merged
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

Large diffs are not rendered by default.

109 changes: 107 additions & 2 deletions config/v1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,30 @@ 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 VSphereFailureDomainZoneType is a string representation of a failure domain
// zone type. There are two supportable types HostGroup and ComputeCluster
// +enum
type VSphereFailureDomainZoneType string
jcpowermac marked this conversation as resolved.
Show resolved Hide resolved

// The VSphereFailureDomainRegionType is a string representation of a failure domain
// region type. There are two supportable types ComputeCluster and Datacenter
// +enum
type VSphereFailureDomainRegionType string

const (
// HostGroupFailureDomainZone is a failure domain zone for a vCenter vm-host group.
HostGroupFailureDomainZone VSphereFailureDomainZoneType = "HostGroup"
// ComputeClusterFailureDomainZone is a failure domain zone for a vCenter compute cluster.
ComputeClusterFailureDomainZone VSphereFailureDomainZoneType = "ComputeCluster"
// DatacenterFailureDomainRegion is a failure domain region for a vCenter datacenter.
DatacenterFailureDomainRegion VSphereFailureDomainRegionType = "Datacenter"
// ComputeClusterFailureDomainRegion is a failure domain region for a vCenter compute cluster.
ComputeClusterFailureDomainRegion VSphereFailureDomainRegionType = "ComputeCluster"
)

// VSpherePlatformFailureDomainSpec holds the region and zone failure domain and the vCenter topology of that failure domain.
// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereHostVMGroupZonal,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"
// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereHostVMGroupZonal,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 @@ -1188,6 +1210,21 @@ type VSpherePlatformFailureDomainSpec struct {
// +kubebuilder:validation:Required
Zone string `json:"zone"`

// regionAffinity holds the type of region, Datacenter or ComputeCluster.
// When set to Datacenter, this means the region is a vCenter Datacenter as defined in topology.
// When set to ComputeCluster, this means the region is a vCenter Cluster as defined in topology.
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +optional
RegionAffinity *VSphereFailureDomainRegionAffinity `json:"regionAffinity,omitempty"`

// zoneAffinity holds the type of the zone and the hostGroup which
// 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
// +optional
ZoneAffinity *VSphereFailureDomainZoneAffinity `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 @@ -1277,6 +1314,74 @@ type VSpherePlatformTopology struct {
Template string `json:"template,omitempty"`
}

// VSphereFailureDomainZoneAffinity contains the vCenter cluster vm-host group (virtual machine and host types)
// and the vm-host affinity rule that together creates an 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) : !has(self.hostGroup)",message="hostGroup is required when type is HostGroup, and forbidden otherwise"
// +union
type VSphereFailureDomainZoneAffinity struct {
// type determines the vSphere object type for a zone within this failure domain.
// Available types are ComputeCluster and HostGroup.
// When set to ComputeCluster, this means the vCenter cluster defined is the zone.
// When set to HostGroup, hostGroup must be configured with hostGroup, vmGroup and vmHostRule and
// this means the zone is defined by the grouping of those fields.
// +kubebuilder:validation:Enum:=HostGroup;ComputeCluster
// +kubebuilder:validation:Required
// +unionDiscriminator
Type VSphereFailureDomainZoneType `json:"type"`
jcpowermac marked this conversation as resolved.
Show resolved Hide resolved

// hostGroup 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.
// +unionMember
// +optional
HostGroup *VSphereFailureDomainHostGroup `json:"hostGroup,omitempty"`
}

// VSphereFailureDomainRegionAffinity contains the region type which is the string representation of the
// VSphereFailureDomainRegionType with available options of Datacenter and ComputeCluster.
// +union
type VSphereFailureDomainRegionAffinity struct {
jcpowermac marked this conversation as resolved.
Show resolved Hide resolved
// type determines the vSphere object type for a region within this failure domain.
// Available types are Datacenter and ComputeCluster.
// When set to Datacenter, this means the vCenter Datacenter defined is the region.
// When set to ComputeCluster, this means the vCenter cluster defined is the region.
// +kubebuilder:validation:Enum:=ComputeCluster;Datacenter
// +kubebuilder:validation:Required
// +unionDiscriminator
Type VSphereFailureDomainRegionType `json:"type"`
}

// VSphereFailureDomainHostGroup 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.
type VSphereFailureDomainHostGroup struct {
// vmGroup is the name of the vm-host group of type virtual machine within vCenter for this failure domain.
jcpowermac marked this conversation as resolved.
Show resolved Hide resolved
// vmGroup is limited to 80 characters.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Required
VMGroup string `json:"vmGroup"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We found no way to limit the character set here right? Same question for the other 2 as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, previous thread:
#1999 (comment)


// hostGroup is the name of the vm-host group of type host within vCenter for this failure domain.
// hostGroup is limited to 80 characters.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Required
HostGroup string `json:"hostGroup"`

// vmHostRule is the name of the affinity vm-host rule within vCenter for this failure domain.
// vmHostRule is limited to 80 characters.
// This field is required when the VSphereFailureDomain ZoneType is HostGroup
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Required
VMHostRule string `json:"vmHostRule"`
}

// 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 @@ -625,9 +625,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 @@ -644,6 +644,25 @@ spec:
maxLength: 80
minLength: 1
type: string
regionAffinity:
description: |-
regionAffinity holds the type of region, Datacenter or ComputeCluster.
When set to Datacenter, this means the region is a vCenter Datacenter as defined in topology.
When set to ComputeCluster, this means the region is a vCenter Cluster as defined in topology.
properties:
type:
description: |-
type determines the vSphere object type for a region within this failure domain.
Available types are Datacenter and ComputeCluster.
When set to Datacenter, this means the vCenter Datacenter defined is the region.
When set to ComputeCluster, this means the vCenter cluster defined is the region.
enum:
- ComputeCluster
- Datacenter
type: string
required:
- type
type: object
server:
anyOf:
- format: ipv4
Expand Down Expand Up @@ -744,13 +763,85 @@ spec:
maxLength: 80
minLength: 1
type: string
zoneAffinity:
description: |-
zoneAffinity holds the type of the zone and the hostGroup which
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 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.
hostGroup is limited to 80 characters.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
minLength: 1
type: string
vmGroup:
description: |-
vmGroup is the name of the vm-host group of type virtual machine within vCenter for this failure domain.
vmGroup is limited to 80 characters.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
minLength: 1
type: string
vmHostRule:
description: |-
vmHostRule is the name of the affinity vm-host rule within vCenter for this failure domain.
vmHostRule is limited to 80 characters.
This field is required when the VSphereFailureDomain ZoneType is HostGroup
maxLength: 80
minLength: 1
type: string
required:
- hostGroup
- vmGroup
- vmHostRule
type: object
type:
description: |-
type determines the vSphere object type for a zone within this failure domain.
Available types are ComputeCluster and HostGroup.
When set to ComputeCluster, this means the vCenter cluster defined is the zone.
When set to HostGroup, hostGroup must be configured with hostGroup, vmGroup and vmHostRule and
this means the zone is defined by the grouping of those fields.
enum:
- HostGroup
- ComputeCluster
type: string
required:
- type
type: object
x-kubernetes-validations:
- message: hostGroup is required when type is HostGroup,
and forbidden otherwise
rule: 'has(self.type) && self.type == ''HostGroup''
? has(self.hostGroup) : !has(self.hostGroup)'
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