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

feat: add nutanix csi #7

Merged
merged 31 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7662213
feat: adds nutanix csi to api
faiq Mar 18, 2024
e32da13
feat: minor API tweaks and adds tooling for chart
faiq Mar 19, 2024
d9f9e3e
feat: more api changes
faiq Mar 20, 2024
39cf44f
fix: adds proper permissions and api fixes
faiq Mar 21, 2024
c6733ba
fix: adds configuration for new storage to examples/
faiq Mar 21, 2024
d5c5ec2
fix: don't use deepcopy
faiq Mar 21, 2024
80a80db
fix: rename files to put the configmaps in the right place
faiq Mar 21, 2024
2280da1
refactor: apply suggestion from review
faiq Mar 26, 2024
efdeab1
fix: linting errors
faiq Mar 26, 2024
e4c3aa5
feat: adds nutanix driver create storage class
faiq Mar 26, 2024
e58e2f8
fix: pre-commit errors
faiq Mar 26, 2024
79defde
fix: pass in provisioner name
faiq Mar 27, 2024
7d0c094
refactor: deploy storage class as a cluster resource set
faiq Mar 27, 2024
a54e97c
refactor: change name of example sc
faiq Mar 28, 2024
dda31d8
fix: typo for default storage class key
faiq Mar 28, 2024
832cc64
fix: addon defaults for csi
faiq Mar 28, 2024
868022f
fix: sets the Items correctly
faiq Mar 28, 2024
25b05fc
fix: examples
faiq Mar 28, 2024
59bf818
fix: actually apply cm
faiq Mar 28, 2024
3eee6ce
fix: storage class crs
faiq Mar 28, 2024
f0397e5
fix: use a unique storage class cm per cluster
faiq Mar 28, 2024
c57e709
refactor: rename CSIProviders to CSI
faiq Mar 28, 2024
8ceebef
fix: more unit tests
faiq Mar 28, 2024
3269c5b
fix: gomod
faiq Mar 29, 2024
f963e97
test: adds a unit test for no params
faiq Mar 29, 2024
9ec05d1
feat: create crs from provider credentials
faiq Mar 29, 2024
13aa430
feat: set a default storage class if 1 provider and 1 storage class c…
faiq Mar 29, 2024
6845f96
refactor: use default storage config obj
faiq Mar 29, 2024
5ab09f8
feat: allow volume expansion
faiq Mar 29, 2024
05faebb
feat: deploy snapshot chart with nutanix
faiq Mar 29, 2024
7665a94
fix: apply suggestions from reviews
faiq Apr 1, 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
189 changes: 163 additions & 26 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
)

const (
AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet"
AddonStrategyHelmAddon AddonStrategy = "HelmAddon"
VolumeBindingImmediate = storagev1.VolumeBindingImmediate
VolumeBindingWaitForFirstConsumer = storagev1.VolumeBindingWaitForFirstConsumer

VolumeReclaimRecycle = corev1.PersistentVolumeReclaimRecycle
VolumeReclaimDelete = corev1.PersistentVolumeReclaimDelete
VolumeReclaimRetain = corev1.PersistentVolumeReclaimRetain
)

