Skip to content

Commit

Permalink
cel,docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpowermac committed Sep 20, 2024
1 parent 3e5ba33 commit c5634ed
Show file tree
Hide file tree
Showing 38 changed files with 1,261 additions and 332 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
Original file line number Diff line number Diff line change
Expand Up @@ -129,42 +129,6 @@ tests:
port: 443
server: server4.dev.cluster.com
expectedError: "Too many: 4: must have at most 3 items"
- 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: "missing"
onUpdate:
- name: Should be able to modify vCenters to single from empty spec
initial: |
Expand Down
34 changes: 22 additions & 12 deletions config/v1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ const (

// 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 != '' : false",message="missing"
// +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 @@ -1180,7 +1181,7 @@ type VSpherePlatformFailureDomainSpec struct {

// 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
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum=ComputeCluster;Datacenter
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Optional
Expand All @@ -1200,7 +1201,7 @@ type VSpherePlatformFailureDomainSpec struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=80
// +kubebuilder:validation:Optional
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum="";HostGroup;ComputeCluster
// +openshift:validation:FeatureGateAwareEnum:featureGate=VSphereHostVMGroupZonal,enum=HostGroup;ComputeCluster
// +optional
ZoneType string `json:"zoneType,omitempty"`

Expand Down Expand Up @@ -1301,23 +1302,32 @@ type VSpherePlatformTopology struct {
Affinity VSphereFailureDomainAffinity `json:"affinity,omitempty"`
}


// VSphereFailureDomainAffinity contains the vSphere 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 {
// VMGroupName is the name of the VM group within vCenter for this failure domain
// VMGroupName 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"`

// HostGroupName is the name of the Host group within vcenter for this failure domain
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:MaxLength=80
// +optional
// 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 vm host rule within vCenter for this failure domain
// +openshift:validation:featureGate=VSphereHostVMGroupZonal
// +kubebuilder:validation:MaxLength=80
// +optional

// 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"`
}

Expand Down
Loading

0 comments on commit c5634ed

Please sign in to comment.