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

Add support for noobaa on client clusters #176

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
nbapis "github.com/noobaa/noobaa-operator/v5/pkg/apis"
configv1 "github.com/openshift/api/config/v1"
consolev1 "github.com/openshift/api/console/v1"
quotav1 "github.com/openshift/api/quota/v1"
Expand Down Expand Up @@ -73,6 +74,7 @@ func init() {
utilruntime.Must(extv1.AddToScheme(scheme))
utilruntime.Must(quotav1.AddToScheme(scheme))
utilruntime.Must(csiopv1a1.AddToScheme(scheme))
utilruntime.Must(nbapis.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ rules:
- list
- update
- watch
- apiGroups:
- noobaa.io
resources:
- noobaas
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ocs.openshift.io
resources:
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ require (
sigs.k8s.io/controller-runtime v0.18.4
)

require (
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
sigs.k8s.io/container-object-storage-interface-api v0.1.0 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
Expand Down Expand Up @@ -62,6 +68,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/noobaa/noobaa-operator/v5 v5.15.4
github.com/nxadm/tail v1.4.8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
Expand Down
550 changes: 550 additions & 0 deletions go.sum

Large diffs are not rendered by default.

51 changes: 49 additions & 2 deletions internal/controller/storageclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/red-hat-storage/ocs-client-operator/pkg/utils"

csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
configv1 "github.com/openshift/api/config/v1"
opv1a1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
providerClient "github.com/red-hat-storage/ocs-operator/v4/services/provider/client"
Expand Down Expand Up @@ -99,7 +100,9 @@ func (r *StorageClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&v1alpha1.StorageClient{}).
Owns(&v1alpha1.StorageClaim{}).
Owns(&batchv1.CronJob{}).
Owns(&quotav1.ClusterResourceQuota{}, builder.WithPredicates(generationChangePredicate))
Owns(&quotav1.ClusterResourceQuota{}, builder.WithPredicates(generationChangePredicate)).
Owns(&nbv1.NooBaa{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Owns(&corev1.Secret{})

if utils.DelegateCSI {
bldr = bldr.Owns(&csiopv1a1.CephConnection{}, builder.WithPredicates(generationChangePredicate))
Expand All @@ -116,6 +119,8 @@ func (r *StorageClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
//+kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;create;update;watch;delete
//+kubebuilder:rbac:groups=operators.coreos.com,resources=clusterserviceversions,verbs=get;list;watch
//+kubebuilder:rbac:groups=csi.ceph.io,resources=cephconnections,verbs=get;list;update;create;watch;delete
//+kubebuilder:rbac:groups=noobaa.io,resources=noobaas,verbs=get;list;watch;create;update;delete
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;delete

func (r *StorageClientReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
var err error
Expand Down Expand Up @@ -235,9 +240,51 @@ func (r *StorageClientReconciler) reconcilePhases() (ctrl.Result, error) {
return reconcile.Result{}, fmt.Errorf("failed to reconcile cephConnection: %v", err)
}
}
case "Secret":
data := map[string][]byte{}
if err := json.Unmarshal(eResource.Data, &data); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshall secret: %v", err)
}
secret := &corev1.Secret{}
secret.Name = eResource.Name
secret.Namespace = r.storageClient.Namespace
_, err := controllerutil.CreateOrUpdate(r.ctx, r.Client, secret, func() error {
if err := r.own(secret); err != nil {
return err
}
secret.Data = data
return nil
})
if err != nil {
return reconcile.Result{}, fmt.Errorf(
"failed to create or update secret %v: %v",
client.ObjectKeyFromObject(secret),
err,
)
}
case "Noobaa":
noobaaSpec := &nbv1.NooBaaSpec{}
if err := json.Unmarshal(eResource.Data, &noobaaSpec); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshall noobaa spec data: %v", err)
}
nb := &nbv1.NooBaa{}
nb.Name = eResource.Name
nb.Namespace = r.storageClient.Namespace

_, err = controllerutil.CreateOrUpdate(r.ctx, r.Client, nb, func() error {
if err := r.own(nb); err != nil {
return err
}
utils.AddAnnotation(nb, "remote-client-noobaa", "true")
noobaaSpec.JoinSecret.Namespace = r.storageClient.Namespace
nb.Spec = *noobaaSpec
return nil
})
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to create remote noobaa: %v", err)
}
}
}

if r.storageClient.GetAnnotations()[storageClaimProcessedAnnotationKey] != "true" {
if err := r.reconcileBlockStorageClaim(); err != nil {
return reconcile.Result{}, err
Expand Down
201 changes: 201 additions & 0 deletions vendor/github.com/kube-object-storage/lib-bucket-provisioner/LICENSE

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

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

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

Loading
Loading