Skip to content

Commit

Permalink
allow multiple instances of metastorageprovisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
denarsh committed Sep 2, 2024
1 parent 5bf2b0c commit 177d4f3
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 18 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/metastoragetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type MetaStorageProvisionerStatus string
// MetaStorageProvisioner represents the storage provisioner to be installed
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`

type MetaStorageProvisioner struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion charts/metastorageprovisioner/templates/dep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
containers:
- name: metastorageprovisioner
imagePullPolicy: Always
image: "{{.Values.imageHub}}/cnvrg-operator:5.1.20"
image: "{{.Values.imageHub}}/cnvrg-operator:5.1.22"
command:
- /opt/app-root/cnvrg-metastorageprovisioner
- start
Expand Down
8 changes: 5 additions & 3 deletions charts/mlops/crds/mlops.cnvrg.io_metastorageprovisioners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ spec:
singular: metastorageprovisioner
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .status.status
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: MetaStorageProvisioner represents the storage provisioner to
be installed
properties:
apiVersion:
description: |-
Expand Down
8 changes: 5 additions & 3 deletions config/crd/bases/mlops.cnvrg.io_metastorageprovisioners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ spec:
singular: metastorageprovisioner
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .status.status
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: MetaStorageProvisioner represents the storage provisioner to
be installed
properties:
apiVersion:
description: |-
Expand Down
15 changes: 9 additions & 6 deletions controllers/metastorageprovider/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu

// readiness checker for NFS provisioner
checker = func() (bool, error) {
deployment := types.NamespacedName{Name: nfsProvisionerReleaseName, Namespace: r.Namespace}
deployment := types.NamespacedName{Name: provisionerObject.Name, Namespace: r.Namespace}
return CheckDeploymentReadiness(r.Client, deployment)
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
// if not ready, requeue
if !ready {
r.EventLogger.WithMessage("waiting for deployment readiness").WithStatus(v1alpha1.Pending).Log(ctx)
return ctrl.Result{RequeueAfter: 5}, nil
return ctrl.Result{RequeueAfter: 30}, nil
}

// provisioner is ready
Expand All @@ -138,7 +138,9 @@ func (r *Reconciler) nfsConfig(provisionerObject *v1alpha1.MetaStorageProvisione
"path": provisionerObject.Spec.NFSProvisioner.NFSPath,
}

chartConfig = r.ChartConfig(values)
values["fullnameOverride"] = provisionerObject.Name

chartConfig = r.NFSChartConfig(provisionerObject.Name, values)
return chartConfig
}

Expand All @@ -150,10 +152,11 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
Complete(r)
}

func (r *Reconciler) ChartConfig(values map[string]interface{}) installer.ChartConfig {
func (r *Reconciler) NFSChartConfig(name string, values map[string]interface{}) installer.ChartConfig {
return installer.ChartConfig{
Namespace: r.Namespace,
ReleaseName: nfsProvisionerReleaseName,
ReleaseName: name,
ChartName: nfsProvisionerReleaseName,
Url: fmt.Sprintf("https://kubernetes-sigs.github.io/%s", nfsProvisionerReleaseName),
Values: values,
Version: nfsProvisionerVersion,
Expand All @@ -178,7 +181,7 @@ func (r *Reconciler) ReconcileDelete(ctx context.Context, provisioner *v1alpha1.
logger := log.FromContext(ctx)
r.EventLogger.WithMessage("deleting meta storage provisioner").WithStatus(v1alpha1.Deleting).Log(ctx)

chartConfig := r.ChartConfig(nil)
chartConfig := r.NFSChartConfig(provisioner.Name, nil)
helm, err := installer.NewHelm(chartConfig, logger)
if err != nil {
return fmt.Errorf("error while creating helm installer: %w", err)
Expand Down
13 changes: 12 additions & 1 deletion pkg/app/controlplane/tmpl/conf/rbac/ccp-role.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,15 @@ rules:
- list
- patch
- update
- watch
- watch
- apiGroups:
- mlops.cnvrg.io
resources:
- metastorageprovisioners
verbs:
- get
- list
- watch
- create
- update
- delete
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ metadata:
mlops.cnvrg.io/default-loader: "true"
mlops.cnvrg.io/own: "false"
mlops.cnvrg.io/updatable: "true"
mlops.cnvrg.io/default-loader: "true"
mlops.cnvrg.io/own: "false"
mlops.cnvrg.io/updatable: "true"
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: cnvrgthirdparties.mlops.cnvrg.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ spec:
singular: metastorageprovisioner
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .status.status
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: MetaStorageProvisioner represents the storage provisioner to
be installed
properties:
apiVersion:
description: |-
Expand Down
3 changes: 2 additions & 1 deletion pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ChartConfig struct {
Namespace string
Pass string
ReleaseName string
ChartName string
Url string
User string
Values map[string]interface{}
Expand Down Expand Up @@ -99,7 +100,7 @@ func (h *Helm) configureRegistryClient() error {
func (h *Helm) loadChart(cpo *action.ChartPathOptions) (*chart.Chart, error) {
cpo.Version = h.chartConfig.Version
cpo.RepoURL = h.chartConfig.Url
cp, err := cpo.LocateChart(h.chartConfig.ReleaseName, h.envSettings)
cp, err := cpo.LocateChart(h.chartConfig.ChartName, h.envSettings)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 177d4f3

Please sign in to comment.