Skip to content

Commit 964389e

Browse files
committed
feature: Added FailureDomains as mutation in caren
1 parent 55fdaf3 commit 964389e

File tree

8 files changed

+674
-0
lines changed

8 files changed

+674
-0
lines changed

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

0 commit comments

Comments
 (0)