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

Commit cb080d9

Browse files
committed
feat: deploy snapshot chart with nutanix
1 parent 05951a9 commit cb080d9

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

pkg/handlers/generic/lifecycle/csi/handler.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (c *CSIHandler) AfterControlPlaneInitialized(
9999
return
100100
}
101101
if len(csiProviders.Providers) == 1 &&
102-
csiProviders.Providers[0].StorageClassConfig != nil &&
103102
len(csiProviders.Providers[0].StorageClassConfig) == 1 &&
104103
csiProviders.DefaultStorage == nil {
105104
csiProviders.DefaultStorage = &v1alpha1.DefaultStorage{
@@ -113,13 +112,13 @@ func (c *CSIHandler) AfterControlPlaneInitialized(
113112
if !ok {
114113
log.V(4).Info(
115114
fmt.Sprintf(
116-
"Skipping CSI handler, for provider given in %q. Provider handler not given ",
117-
provider,
115+
"Skipping CSI handler, for provider given in %s. Provider handler not given.",
116+
provider.Name,
118117
),
119118
)
120119
continue
121120
}
122-
log.Info(fmt.Sprintf("Creating csi provider %s", provider))
121+
log.Info(fmt.Sprintf("Creating csi provider %s", provider.Name))
123122
err = handler.Apply(
124123
ctx,
125124
provider,

pkg/handlers/generic/lifecycle/csi/nutanix-csi/handler.go

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ import (
2424
)
2525

2626
const (
27-
defaultHelmRepositoryURL = "https://nutanix.github.io/helm/"
28-
defaultHelmChartVersion = "v2.6.6"
29-
defaultHelmChartName = "nutanix-csi-storage"
30-
defaultHelmReleaseNameTemplate = "nutanix-csi-storage-%s"
27+
defaultHelmRepositoryURL = "https://nutanix.github.io/helm/"
28+
defaultStorageHelmChartVersion = "v2.6.6"
29+
defaultStorageHelmChartName = "nutanix-csi-storage"
30+
defaultStorageHelmReleaseNameTemplate = "nutanix-csi-storage-%s"
31+
32+
defaultSnapshotHelmChartVersion = "v6.3.2"
33+
defaultSnapshotHelmChartName = "nutanix-csi-snapshot"
34+
defaultSnapshotHelmReleaseNameTemplate = "nutanix-csi-snapshot-%s"
3135
)
3236

3337
type NutanixCSIConfig struct {
@@ -141,13 +145,13 @@ func (n *NutanixCSI) handleHelmAddonApply(
141145
},
142146
Spec: caaphv1.HelmChartProxySpec{
143147
RepoURL: defaultHelmRepositoryURL,
144-
ChartName: defaultHelmChartName,
148+
ChartName: defaultStorageHelmChartName,
145149
ClusterSelector: metav1.LabelSelector{
146150
MatchLabels: map[string]string{clusterv1.ClusterNameLabel: req.Cluster.Name},
147151
},
148152
ReleaseNamespace: req.Cluster.Namespace,
149-
ReleaseName: fmt.Sprintf(defaultHelmReleaseNameTemplate, req.Cluster.Name),
150-
Version: defaultHelmChartVersion,
153+
ReleaseName: fmt.Sprintf(defaultStorageHelmReleaseNameTemplate, req.Cluster.Name),
154+
Version: defaultStorageHelmChartVersion,
151155
ValuesTemplate: values,
152156
},
153157
}
@@ -163,6 +167,41 @@ func (n *NutanixCSI) handleHelmAddonApply(
163167
return fmt.Errorf("failed to apply nutanix-csi installation HelmChartProxy: %w", err)
164168
}
165169

170+
snapshotChart := &caaphv1.HelmChartProxy{
171+
TypeMeta: metav1.TypeMeta{
172+
APIVersion: caaphv1.GroupVersion.String(),
173+
Kind: "HelmChartProxy",
174+
},
175+
ObjectMeta: metav1.ObjectMeta{
176+
Namespace: req.Cluster.Namespace,
177+
Name: "nutanix-csi-snapshot" + req.Cluster.Name,
178+
},
179+
Spec: caaphv1.HelmChartProxySpec{
180+
RepoURL: defaultHelmRepositoryURL,
181+
ChartName: defaultSnapshotHelmChartName,
182+
ClusterSelector: metav1.LabelSelector{
183+
MatchLabels: map[string]string{clusterv1.ClusterNameLabel: req.Cluster.Name},
184+
},
185+
ReleaseNamespace: req.Cluster.Namespace,
186+
ReleaseName: fmt.Sprintf(defaultStorageHelmReleaseNameTemplate, req.Cluster.Name),
187+
Version: defaultSnapshotHelmChartVersion,
188+
},
189+
}
190+
191+
if err = controllerutil.SetOwnerReference(&req.Cluster, snapshotChart, n.client.Scheme()); err != nil {
192+
return fmt.Errorf(
193+
"failed to set owner reference on nutanix-csi installation HelmChartProxy: %w",
194+
err,
195+
)
196+
}
197+
198+
if err = client.ServerSideApply(ctx, n.client, snapshotChart); err != nil {
199+
return fmt.Errorf(
200+
"failed to apply nutanix-csi-snapshot installation HelmChartProxy: %w",
201+
err,
202+
)
203+
}
204+
166205
return nil
167206
}
168207

0 commit comments

Comments
 (0)