Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for CAPX #384

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
94451f1
[WIP] added nutanix support
deepakm-ntnx Feb 20, 2024
cc7f2b6
added yamls for crs and helmaddon
deepakm-ntnx Feb 21, 2024
8b93532
added generated file after make release
deepakm-ntnx Feb 21, 2024
df849f5
added placeholders for nutanix related clusterConfig
deepakm-ntnx Feb 22, 2024
1c3160e
fixed stale code
deepakm-ntnx Feb 22, 2024
223aa07
fixed the stale code
deepakm-ntnx Feb 22, 2024
39747e5
test fixes
deepakm-ntnx Feb 22, 2024
b9ab97a
updated licenses
deepakm-ntnx Feb 22, 2024
ddb879f
added first variable patch and tests (WIP)
deepakm-ntnx Feb 23, 2024
803193c
patches
deepakm-ntnx Feb 26, 2024
1138b9f
review comments fixes
deepakm-ntnx Feb 27, 2024
358610b
patches
deepakm-ntnx Feb 27, 2024
33d79c5
updated latest final yaml
deepakm-ntnx Feb 27, 2024
aed4b42
updated yaml with faultDomain
deepakm-ntnx Feb 27, 2024
a2c80fb
WIP added all the types as a placeholder to share across team members
deepakm-ntnx Feb 29, 2024
d5390bd
added cluster config variables
deepakm-ntnx Feb 29, 2024
2113e27
reverted year update in copyright for existing files
deepakm-ntnx Mar 1, 2024
72fb2e8
test fixes
deepakm-ntnx Mar 1, 2024
324c075
added prism central endpoint mutation
deepakm-ntnx Mar 1, 2024
3d5f6f0
updated prism central endpoint mutation
deepakm-ntnx Mar 1, 2024
7fb8d15
added machine details mutation
deepakm-ntnx Mar 5, 2024
14732dd
added nutanix into charts to install clusterclass
deepakm-ntnx Mar 5, 2024
b637285
need to add double $ sign in bases so that var remains in example yaml
deepakm-ntnx Mar 5, 2024
28835b7
using a dev build yaml. todo revert url of the yaml
deepakm-ntnx Mar 8, 2024
24653fa
now updated examples with latest state for completeness
deepakm-ntnx Mar 13, 2024
47da896
make lint fixes
deepakm-ntnx Mar 13, 2024
ded0d20
now able to apply nutanix cluster with topology with cre validating it
deepakm-ntnx Mar 13, 2024
0c9b408
removed temp file
deepakm-ntnx Mar 13, 2024
e415d46
now using clusterctl.yaml vars so that its easy to fill in values
deepakm-ntnx Mar 13, 2024
4a9c7e0
updated paths to new branch due to stackked PR related changes
deepakm-ntnx Mar 14, 2024
c422e2f
fixed examples.sync
deepakm-ntnx Mar 15, 2024
9c532c4
reorg of examples kustomize yamls
deepakm-ntnx Mar 15, 2024
62e86e8
fixed the naming of all the objects which was getting overriden thru …
deepakm-ntnx Mar 15, 2024
a3b6a9c
now added subnet settings in cre
deepakm-ntnx Mar 18, 2024
7688d3e
fixed NPE
deepakm-ntnx Mar 18, 2024
ec87ae3
Merge branch 'nutanix-cloud-native:main' into KRBN-8015
deepakm-ntnx Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions api/v1alpha1/clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type ClusterConfigSpec struct {
AWS *AWSSpec `json:"aws,omitempty"`
// +optional
Docker *DockerSpec `json:"docker,omitempty"`
// +optional
Nutanix *NutanixSpec `json:"nutanix,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the reviewing easier what do you think about opening a PR with just API changes for only the required input?


GenericClusterConfig `json:",inline"`

Expand Down Expand Up @@ -71,6 +73,16 @@ func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:
}.VariableSchema().OpenAPIV3Schema,
},
)
case s.Nutanix != nil:
maps.Copy(
clusterConfigProps.OpenAPIV3Schema.Properties,
map[string]clusterv1.JSONSchemaProps{
NutanixVariableName: NutanixSpec{}.VariableSchema().OpenAPIV3Schema,
"controlPlane": NodeConfigSpec{
Nutanix: &NutanixNodeSpec{},
}.VariableSchema().OpenAPIV3Schema,
},
)
}

return clusterConfigProps
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ const (
ClusterAutoscalerVariableName = "clusterAutoscaler"
// AWSVariableName is the AWS config patch variable name.
AWSVariableName = "aws"
// NutanixVariableName is the Nutanix config patch variable name.
NutanixVariableName = "nutanix"
)
9 changes: 9 additions & 0 deletions api/v1alpha1/node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type NodeConfigSpec struct {
AWS *AWSNodeSpec `json:"aws,omitempty"`
// +optional
Docker *DockerNodeSpec `json:"docker,omitempty"`
// +optional
Nutanix *NutanixNodeSpec `json:"nutanix,omitempty"`
}

func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
Expand All @@ -49,6 +51,13 @@ func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
"docker": DockerNodeSpec{}.VariableSchema().OpenAPIV3Schema,
},
)
case s.Nutanix != nil:
maps.Copy(
nodeConfigProps.OpenAPIV3Schema.Properties,
map[string]clusterv1.JSONSchemaProps{
"nutanix": NutanixNodeSpec{}.VariableSchema().OpenAPIV3Schema,
},
)
}

return nodeConfigProps
Expand Down
162 changes: 162 additions & 0 deletions api/v1alpha1/nutanix_clusterconfig_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Copyright 2024 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

type NutanixSpec struct {
PrismCentralEndpoint *NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint,omitempty"`
ControlPlaneEndpoint *NutanixControlPlaneEndpointSpec `json:"controlPlaneEndpoint,omitempty"`
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
}