type Addons struct {
// +optional
CNI *CNI `json:"cni,omitempty"`
Expand All @@ -23,7 +37,7 @@ type Addons struct {
CCM *CCM `json:"ccm,omitempty"`

// +optional
CSIProviders *CSIProviders `json:"csi,omitempty"`
CSIProviders *CSI `json:"csi,omitempty"`
}

func (Addons) VariableSchema() clusterv1.VariableSchema {
Expand All @@ -35,7 +49,7 @@ func (Addons) VariableSchema() clusterv1.VariableSchema {
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
"clusterAutoscaler": ClusterAutoscaler{}.VariableSchema().OpenAPIV3Schema,
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
"csi": CSI{}.VariableSchema().OpenAPIV3Schema,
"ccm": CCM{}.VariableSchema().OpenAPIV3Schema,
},
},
Expand All @@ -44,11 +58,6 @@ func (Addons) VariableSchema() clusterv1.VariableSchema {

type AddonStrategy string

const (
AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet"
AddonStrategyHelmAddon AddonStrategy = "HelmAddon"
)

// CNI required for providing CNI configuration.
type CNI struct {
// +optional
Expand Down Expand Up @@ -134,40 +143,168 @@ func (ClusterAutoscaler) VariableSchema() clusterv1.VariableSchema {
}
}

type CSIProviders struct {
type DefaultStorage struct {
ProviderName string `json:"providerName"`
StorageClassConfigName string `json:"storageClassConfigName"`
}

type CSI struct {
// +optional
Providers []CSIProvider `json:"providers,omitempty"`
// +optional
DefaultClassName string `json:"defaultClassName,omitempty"`
DefaultStorage *DefaultStorage `json:"defaultStorage,omitempty"`
}

type CSIProvider struct {
Name string `json:"name,omitempty"`
Name string `json:"name"`

// +optional
StorageClassConfig []StorageClassConfig `json:"storageClassConfig,omitempty"`

Strategy AddonStrategy `json:"strategy"`

// +optional
Credentials *corev1.SecretReference `json:"credentials,omitempty"`
faiq marked this conversation as resolved.
Show resolved Hide resolved
dkoshkin marked this conversation as resolved.
Show resolved Hide resolved
}

func (CSIProviders) VariableSchema() clusterv1.VariableSchema {
supportedCSIProviders := []string{CSIProviderAWSEBS}
type StorageClassConfig struct {
Name string `json:"name"`

// +optional
Parameters map[string]string `json:"parameters,omitempty"`

// +optional
ReclaimPolicy corev1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy,omitempty"`

// +optional
VolumeBindingMode storagev1.VolumeBindingMode `json:"volumeBindingMode,omitempty"`

// +optional
AllowExpansion bool `json:"allowExpansion,omitempty"`
}

func (StorageClassConfig) VariableSchema() clusterv1.VariableSchema {
supportedReclaimPolicies := []string{
string(VolumeReclaimRecycle),
string(VolumeReclaimDelete),
string(VolumeReclaimRetain),
}
supportedBindingModes := []string{
string(VolumeBindingImmediate),
string(VolumeBindingWaitForFirstConsumer),
}
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "object",
Type: "object",
Required: []string{"name"},
Properties: map[string]clusterv1.JSONSchemaProps{
"providers": {
Type: "array",
Items: &clusterv1.JSONSchemaProps{
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"name": {
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(
supportedCSIProviders...),
},
"name": {
Type: "string",
Description: "Name of storage class config.",
},
"parameters": {
Type: "object",
Description: "Parameters passed into the storage class object.",
AdditionalProperties: &clusterv1.JSONSchemaProps{
Type: "string",
},
},
"reclaimPolicy": {
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(supportedReclaimPolicies...),
Default: variables.MustMarshal(VolumeReclaimDelete),
},
"volumeBindingMode": {
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(supportedBindingModes...),
Default: variables.MustMarshal(VolumeBindingWaitForFirstConsumer),
},
"allowExpansion": {
Type: "boolean",
Default: variables.MustMarshal(false),
Description: "If the storage class should allow volume expanding",
},
},
},
}
}

func (CSIProvider) VariableSchema() clusterv1.VariableSchema {
supportedCSIProviders := []string{CSIProviderAWSEBS, CSIProviderNutanix}
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "object",
Required: []string{"name", "strategy"},
Properties: map[string]clusterv1.JSONSchemaProps{
"name": {
Description: "Name of the CSI Provider",
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(
supportedCSIProviders...),
},
"strategy": {
Description: "Addon strategy used to deploy the CSI provider to the workload cluster",
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(
AddonStrategyClusterResourceSet,
AddonStrategyHelmAddon,
),
},
"credentials": {
Type: "object",
Description: "The reference to any secret used by the CSI Provider.",
Properties: map[string]clusterv1.JSONSchemaProps{
"name": {
Type: "string",
},
"namespace": {
Type: "string",
},
},
},
"defaultClassName": {
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(supportedCSIProviders...),
"storageClassConfig": {
Type: "array",
Items: ptr.To(StorageClassConfig{}.VariableSchema().OpenAPIV3Schema),
},
},
},
}
}

func (DefaultStorage) VariableSchema() clusterv1.VariableSchema {
supportedCSIProviders := []string{CSIProviderAWSEBS, CSIProviderNutanix}
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "object",
Description: "A tuple of provider name and storage class ",
Required: []string{"providerName", "storageClassConfigName"},
Properties: map[string]clusterv1.JSONSchemaProps{
"providerName": {
Type: "string",
Description: "Name of the CSI Provider for the default storage class",
Enum: variables.MustMarshalValuesToEnumJSON(
supportedCSIProviders...,
),
},
"storageClassConfigName": {
Type: "string",
Description: "Name of storage class config in any of the provider objects",
},
},
},
}
}

func (CSI) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"providers": {
Type: "array",
Items: ptr.To(CSIProvider{}.VariableSchema().OpenAPIV3Schema),
},
"defaultStorage": DefaultStorage{}.VariableSchema().OpenAPIV3Schema,
},
},
}
Expand Down
11 changes: 8 additions & 3 deletions api/v1alpha1/clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ import (
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/openapi/patterns"
)

type StorageProvisioner string

const (
CNIProviderCalico = "Calico"
CNIProviderCilium = "Cilium"
CNIProviderCalico = "Calico"
CNIProviderCilium = "Cilium"
AWSEBSProvisioner StorageProvisioner = "ebs.csi.aws.com"
NutanixProvisioner StorageProvisioner = "csi.nutanix.com"

CSIProviderAWSEBS = "aws-ebs"
CSIProviderAWSEBS = "aws-ebs"
CSIProviderNutanix = "nutanix"

CCMProviderAWS = "aws"
)
Expand Down
Loading
Loading