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

Commit

Permalink
feat: deploy snapshot chart with nutanix
Browse files Browse the repository at this point in the history
  • Loading branch information
faiq committed Mar 29, 2024
1 parent 6f41a6f commit ff05c28
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 36 deletions.
18 changes: 0 additions & 18 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-api-runtime-extensions-nutanix-manager-role
name: {{ include "chart.name" . }}-manager-role
rules:
- apiGroups:
- ""
Expand Down
1 change: 0 additions & 1 deletion make/addons.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ update-addon.aws-ccm.%: ; $(info $(M) updating aws ccm $* manifests)
.PHONY: update-addon.nutanix-csi
update-addon.nutanix-csi: ; $(info $(M) updating nutanix csi manifests)
./hack/addons/update-nutanix-csi.sh

7 changes: 3 additions & 4 deletions pkg/handlers/generic/lifecycle/csi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (c *CSIHandler) AfterControlPlaneInitialized(
return
}
if len(csiProviders.Providers) == 1 &&
csiProviders.Providers[0].StorageClassConfig != nil &&
len(csiProviders.Providers[0].StorageClassConfig) == 1 &&
csiProviders.DefaultStorage == nil {
csiProviders.DefaultStorage = &v1alpha1.DefaultStorage{
Expand All @@ -113,13 +112,13 @@ func (c *CSIHandler) AfterControlPlaneInitialized(
if !ok {
log.V(4).Info(
fmt.Sprintf(
"Skipping CSI handler, for provider given in %q. Provider handler not given ",
provider,
"Skipping CSI handler, for provider given in %s. Provider handler not given.",
provider.Name,
),
)
continue
}
log.Info(fmt.Sprintf("Creating csi provider %s", provider))
log.Info(fmt.Sprintf("Creating csi provider %s", provider.Name))
err = handler.Apply(
ctx,
provider,
Expand Down
53 changes: 46 additions & 7 deletions pkg/handlers/generic/lifecycle/csi/nutanix-csi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ import (
)

const (
defaultHelmRepositoryURL = "https://nutanix.github.io/helm/"
defaultHelmChartVersion = "v2.6.6"
defaultHelmChartName = "nutanix-csi-storage"
defaultHelmReleaseNameTemplate = "nutanix-csi-storage-%s"
defaultHelmRepositoryURL = "https://nutanix.github.io/helm/"
defaultStorageHelmChartVersion = "v2.6.6"
defaultStorageHelmChartName = "nutanix-csi-storage"
defaultStorageHelmReleaseNameTemplate = "nutanix-csi-storage-%s"

defaultSnapshotHelmChartVersion = "v6.3.2"
defaultSnapshotHelmChartName = "nutanix-csi-snapshot"
defaultSnapshotHelmReleaseNameTemplate = "nutanix-csi-snapshot-%s"
)

type NutanixCSIConfig struct {
Expand Down Expand Up @@ -141,13 +145,13 @@ func (n *NutanixCSI) handleHelmAddonApply(
},
Spec: caaphv1.HelmChartProxySpec{
RepoURL: defaultHelmRepositoryURL,
ChartName: defaultHelmChartName,
ChartName: defaultStorageHelmChartName,
ClusterSelector: metav1.LabelSelector{
MatchLabels: map[string]string{clusterv1.ClusterNameLabel: req.Cluster.Name},
},
ReleaseNamespace: req.Cluster.Namespace,
ReleaseName: fmt.Sprintf(defaultHelmReleaseNameTemplate, req.Cluster.Name),
Version: defaultHelmChartVersion,
ReleaseName: fmt.Sprintf(defaultStorageHelmReleaseNameTemplate, req.Cluster.Name),
Version: defaultStorageHelmChartVersion,
ValuesTemplate: values,
},
}
Expand All @@ -163,6 +167,41 @@ func (n *NutanixCSI) handleHelmAddonApply(
return fmt.Errorf("failed to apply nutanix-csi installation HelmChartProxy: %w", err)
}

snapshotChart := &caaphv1.HelmChartProxy{
TypeMeta: metav1.TypeMeta{
APIVersion: caaphv1.GroupVersion.String(),
Kind: "HelmChartProxy",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: req.Cluster.Namespace,
Name: "nutanix-csi-snapshot" + req.Cluster.Name,
},
Spec: caaphv1.HelmChartProxySpec{
RepoURL: defaultHelmRepositoryURL,
ChartName: defaultSnapshotHelmChartName,
ClusterSelector: metav1.LabelSelector{
MatchLabels: map[string]string{clusterv1.ClusterNameLabel: req.Cluster.Name},
},
ReleaseNamespace: req.Cluster.Namespace,
ReleaseName: fmt.Sprintf(defaultStorageHelmReleaseNameTemplate, req.Cluster.Name),
Version: defaultSnapshotHelmChartVersion,
},
}

if err = controllerutil.SetOwnerReference(&req.Cluster, snapshotChart, n.client.Scheme()); err != nil {
return fmt.Errorf(
"failed to set owner reference on nutanix-csi installation HelmChartProxy: %w",
err,
)
}

if err = client.ServerSideApply(ctx, n.client, snapshotChart); err != nil {
return fmt.Errorf(
"failed to apply nutanix-csi-snapshot installation HelmChartProxy: %w",
err,
)
}

return nil
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/handlers/generic/lifecycle/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Handlers struct {
clusterAutoscalerConfig *clusterautoscaler.Config
ebsConfig *awsebs.AWSEBSConfig
nutnaixCSIConfig *nutanixcsi.NutanixCSIConfig
awsCPIConfig *awscpi.AWSCPIConfig
awsccmConfig *awsccm.AWSCCMConfig
}

func New(globalOptions *options.GlobalOptions) *Handlers {
Expand Down Expand Up @@ -70,10 +70,6 @@ func (h *Handlers) AddFlags(flagSet *pflag.FlagSet) {
h.calicoCNIConfig.AddFlags("cni.calico", flagSet)
h.ciliumCNIConfig.AddFlags("cni.cilium", flagSet)
h.ebsConfig.AddFlags("awsebs", pflag.CommandLine)
<<<<<<< HEAD
h.awsccmConfig.AddFlags("awsccm", pflag.CommandLine)
=======
h.nutnaixCSIConfig.AddFlags("nutanixcsi", flagSet)
h.awsCPIConfig.AddFlags("awscpi", pflag.CommandLine)
>>>>>>> f7ff2e9 (fix: adds proper permissions and api fixes)
}

0 comments on commit ff05c28

Please sign in to comment.