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

There should be the possibility to create Binding without ownerReference to Service. #254

Closed
arturobrzut opened this issue Jul 7, 2021 · 1 comment · Fixed by #256
Closed

Comments

@arturobrzut
Copy link
Member

There should be the possibility to create Binding without ownerReference to Service

we use the Crossplane to create IBM Cloud Operator CR like Service and Binding

Currently, Binding contains ownerReference to Service set by IBM Cloud Operator

In our case:
Crossplane create Binding CR and even if the Crossplane set they own OwnerReference to Binding CR,
the Binding CR will contain two OwnerReferences:

  • for Service CR
  • for Crossplabe CR.
    and if we removed Crossplane CR, Binding will not be removed because it contains ownerReference to Service.

The binding contains credentials for service login, requested by clients.
If one client requests a credential, cross-plane creates CR which creates Binding CR.
But for us, it is crucial to remove Binding CR if we removed Crossplane CR (it is like client remove)

We can do that if there will be the possibility to skip creation ownerReference in Binding CR by IBM Cloud Operator.
We can pass this information through Binding CR inside parameters

spec:
  parameters:
    - name: skipOwnerReferences
      value: 'true'
  secretName: my-secret
  serviceName: my-service

and we can read this parameter in the binding Reconciliation loop

	// Set an owner reference if service and binding are in the same namespace
	// and if there is not parameter skipOwnerReferences='true' inside Binding CR
	if serviceInstance.Namespace == instance.Namespace {
		parameters, err := r.getParams(ctx, instance)
		if err != nil {
			r.Log.Error(err, "Instance ", instance.ObjectMeta.Name, " has problems with its parameters")
			return ctrl.Result{}, err
		}
		if parameters["skipOwnerReferences"] != "true" {
			if err := r.SetControllerReference(serviceInstance, instance, r.Scheme); err != nil {
				logt.Info("Binding could not update controller reference", instance.Name, err.Error())
				return ctrl.Result{}, err
			}

			if err := r.Update(ctx, instance); err != nil {
				logt.Info("Error setting controller reference", instance.Name, err.Error())
				return ctrl.Result{}, nil
			}
		}
	}
@arturobrzut
Copy link
Member Author

I want to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant