Skip to content

Commit 0e5febe

Browse files
committed
feat: Added FailureDomains as mutation in caren
1 parent a603e7f commit 0e5febe

File tree

8 files changed

+670
-0
lines changed

8 files changed

+670
-0
lines changed

Diff for: api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

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

Diff for: api/v1alpha1/nutanix_clusterconfig_types.go

+44
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"fmt"
88
"net/url"
99
"strconv"
10+
11+
capxv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
1012
)
1113

1214
const (
@@ -23,6 +25,14 @@ type NutanixSpec struct {
2325
// Nutanix Prism Central endpoint configuration.
2426
// +kubebuilder:validation:Required
2527
PrismCentralEndpoint NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint"`
28+
29+
// failureDomains configures failure domains information for the Nutanix platform.
30+
// When set, the failure domains defined here may be used to spread Machines across
31+
// prism element clusters to improve fault tolerance of the cluster.
32+
// +listType=map
33+
// +listMapKey=name
34+
// +kubebuilder:validation:Optional
35+
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
2636
}
2737

2838
type NutanixPrismCentralEndpointSpec struct {
@@ -76,3 +86,37 @@ func (s NutanixPrismCentralEndpointSpec) ParseURL() (string, int32, error) {
7686

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

Diff for: 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.
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
+++
2+
title = "Failure Domains"
3+
+++
4+
5+
Configure Failure Domains. Defines the Prism Element Cluster and subnets to use for creating Control Plane or Worker
6+
node VMs of Kubernetes Cluster.
7+
8+
## Examples
9+
10+
### Configure one or more Failure Domains
11+
12+
```yaml
13+
apiVersion: cluster.x-k8s.io/v1beta1
14+
kind: Cluster
15+
metadata:
16+
name: <NAME>
17+
spec:
18+
topology:
19+
variables:
20+
- name: clusterConfig
21+
value:
22+
nutanix:
23+
failureDomains:
24+
- cluster:
25+
name: pe-cluster-name-1
26+
type: name
27+
controlPlane: true
28+
name: failure-domain-name-1
29+
subnets:
30+
- name: subnet-name-1
31+
type: name
32+
- cluster:
33+
name: pe-cluster-name-2
34+
type: name
35+
controlPlane: true
36+
name: failure-domain-name-2
37+
subnets:
38+
- name: subnet-name-2
39+
type: name
40+
41+
```
42+
43+
Applying this configuration will result in the following value being set:
44+
45+
- `NutanixCluster`:
46+
47+
```yaml
48+
spec:
49+
template:
50+
spec:
51+
failureDomains:
52+
- cluster:
53+
name: pe-cluster-name-1
54+
type: name
55+
controlPlane: true
56+
name: failure-domain-name-1
57+
subnets:
58+
- name: subnet-name-1
59+
type: name
60+
- cluster:
61+
name: pe-cluster-name-2
62+
type: name
63+
controlPlane: true
64+
name: failure-domain-name-2
65+
subnets:
66+
- name: subnet-name-2
67+
type: name
68+
```
69+
70+
Note:
71+
72+
- Configuring Failure Domains is optional and if not configured then respective NutanixMachineTemplate's cluster and
73+
subnets will be used to create respective control plane and worker nodes
74+
75+
- Only one Failure Domain can be used per Machine Deployment. Worker nodes will be created on respective Prism Element
76+
cluster and subnet of the respective failure domain.
77+
78+
- Control plane nodes will be created on every failure domain's cluster which has ControlPlane boolean set to true.
79+
80+
Following is the way to set failure Domain to each Machine Deployment
81+
82+
- `NutanixCluster`:
83+
84+
```yaml
85+
workers:
86+
machineDeployments:
87+
- class: default-worker
88+
name: md-0
89+
failureDomain: failure-domain-name-1
90+
- class: default-worker
91+
name: md-1
92+
failureDomain: failure-domain-name-2
93+
```

0 commit comments

Comments
 (0)