Skip to content

Commit 75eee8c

Browse files
committed
feat: Added FailureDomains as mutation in caren
1 parent a603e7f commit 75eee8c

File tree

8 files changed

+709
-0
lines changed

8 files changed

+709
-0
lines changed

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

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,124 @@ spec:
508508
imageRegistries:
509509
items:
510510
properties:
511+
host:
512+
description: The hostname on which the API server is serving.
513+
minLength: 1
514+
type: string
515+
port:
516+
description: The port on which the API server is serving.
517+
format: int32
518+
maximum: 65535
519+
minimum: 1
520+
type: integer
521+
virtualIP:
522+
description: Configuration for the virtual IP provider.
523+
properties:
524+
provider:
525+
default: KubeVIP
526+
description: Virtual IP provider to deploy.
527+
enum:
528+
- KubeVIP
529+
type: string
530+
type: object
531+
required:
532+
- host
533+
- port
534+
type: object
535+
failureDomains:
536+
description: |-
537+
failureDomains configures failure domains information for the Nutanix platform.
538+
When set, the failure domains defined here may be used to spread Machines across
539+
prism element clusters to improve fault tolerance of the cluster.
540+
items:
541+
description: NutanixFailureDomain configures failure domain
542+
information for Nutanix.
543+
properties:
544+
cluster:
545+
description: |-
546+
cluster is to identify the cluster (the Prism Element under management of the Prism Central),
547+
in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
548+
from the Prism Central console or using the prism_central API.
549+
properties:
550+
name:
551+
description: name is the resource name in the PC
552+
type: string
553+
type:
554+
description: Type is the identifier type to use for
555+
this resource.
556+
enum:
557+
- uuid
558+
- name
559+
type: string
560+
uuid:
561+
description: uuid is the UUID of the resource in the
562+
PC.
563+
type: string
564+
required:
565+
- type
566+
type: object
567+
controlPlane:
568+
description: indicates if a failure domain is suited for
569+
control plane nodes
570+
type: boolean
571+
name:
572+
description: |-
573+
name defines the unique name of a failure domain.
574+
Name is required and must be at most 64 characters in length.
575+
It must consist of only lower case alphanumeric characters and hyphens (-).
576+
It must start and end with an alphanumeric character.
577+
This value is arbitrary and is used to identify the failure domain within the platform.
578+
maxLength: 64
579+
minLength: 1
580+
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
581+
type: string
582+
subnets:
583+
description: |-
584+
subnets holds a list of identifiers (one or more) of the cluster's network subnets
585+
for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
586+
obtained from the Prism Central console or using the prism_central API.
587+
items:
588+
description: NutanixResourceIdentifier holds the identity
589+
of a Nutanix PC resource (cluster, image, subnet, etc.)
590+
properties:
591+
name:
592+
description: name is the resource name in the PC
593+
type: string
594+
type:
595+
description: Type is the identifier type to use for
596+
this resource.
597+
enum:
598+
- uuid
599+
- name
600+
type: string
601+
uuid:
602+
description: uuid is the UUID of the resource in the
603+
PC.
604+
type: string
605+
required:
606+
- type
607+
type: object
608+
minItems: 1
609+
type: array
610+
required:
611+
- cluster
612+
- name
613+
- subnets
614+
type: object
615+
type: array
616+
x-kubernetes-list-map-keys:
617+
- name
618+
x-kubernetes-list-type: map
619+
prismCentralEndpoint:
620+
description: Nutanix Prism Central endpoint configuration.
621+
properties:
622+
additionalTrustBundle:
623+
description: |-
624+
A base64 PEM encoded x509 cert for the RootCA that was used to create
625+
the certificate for a Prism Central that uses certificates that were issued by a non-publicly trusted RootCA.
626+
The trust bundle is added to the cert pool used to authenticate the TLS connection to the Prism Central.
627+
format: byte
628+
type: string
511629
credentials:
512630
description: Credentials and CA certificate for the image registry
513631
properties:

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 42 additions & 0 deletions
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,37 @@ 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+
Subnets []NutanixResourceIdentifier `json:"subnets"`
116+
117+
// indicates if a failure domain is suited for control plane nodes
118+
// +kubebuilder:validation:Required
119+
ControlPlane bool `json:"controlPlane,omitempty"`
120+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 93 additions & 0 deletions
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)