Skip to content

Commit fe38373

Browse files
committed
NCN-100421 Added FailureDomains as mutation in caren
1 parent 55fdaf3 commit fe38373

File tree

13 files changed

+551
-700
lines changed

13 files changed

+551
-700
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"cmp"
2021
"fmt"
2122

2223
credentialTypes "github.com/nutanix-cloud-native/prism-go-client/environment/credentials"
24+
corev1 "k8s.io/api/core/v1"
2325
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2426
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2527
"sigs.k8s.io/cluster-api/errors"
@@ -162,6 +164,12 @@ func (ncl *NutanixCluster) GetPrismCentralCredentialRef() (*credentialTypes.Nuta
162164
return prismCentralInfo.CredentialRef, nil
163165
}
164166

167+
// GetNamespacedName returns the namespaced name of the NutanixCluster.
168+
func (ncl *NutanixCluster) GetNamespacedName() string {
169+
namespace := cmp.Or(ncl.Namespace, corev1.NamespaceDefault)
170+
return fmt.Sprintf("%s/%s", namespace, ncl.Name)
171+
}
172+
165173
// +kubebuilder:object:root=true
166174

167175
// NutanixClusterList contains a list of NutanixCluster

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

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ const (
3535
// resources associated with NutanixMachine before removing it from the
3636
// API Server.
3737
NutanixMachineFinalizer = "nutanixmachine.infrastructure.cluster.x-k8s.io"
38+
39+
// NutanixMachineBootstrapRefKindSecret represents the Kind of Secret
40+
// referenced by NutanixMachine's BootstrapRef.
41+
NutanixMachineBootstrapRefKindSecret = "Secret"
42+
43+
// NutanixMachineBootstrapRefKindImage represents the Kind of Image
44+
// referenced by NutanixMachine's BootstrapRef. If the BootstrapRef.Kind is set
45+
// to Image, the NutanixMachine will be created with the image mounted
46+
// as a CD-ROM.
47+
NutanixMachineBootstrapRefKindImage = "Image"
3848
)
3949

4050
// NutanixMachineSpec defines the desired state of NutanixMachine

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,93 @@ spec:
571571
- host
572572
- port
573573
type: object
574+
failureDomains:
575+
description: |-
576+
failureDomains configures failure domains information for the Nutanix platform.
577+
When set, the failure domains defined here may be used to spread Machines across
578+
prism element clusters to improve fault tolerance of the cluster.
579+
items:
580+
description: NutanixFailureDomain configures failure domain
581+
information for Nutanix.
582+
properties:
583+
cluster:
584+
description: |-
585+
cluster is to identify the cluster (the Prism Element under management of the Prism Central),
586+
in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
587+
from the Prism Central console or using the prism_central API.
588+
properties:
589+
name:
590+
description: name is the resource name in the PC
591+
type: string
592+
type:
593+
description: Type is the identifier type to use for
594+
this resource.
595+
enum:
596+
- uuid
597+
- name
598+
type: string
599+
uuid:
600+
description: uuid is the UUID of the resource in the
601+
PC.
602+
type: string
603+
required:
604+
- type
605+
type: object
606+
controlPlane:
607+
description: indicates if a failure domain is suited for
608+
control plane nodes
609+
type: boolean
610+
name:
611+
description: |-
612+
name defines the unique name of a failure domain.
613+
Name is required and must be at most 64 characters in length.
614+
It must consist of only lower case alphanumeric characters and hyphens (-).
615+
It must start and end with an alphanumeric character.
616+
This value is arbitrary and is used to identify the failure domain within the platform.
617+
maxLength: 64
618+
minLength: 1
619+
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
620+
type: string
621+
subnets:
622+
description: |-
623+
subnets holds a list of identifiers (one or more) of the cluster's network subnets
624+
for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
625+
obtained from the Prism Central console or using the prism_central API.
626+
items:
627+
description: NutanixResourceIdentifier holds the identity
628+
of a Nutanix PC resource (cluster, image, subnet, etc.)
629+
properties:
630+
name:
631+
description: name is the resource name in the PC
632+
type: string
633+
type:
634+
description: Type is the identifier type to use for
635+
this resource.
636+
enum:
637+
- uuid
638+
- name
639+
type: string
640+
uuid:
641+
description: uuid is the UUID of the resource in the
642+
PC.
643+
type: string
644+
required:
645+
- type
646+
type: object
647+
minItems: 1
648+
type: array
649+
x-kubernetes-list-map-keys:
650+
- type
651+
x-kubernetes-list-type: map
652+
required:
653+
- cluster
654+
- name
655+
- subnets
656+
type: object
657+
type: array
658+
x-kubernetes-list-map-keys:
659+
- name
660+
x-kubernetes-list-type: map
574661
prismCentralEndpoint:
575662
description: Nutanix Prism Central endpoint configuration.
576663
properties:

