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 Sep 24, 2024
1 parent 8f6ded4 commit 7642ae7
Show file tree
Hide file tree
Showing 50 changed files with 6,902 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Infrastructure"
crdName: infrastructures.config.openshift.io
featureGate: VSphereHostVMGroupZonal
tests:
onCreate:
- name: Should not be able to have empty affinity fields if ZoneType is HostGroup
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
affinity: {}
zone: generated-zone
zoneType: HostGroup
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
expectedError: "when zoneType is HostGroup, failuredomain topology affinity vmGroup, hostGroup and vmHostRule fields must be defined"
- name: zoneType must be HostGroup if affinity vmGroup, hostGroup and vmHostRule fields are defined
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
affinity:
vmGroup: vmg1
hostGroup: hg1
vmHostRule: mhr1
zone: generated-zone
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
expectedError: "when failuredomain topology affinity vmGroup, hostGroup and vmHostRule fields are defined failuredomain zoneType must be HostGroup"
- name: Should be able to create a vm-host zonal infrastructure spec
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
regionType: ComputeCluster
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
affinity:
vmGroup: vmg1
hostGroup: hg1
vmHostRule: mhr1
zone: generated-zone
zoneType: HostGroup
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
expected: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
regionType: ComputeCluster
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
affinity:
vmGroup: vmg1
hostGroup: hg1
vmHostRule: mhr1
zone: generated-zone
zoneType: HostGroup
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
- name: Should be able to create a non-vm-host zonal infrastructure spec
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
zone: generated-zone
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
expected: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec:
cloudConfig:
key: config
name: cloud-provider-config
platformSpec:
type: VSphere
vsphere:
failureDomains:
- name: generated-failure-domain
region: generated-region
server: server1.dev.cluster.com
topology:
computeCluster: /IBMCloud/host/vcs-8e-workload
datacenter: IBMCloud
datastore: /IBMCloud/datastore/mdcnc-ds-shared
networks:
- ocp-ci-seg-13
resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
zone: generated-zone
nodeNetworking:
external: {}
internal: {}
vcenters:
- datacenters:
- IBMCloud
port: 443
server: server1.dev.cluster.com
71 changes: 69 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.zoneType) && self.zoneType == 'HostGroup' ? self.topology.affinity.vmGroup != '' && self.topology.affinity.hostGroup != '' && self.topology.affinity.vmHostRule != '' : true",message="when zoneType is HostGroup, failuredomain topology affinity vmGroup, hostGroup and vmHostRule fields must be defined"
// +kubebuilder:validation:XValidation:rule="has(self.topology.affinity) && (self.topology.affinity.vmGroup != '' || self.topology.affinity.hostGroup != '' || self.topology.affinity.vmHostRule != '') ? has(self.zoneType) && self.zoneType == 'HostGroup' : true",message="when failuredomain topology affinity vmGroup, hostGroup and vmHostRule fields are defined failuredomain zoneType must be HostGroup"
type VSpherePlatformFailureDomainSpec struct {
// name defines the arbitrary but unique name
// of a failure domain.
Expand All @@ -1166,6 +1180,15 @@ type VSpherePlatformFailureDomainSpec struct {
// +kubebuilder:validation:Required
Region string `json:"region"`

// regionType defines the type of region that is used for this failure domain. The current available options
// are ComputeCluster and Datacenter.
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum=ComputeCluster;Datacenter
// +kubebuilder:validation:MinLength=9
// +kubebuilder:validation:MaxLength=14
// +kubebuilder:validation:Optional
// +optional
RegionType string `json:"regionType,omitempty"`

// zone defines the name of a zone tag that will
// be attached to a vCenter cluster. The tag
// category in vCenter must be named openshift-zone.
Expand All @@ -1174,6 +1197,15 @@ type VSpherePlatformFailureDomainSpec struct {
// +kubebuilder:validation:Required
Zone string `json:"zone"`

// zoneType defines the type of zone that is used for this failure domain. The current available options
// are HostGroup and ComputeCluster.
// +kubebuilder:validation:MinLength=9
// +kubebuilder:validation:MaxLength=14
// +kubebuilder:validation:Optional
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum=HostGroup;ComputeCluster
// +optional
ZoneType string `json:"zoneType,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 @@ -1261,6 +1293,41 @@ type VSpherePlatformTopology struct {
// +kubebuilder:validation:Pattern=`^/.*?/vm/.*?`
// +optional
Template string `json:"template,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
Affinity VSphereFailureDomainAffinity `json:"affinity,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.
type VSphereFailureDomainAffinity struct {
// 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
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
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
VMHostRule string `json:"vmHostRule,omitempty"`
}

// VSpherePlatformVCenterSpec stores the vCenter connection fields.
Expand Down
Loading

0 comments on commit 7642ae7

Please sign in to comment.