Skip to content

Commit 1a35a14

Browse files
committed
feat: update CAPX for NuanixFailureDomain support
1 parent 2007a42 commit 1a35a14

File tree

8 files changed

+249
-26
lines changed

8 files changed

+249
-26
lines changed

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/conditions.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ const (
2424
VolumeGroupDetachFailed = "VolumeGroupDetachFailed"
2525
)
2626

27+
// Conditions and Reasons releated to failure domain
2728
const (
28-
// FailureDomainsReconciled indicates the status of the failure domain reconciliation
29-
FailureDomainsReconciled capiv1.ConditionType = "FailureDomainsReconciled"
29+
// FailureDomainSafeForDeletionCondition indicates whether the failure domain object is safe for deletion,
30+
// ie., when it is not used or referenced by other resources
31+
FailureDomainSafeForDeletionCondition capiv1.ConditionType = "FailureDomainSafeForDeletion"
3032

31-
// NoFailureDomainsReconciled indicates no failure domains have been defined
32-
NoFailureDomainsReconciled capiv1.ConditionType = "NoFailureDomainsReconciled"
33+
// FailureDomainInUseReason indicates that the failure domain is used by
34+
// Machines and/or referenced by cluster
35+
FailureDomainInUseReason = "FailureDomainInUse"
3336

34-
// FailureDomainsReconciliationFailed indicates the failure domain reconciliation failed
35-
FailureDomainsReconciliationFailed = "FailureDomainsReconciliationFailed"
37+
// NoFailureDomainsConfiguredCondition indicates no failure domains have been configured
38+
NoFailureDomainsConfiguredCondition capiv1.ConditionType = "NoFailureDomainsConfigured"
39+
40+
// FailureDomainsValidatedCondition indicates whether the failure domains are configured correctly or not.
41+
FailureDomainsValidatedCondition capiv1.ConditionType = "FailureDomainsValidated"
42+
43+
// FailureDomainsMisconfiguredReason (Severity=Warning) indicates that some of the failure domains
44+
// are misconfigured.
45+
FailureDomainsMisconfiguredReason = "FailureDomainsMisconfigured"
3646
)
3747

