Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 3c68b43

Browse files
committed
fix: added support for capx
1 parent 2ec54be commit 3c68b43

File tree

34 files changed

+2955
-5
lines changed

34 files changed

+2955
-5
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type ClusterConfigSpec struct {
4545
AWS *AWSSpec `json:"aws,omitempty"`
4646
// +optional
4747
Docker *DockerSpec `json:"docker,omitempty"`
48+
// +optional
49+
Nutanix *NutanixSpec `json:"nutanix,omitempty"`
4850

4951
GenericClusterConfig `json:",inline"`
5052

@@ -76,6 +78,16 @@ func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:
7678
}.VariableSchema().OpenAPIV3Schema,
7779
},
7880
)
81+
case s.Nutanix != nil:
82+
maps.Copy(
83+
clusterConfigProps.OpenAPIV3Schema.Properties,
84+
map[string]clusterv1.JSONSchemaProps{
85+
NutanixVariableName: NutanixSpec{}.VariableSchema().OpenAPIV3Schema,
86+
"controlPlane": NodeConfigSpec{
87+
Nutanix: &NutanixNodeSpec{},
88+
}.VariableSchema().OpenAPIV3Schema,
89+
},
90+
)
7991
}
8092

8193
return clusterConfigProps

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ const (
1212
ClusterAutoscalerVariableName = "clusterAutoscaler"
1313
// AWSVariableName is the AWS config patch variable name.
1414
AWSVariableName = "aws"
15+
// NutanixVariableName is the Nutanix config patch variable name.
16+
NutanixVariableName = "nutanix"
1517
)

api/v1alpha1/node_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type NodeConfigSpec struct {
2929
AWS *AWSNodeSpec `json:"aws,omitempty"`
3030
// +optional
3131
Docker *DockerNodeSpec `json:"docker,omitempty"`
32+
// +optional
33+
Nutanix *NutanixNodeSpec `json:"nutanix,omitempty"`
3234
}
3335

3436
func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
@@ -49,6 +51,13 @@ func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
4951
"docker": DockerNodeSpec{}.VariableSchema().OpenAPIV3Schema,
5052
},
5153
)
54+
case s.Nutanix != nil:
55+
maps.Copy(
56+
nodeConfigProps.OpenAPIV3Schema.Properties,
57+
map[string]clusterv1.JSONSchemaProps{
58+
"nutanix": NutanixNodeSpec{}.VariableSchema().OpenAPIV3Schema,
59+
},
60+
)
5261
}
5362