func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix cluster configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
"controlPlaneEndpoint": NutanixControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
"failureDomains": NutanixFailureDomains{}.VariableSchema().OpenAPIV3Schema,
},
},
}
}

type NutanixPrismCentralEndpointSpec struct {
Host string `json:"host"`
Port int32 `json:"port"`
Insecure bool `json:"insecure"`
AdditionalTrustBundle string `json:"additionalTrustBundle,omitempty"`
CredentialSecret string `json:"credentialSecret"`
}

func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix Prism Central endpoint configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"host": {
Description: "host ip/fqdn for Prism Central Server",
Type: "string",
},
"port": {
Description: "port for Prism Central Server",
Type: "integer",
},
"insecure": {
Description: "Prism Central Certificate checking",
Type: "boolean",
},
"additionalTrustBundle": {
Description: "Name of configMap with certificate trust bundle used for Prism Central connection",
Type: "string",
},
"credentialSecret": {
Description: "Name of a Credential information secret for the target Prism instance",
Type: "string",
},
},
},
}
}

type NutanixControlPlaneEndpointSpec struct {
deepakm-ntnx marked this conversation as resolved.
Show resolved Hide resolved
Host string `json:"host,omitempty"`
Port int32 `json:"port,omitempty"`
}

func (NutanixControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix control-plane endpoint configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"host": {
Description: "host ip/fqdn for control plane API Server",
Type: "string",
},
"port": {
Description: "port for control plane API Server",
Type: "integer",
},
},
},
}
}

type NutanixFailureDomains []NutanixFailureDomain

func (NutanixFailureDomains) VariableSchema() clusterv1.VariableSchema {
resourceSchema := NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema

return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix failure domains",
Type: "array",
Items: &resourceSchema,
},
}
}

type NutanixFailureDomain struct {
// name defines the unique name of a failure domain.
// Name is required and must be at most 64 characters in length.
// It must consist of only lower case alphanumeric characters and hyphens (-).
// It must start and end with an alphanumeric character.
// This value is arbitrary and is used to identify the failure domain within the platform.
Name string `json:"name"`

// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
// from the Prism Central console or using the prism_central API.
Cluster NutanixResourceIdentifier `json:"cluster"`

// subnets holds a list of identifiers (one or more) of the cluster's network subnets
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
// obtained from the Prism Central console or using the prism_central API.
Subnets []NutanixResourceIdentifier `json:"subnets"`

// indicates if a failure domain is suited for control plane nodes
ControlPlane bool `json:"controlPlane,omitempty"`
}

func (NutanixFailureDomain) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix Failure Domain",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"name": {
Description: "name of failure domain",
Type: "string",
},
"cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema,
"subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema,
"controlPlane": {
Description: "indicates if a failure domain is suited for control plane nodes",
Type: "boolean",
},
},
},
}
}

type NutanixResourceIdentifiers []NutanixResourceIdentifier

func (NutanixResourceIdentifiers) VariableSchema() clusterv1.VariableSchema {
resourceSchema := NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema

return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix resource identifier",
Type: "array",
Items: &resourceSchema,
},
}
}
Loading