3848
const (

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/nutanixcluster_types.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ type NutanixClusterSpec struct {
6464
// +listType=map
6565
// +listMapKey=name
6666
// +optional
67-
FailureDomains []NutanixFailureDomain `json:"failureDomains"`
67+
//
68+
// Deprecated: This field is replaced by the field controlPlaneFailureDomains and will be removed in the next apiVersion.
69+
//
70+
FailureDomains []NutanixFailureDomainConfig `json:"failureDomains,omitempty"`
71+
72+
// controlPlaneFailureDomains configures references to the NutanixFailureDomain objects
73+
// that the cluster uses to deploy its control-plane machines.
74+
// +listType=set
75+
// +optional
76+
ControlPlaneFailureDomains []corev1.LocalObjectReference `json:"controlPlaneFailureDomains,omitempty"`
6877
}
6978

7079
// NutanixClusterStatus defines the observed state of NutanixCluster
@@ -75,6 +84,8 @@ type NutanixClusterStatus struct {
7584
// +optional
7685
Ready bool `json:"ready,omitempty"`
7786

87+
// failureDomains are a list of failure domains configured in the
88+
// cluster's spec and validated by the cluster controller.
7889
FailureDomains capiv1.FailureDomains `json:"failureDomains,omitempty"`
7990

8091
// Conditions defines current service state of the NutanixCluster.
@@ -96,6 +107,7 @@ type NutanixClusterStatus struct {
96107
// +kubebuilder:storageversion
97108
// +kubebuilder:printcolumn:name="ControlplaneEndpoint",type="string",JSONPath=".spec.controlPlaneEndpoint.host",description="ControlplaneEndpoint"
98109
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="in ready status"
110+
// +kubebuilder:printcolumn:name="FailureDomains",type="string",JSONPath=".status.failureDomains",description="NutanixCluster FailureDomains"
99111

100112
// NutanixCluster is the Schema for the nutanixclusters API
101113
type NutanixCluster struct {
@@ -106,8 +118,10 @@ type NutanixCluster struct {
106118
Status NutanixClusterStatus `json:"status,omitempty"`
107119
}
108120

109-
// NutanixFailureDomain configures failure domain information for Nutanix.
110-
type NutanixFailureDomain struct {
121+
// NutanixFailureDomainConfig configures failure domain information for Nutanix.
122+
//
123+
// Deprecated: This type is replaced by the NutanixFailureDomain CRD type and will be removed in the next apiVersion.
124+
type NutanixFailureDomainConfig struct {
111125
// name defines the unique name of a failure domain.
112126
// Name is required and must be at most 64 characters in length.
113127
// It must consist of only lower case alphanumeric characters and hyphens (-).
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
Copyright 2025 Nutanix
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
)
23+
24+
const (
25+
// NutanixFailureDomainKind represents the Kind of NutanixFailureDomain
26+
NutanixFailureDomainKind = "NutanixFailureDomain"
27+
28+
// NutanixFailureDomainFinalizer is the finalizer used by the NutanixFailureDomain controller to block
29+
// deletion of the NutanixFailureDomain object if there are references to this object by other resources.
30+
NutanixFailureDomainFinalizer = "infrastructure.cluster.x-k8s.io/nutanixfailuredomain"
31+
)
32+
33+
// NutanixFailureDomainSpec defines the desired state of NutanixFailureDomain.
34+
type NutanixFailureDomainSpec struct {
35+
// prismElementCluster is to identify the Prism Element cluster in the Prism Central for the failure domain.
36+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="prismElementCluster is immutable once set"
37+
// +kubebuilder:validation:Required
38+
PrismElementCluster NutanixResourceIdentifier `json:"prismElementCluster"`
39+
40+
// subnets holds a list of identifiers (one or more) of the PE cluster's network subnets
41+
// for the Machine's VM to connect to.
42+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="subnets is immutable once set"
43+
// +kubebuilder:validation:Required
44+
// +kubebuilder:validation:MinItems=1
45+
Subnets []NutanixResourceIdentifier `json:"subnets"`
46+
}
47+
48+
// NutanixFailureDomainStatus defines the observed state of NutanixFailureDomain resource.
49+
type NutanixFailureDomainStatus struct {
50+
// conditions represent the latest states of the failure domain.
51+
// +optional
52+
Conditions []capiv1.Condition `json:"conditions,omitempty"`
53+
}
54+
55+
// +kubebuilder:object:root=true
56+
// +kubebuilder:resource:path=nutanixfailuredomains,shortName=nfd,scope=Namespaced,categories=cluster-api
57+
// +kubebuilder:subresource:status
58+
// +kubebuilder:storageversion
59+
60+
// NutanixFailureDomain is the Schema for the NutanixFailureDomain API.
61+
type NutanixFailureDomain struct {
62+
metav1.TypeMeta `json:",inline"`
63+
metav1.ObjectMeta `json:"metadata,omitempty"`
64+
65+
Spec NutanixFailureDomainSpec `json:"spec,omitempty"`
66+
Status NutanixFailureDomainStatus `json:"status,omitempty"`
67+
}
68+
69+
// GetConditions returns the set of conditions for this object.
70+
func (nfd *NutanixFailureDomain) GetConditions() capiv1.Conditions {
71+
return nfd.Status.Conditions
72+
}
73+
74+
// SetConditions sets the conditions on this object.
75+
func (nfd *NutanixFailureDomain) SetConditions(conditions capiv1.Conditions) {
76+
nfd.Status.Conditions = conditions
77+
}
78+
79+
// +kubebuilder:object:root=true
80+
81+
// NutanixFailureDomainList contains a list of NutanixFailureDomain
82+
type NutanixFailureDomainList struct {
83+
metav1.TypeMeta `json:",inline"`
84+
metav1.ListMeta `json:"metadata,omitempty"`
85+
Items []NutanixFailureDomain `json:"items"`
86+
}
87+
88+
func init() {
89+
SchemeBuilder.Register(&NutanixFailureDomain{}, &NutanixFailureDomainList{})
90+
}

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/nutanixmachine_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ type NutanixMachineStatus struct {
275275
// Will be set in case of failure of Machine instance
276276
// +optional
277277
FailureMessage *string `json:"failureMessage,omitempty"`
278+
279+
// failureDomain is the name of the failure domain where this Machine has been placed in.
280+
// +optional
281+
FailureDomain *string `json:"failureDomain,omitempty"`
278282
}
279283

280284
// +kubebuilder:object:root=true
@@ -284,6 +288,7 @@ type NutanixMachineStatus struct {
284288
// +kubebuilder:printcolumn:name="Address",type="string",JSONPath=".status.addresses[0].address",description="The VM address"
285289
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="NutanixMachine ready status"
286290
// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="NutanixMachine instance ID"
291+
// +kubebuilder:printcolumn:name="FailureDomain",type="string",JSONPath=".status.failureDomain",description="NutanixMachine FailureDomain"
287292
// NutanixMachine is the Schema for the nutanixmachines API
288293
type NutanixMachine struct {
289294
metav1.TypeMeta `json:",inline"`

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/zz_generated.deepcopy.go

Lines changed: 118 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/examples/bases/nutanix/clusterclass/kustomization.yaml.tmpl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ patches:
4646
- op: "remove"
4747
path: "/spec/template/spec/kubeadmConfigSpec/clusterConfiguration/apiServer/certSANs"
4848

49-
# TODO: Remove once https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/pull/519 is
50-
# merged and released.
51-
# Delete the API server cloud-provider flag from the template.
52-
# They will be added by the handler for k8s < 1.33.
53-
- target:
54-
kind: KubeadmControlPlaneTemplate
55-
patch: |-
56-
- op: "remove"
57-
path: "/spec/template/spec/kubeadmConfigSpec/clusterConfiguration/apiServer/extraArgs/cloud-provider"
58-
5949
# Template the kube-vip file.
6050
# The handler will set the variables if needed, or remove it.
6151
- target:

hack/third-party/capx/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.23.0
77

88
toolchain go1.24.2
99

10-
require github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.6.1
10+
require github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.7.0-beta.1
1111

1212
require (
1313
github.com/emicklei/go-restful/v3 v3.12.1 // indirect

hack/third-party/capx/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
7272
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
7373
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0=
7474
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
75-
github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.6.1 h1:LI08R0xuC3Z5YEW0FutU3FNrAmQ+1NWzYLE4unyyKdo=
76-
github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.6.1/go.mod h1:Hx0uph3fyiSupnLRfIQFteAs9B7F2uidnAoktRqp++M=
75+
github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.7.0-beta.1 h1:eaJeZGHYBFWkoDI885NI/n15Iz3IYmNWYPfYqJxnbUU=
76+
github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.7.0-beta.1/go.mod h1:Hx0uph3fyiSupnLRfIQFteAs9B7F2uidnAoktRqp++M=
7777
github.com/nutanix-cloud-native/prism-go-client v0.5.0 h1:aSNuKDOK7+q676MQyetYXcySY41IjSvN2UmrDIU3+6s=
7878
github.com/nutanix-cloud-native/prism-go-client v0.5.0/go.mod h1:QhLX+sEep0cStzHVYU6mPgIlnA8U3DySskagrbDprRk=
7979
github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0=

0 commit comments

Comments
 (0)