5463
return nodeConfigProps
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// Copyright 2024 D2iQ, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
8+
)
9+
10+
type NutanixSpec struct {
11+
PrismCentralEndpoint *NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint,omitempty"`
12+
ControlPlaneEndpoint *NutanixControlPlaneEndpointSpec `json:"controlPlaneEndpoint,omitempty"`
13+
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
14+
}
15+
16+
func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
17+
return clusterv1.VariableSchema{
18+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
19+
Description: "Nutanix cluster configuration",
20+
Type: "object",
21+
Properties: map[string]clusterv1.JSONSchemaProps{
22+
"prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
23+
"controlPlaneEndpoint": NutanixControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
24+
"failureDomains": NutanixFailureDomains{}.VariableSchema().OpenAPIV3Schema,
25+
},
26+
},
27+
}
28+
}
29+
30+
type NutanixPrismCentralEndpointSpec struct {
31+
Host string `json:"host"`
32+
Port int32 `json:"port"`
33+
Insecure bool `json:"insecure"`
34+
AdditionalTrustBundle string `json:"additionalTrustBundle,omitempty"`
35+
CredentialSecret string `json:"credentialSecret"`
36+
}
37+
38+
func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema {
39+
return clusterv1.VariableSchema{
40+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
41+
Description: "Nutanix Prism Central endpoint configuration",
42+
Type: "object",
43+
Properties: map[string]clusterv1.JSONSchemaProps{
44+
"host": {
45+
Description: "host ip/fqdn for Prism Central Server",
46+
Type: "string",
47+
},
48+
"port": {
49+
Description: "port for Prism Central Server",
50+
Type: "integer",
51+
},
52+
"insecure": {
53+
Description: "Prism Central Certificate checking",
54+
Type: "boolean",
55+
},
56+
"additionalTrustBundle": {
57+
Description: "Name of configMap with certificate trust bundle used for Prism Central connection",
58+
Type: "string",
59+
},
60+
"credentialSecret": {
61+
Description: "Name of a Credential information secret for the target Prism instance",
62+
Type: "string",
63+
},
64+
},
65+
},
66+
}
67+
}
68+
69+
type NutanixControlPlaneEndpointSpec struct {
70+
Host string `json:"host,omitempty"`
71+
Port int32 `json:"port,omitempty"`
72+
}
73+
74+
func (NutanixControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema {
75+
return clusterv1.VariableSchema{
76+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
77+
Description: "Nutanix control-plane endpoint configuration",
78+
Type: "object",
79+
Properties: map[string]clusterv1.JSONSchemaProps{
80+
"host": {
81+
Description: "host ip/fqdn for control plane API Server",
82+
Type: "string",
83+
},
84+
"port": {
85+
Description: "port for control plane API Server",
86+
Type: "integer",
87+
},
88+
},
89+
},
90+
}
91+
}
92+
93+
type NutanixFailureDomains []NutanixFailureDomain
94+
95+
func (NutanixFailureDomains) VariableSchema() clusterv1.VariableSchema {
96+
resourceSchema := NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema
97+
98+
return clusterv1.VariableSchema{
99+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
100+
Description: "Nutanix failure domains",
101+
Type: "array",
102+
Items: &resourceSchema,
103+
},
104+
}
105+
}
106+
107+
type NutanixFailureDomain struct {
108+
// name defines the unique name of a failure domain.
109+
// Name is required and must be at most 64 characters in length.
110+
// It must consist of only lower case alphanumeric characters and hyphens (-).
111+
// It must start and end with an alphanumeric character.
112+
// This value is arbitrary and is used to identify the failure domain within the platform.
113+
Name string `json:"name"`
114+
115+
// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
116+
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
117+
// from the Prism Central console or using the prism_central API.
118+
Cluster NutanixResourceIdentifier `json:"cluster"`
119+
120+
// subnets holds a list of identifiers (one or more) of the cluster's network subnets
121+
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
122+
// obtained from the Prism Central console or using the prism_central API.
123+
Subnets []NutanixResourceIdentifier `json:"subnets"`
124+
125+
// indicates if a failure domain is suited for control plane nodes
126+
ControlPlane bool `json:"controlPlane,omitempty"`
127+
}
128+
129+
func (NutanixFailureDomain) VariableSchema() clusterv1.VariableSchema {
130+
return clusterv1.VariableSchema{
131+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
132+
Description: "Nutanix Failure Domain",
133+
Type: "object",
134+
Properties: map[string]clusterv1.JSONSchemaProps{
135+
"name": {
136+
Description: "name of failure domain",
137+
Type: "string",
138+
},
139+
"cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema,
140+
"subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema,
141+
"controlPlane": {
142+
Description: "indicates if a failure domain is suited for control plane nodes",
143+
Type: "boolean",
144+
},
145+
},
146+
},
147+
}
148+
}
149+
150+
type NutanixResourceIdentifiers []NutanixResourceIdentifier
151+
152+
func (NutanixResourceIdentifiers) VariableSchema() clusterv1.VariableSchema {
153+
resourceSchema := NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema
154+
155+
return clusterv1.VariableSchema{
156+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
157+
Description: "Nutanix resource identifier",
158+
Type: "array",
159+
Items: &resourceSchema,
160+
},
161+
}
162+
}

0 commit comments

Comments
 (0)