Skip to content

Commit

Permalink
first version of failure domain support for CAPX
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickstruyf3 committed Nov 28, 2023
1 parent 3154cb0 commit eb5abd5
Show file tree
Hide file tree
Showing 21 changed files with 711 additions and 33 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha4/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
)

const (
//PrismCentralClientCondition indicates the status of the client used to connect to Prism Central
// PrismCentralClientCondition indicates the status of the client used to connect to Prism Central
PrismCentralClientCondition capiv1.ConditionType = "PrismClientInit"

PrismCentralClientInitializationFailed = "PrismClientInitFailed"
Expand Down
41 changes: 41 additions & 0 deletions api/v1alpha4/nutanixcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ type NutanixClusterSpec struct {
// proxy spec.noProxy list.
// +optional
PrismCentral *credentialTypes.NutanixPrismEndpoint `json:"prismCentral"`

// failureDomains configures failure domains information for the Nutanix platform.
// When set, the failure domains defined here may be used to spread Machines across
// prism element clusters to improve fault tolerance of the cluster.
// +listType=map
// +listMapKey=name
// +optional
FailureDomains []NutanixFailureDomain `json:"failureDomains"`
}

// NutanixClusterStatus defines the observed state of NutanixCluster
Expand Down Expand Up @@ -90,6 +98,39 @@ type NutanixCluster struct {
Status NutanixClusterStatus `json:"status,omitempty"`
}

// NutanixFailureDomain configures failure domain information for Nutanix.
type NutanixFailureDomain struct {
// name defines the unique name of a failure domain.
// Name is required and must be at most 64 characters in length.
// It must consist of only lower case alphanumeric characters and hyphens (-).
// It must start and end with an alphanumeric character.
// This value is arbitrary and is used to identify the failure domain within the platform.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=64
// +kubebuilder:validation:Pattern=`[a-z0-9]([-a-z0-9]*[a-z0-9])?`
Name string `json:"name"`

// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
// from the Prism Central console or using the prism_central API.
// +kubebuilder:validation:Required
Cluster NutanixResourceIdentifier `json:"cluster"`

// subnets holds a list of identifiers (one or more) of the cluster's network subnets
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
// obtained from the Prism Central console or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +listType=map
// +listMapKey=type
Subnets []NutanixResourceIdentifier `json:"subnets"`

// indicates if a failure domain is suited for control plane nodes
// +kubebuilder:validation:Required
ControlPlane bool `json:"controlPlane,omitempty"`
}

// GetConditions returns the set of conditions for this object.
func (ncl *NutanixCluster) GetConditions() capiv1.Conditions {
return ncl.Status.Conditions
Expand Down
5 changes: 2 additions & 3 deletions api/v1alpha4/nutanixmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ type NutanixMachineSpec struct {
// of the Prism Central), in which the Machine's VM will be created.
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
Cluster NutanixResourceIdentifier `json:"cluster"`
// subnet is to identify the cluster's network subnet to use for the Machine's VM
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:Optional
Subnets []NutanixResourceIdentifier `json:"subnet"`
// List of categories that need to be added to the machines. Categories must already exist in Prism Central
// +kubebuilder:validation:Optional
Expand Down
42 changes: 42 additions & 0 deletions api/v1alpha4/zz_generated.conversion.go

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

30 changes: 30 additions & 0 deletions api/v1alpha4/zz_generated.deepcopy.go

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

10 changes: 10 additions & 0 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ const (
DeletionFailed = "DeletionFailed"
)

const (
// FailureDomainsReconciled indicates the status of the failure domain reconciliation
FailureDomainsReconciled capiv1.ConditionType = "FailureDomainsReconciled"

// NoFailureDomainsReconciled indicates no failure domains have been defined
NoFailureDomainsReconciled capiv1.ConditionType = "NoFailureDomainsReconciled"

FailureDomainsReconciliationFailed = "FailureDomainsReconciliationFailed"
)

const (
// ClusterCategoryCreatedCondition indicates the status of the category linked to the NutanixCluster
ClusterCategoryCreatedCondition capiv1.ConditionType = "ClusterCategoryCreated"
Expand Down
41 changes: 41 additions & 0 deletions api/v1beta1/nutanixcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ type NutanixClusterSpec struct {
// proxy spec.noProxy list.
// +optional
PrismCentral *credentialTypes.NutanixPrismEndpoint `json:"prismCentral"`

// failureDomains configures failure domains information for the Nutanix platform.
// When set, the failure domains defined here may be used to spread Machines across
// prism element clusters to improve fault tolerance of the cluster.
// +listType=map
// +listMapKey=name
// +optional
FailureDomains []NutanixFailureDomain `json:"failureDomains"`
}

// NutanixClusterStatus defines the observed state of NutanixCluster
Expand Down Expand Up @@ -91,6 +99,39 @@ type NutanixCluster struct {
Status NutanixClusterStatus `json:"status,omitempty"`
}

// NutanixFailureDomain configures failure domain information for Nutanix.
type NutanixFailureDomain struct {
// name defines the unique name of a failure domain.
// Name is required and must be at most 64 characters in length.
// It must consist of only lower case alphanumeric characters and hyphens (-).
// It must start and end with an alphanumeric character.
// This value is arbitrary and is used to identify the failure domain within the platform.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=64
// +kubebuilder:validation:Pattern=`[a-z0-9]([-a-z0-9]*[a-z0-9])?`
Name string `json:"name"`

// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
// from the Prism Central console or using the prism_central API.
// +kubebuilder:validation:Required
Cluster NutanixResourceIdentifier `json:"cluster"`

// subnets holds a list of identifiers (one or more) of the cluster's network subnets
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
// obtained from the Prism Central console or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +listType=map
// +listMapKey=type
Subnets []NutanixResourceIdentifier `json:"subnets"`

// indicates if a failure domain is suited for control plane nodes
// +kubebuilder:validation:Required
ControlPlane bool `json:"controlPlane,omitempty"`
}

// GetConditions returns the set of conditions for this object.
func (ncl *NutanixCluster) GetConditions() capiv1.Conditions {
return ncl.Status.Conditions
Expand Down
5 changes: 2 additions & 3 deletions api/v1beta1/nutanixmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ type NutanixMachineSpec struct {
// of the Prism Central), in which the Machine's VM will be created.
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
Cluster NutanixResourceIdentifier `json:"cluster"`
// subnet is to identify the cluster's network subnet to use for the Machine's VM
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:Optional
Subnets []NutanixResourceIdentifier `json:"subnet"`
// List of categories that need to be added to the machines. Categories must already exist in Prism Central
// +kubebuilder:validation:Optional
Expand Down
30 changes: 30 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Loading

0 comments on commit eb5abd5

Please sign in to comment.