api/v1alpha1/nutanix_clusterconfig_types.go

+44
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ type NutanixSpec struct {
2323
// Nutanix Prism Central endpoint configuration.
2424
// +kubebuilder:validation:Required
2525
PrismCentralEndpoint NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint"`
26+
27+
// failureDomains configures failure domains information for the Nutanix platform.
28+
// When set, the failure domains defined here may be used to spread Machines across
29+
// prism element clusters to improve fault tolerance of the cluster.
30+
// +listType=map
31+
// +listMapKey=name
32+
// +kubebuilder:validation:Optional
33+
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
2634
}
2735

2836
type NutanixPrismCentralEndpointSpec struct {
@@ -76,3 +84,39 @@ func (s NutanixPrismCentralEndpointSpec) ParseURL() (string, int32, error) {
7684

7785
return hostname, int32(port), nil
7886
}
87+
88+
// NutanixFailureDomains is a list of FDs
89+
type NutanixFailureDomains []NutanixFailureDomain
90+
91+
// NutanixFailureDomain configures failure domain information for Nutanix.
92+
type NutanixFailureDomain struct {
93+
// name defines the unique name of a failure domain.
94+
// Name is required and must be at most 64 characters in length.
95+
// It must consist of only lower case alphanumeric characters and hyphens (-).
96+
// It must start and end with an alphanumeric character.
97+
// This value is arbitrary and is used to identify the failure domain within the platform.
98+
// +kubebuilder:validation:Required
99+
// +kubebuilder:validation:MinLength=1
100+
// +kubebuilder:validation:MaxLength=64
101+
// +kubebuilder:validation:Pattern=`[a-z0-9]([-a-z0-9]*[a-z0-9])?`
102+
Name string `json:"name"`
103+
104+
// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
105+
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
106+
// from the Prism Central console or using the prism_central API.
107+
// +kubebuilder:validation:Required
108+
Cluster NutanixResourceIdentifier `json:"cluster"`
109+
110+
// subnets holds a list of identifiers (one or more) of the cluster's network subnets
111+
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
112+
// obtained from the Prism Central console or using the prism_central API.
113+
// +kubebuilder:validation:Required
114+
// +kubebuilder:validation:MinItems=1
115+
// +listType=map
116+
// +listMapKey=type
117+
Subnets []NutanixResourceIdentifier `json:"subnets"`
118+
119+
// indicates if a failure domain is suited for control plane nodes
120+
// +kubebuilder:validation:Required
121+
ControlPlane bool `json:"controlPlane,omitempty"`
122+
}

api/v1alpha1/zz_generated.deepcopy.go

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ kind: Kustomization
77
resources:
88
- ../../../additional-resources/dockerhub-secret.yaml
99
- ../../../additional-resources/nutanix/csi-secret.yaml
10-
- https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/releases/download/${CAPX_VERSION}/cluster-template-topology.yaml
10+
- https://raw.githubusercontent.com/nutanix-cloud-native/cluster-api-provider-nutanix/74c5d337fe852b904b628d3d19a74f0949c37b1c/templates/cluster-template-topology.yaml
1111

1212
sortOptions:
1313
order: fifo

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
55
kind: Kustomization
66

77
resources:
8-
- https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/releases/download/${CAPX_VERSION}/cluster-template-clusterclass.yaml
8+
- https://raw.githubusercontent.com/nutanix-cloud-native/cluster-api-provider-nutanix/74c5d337fe852b904b628d3d19a74f0949c37b1c/templates/cluster-template-clusterclass.yaml
99

1010
configurations:
1111
- kustomizeconfig.yaml

hack/third-party/capx/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.22.1
77

88
toolchain go1.22.2
99

10-
require github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.4.0-alpha.2
10+
require github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.4.0-alpha.2.0.20240507152352-74c5d337fe85
1111

1212
require (
1313
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
@@ -24,7 +24,7 @@ require (
2424
github.com/mailru/easyjson v0.7.7 // indirect
2525
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2626
github.com/modern-go/reflect2 v1.0.2 // indirect
27-
github.com/nutanix-cloud-native/prism-go-client v0.3.4 // indirect
27+
github.com/nutanix-cloud-native/prism-go-client v0.4.0 // indirect
2828
github.com/pkg/errors v0.9.1 // indirect
2929
golang.org/x/net v0.24.0 // indirect
3030
golang.org/x/text v0.14.0 // indirect

0 commit comments

Comments
 (0)