--
You received this message because you are subscribed to the Google Groups "Operator Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to operator-framew...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/1053fa53-9897-4b30-a6cf-110caea7bb02n%40googlegroups.com.
I see! Yes I think that is what I am looking for.I was hoping that was (somehow) handled automatically by the system, but appears not so.That's ok, as long as there is a way to handle it. Of course, now I'm not entirely sure what that manager setup configuration is for, but maybe that's another research project. Still new to the operator system.
Michael Hrivnak
Senior Principal Software Engineer, RHCERed Hat
Makes a lot of sense.In doing some testing, I am actually not seeing this at all though.As a simple example:I have a resource the operator manages called DockerLogin - when that is created, it creates an accompanying k8s secret with docker credentials in it.If I update the DockerLogin resource, the reconciler kicks in. However, if I update or delete the Secret, nothing happens. It's also not attaching the owner references to it (I updated the code to make the call to SetControllerReference)err = ctrl.SetControllerReference(dl, secret, r.Scheme)if err != nil {logger.Error(err, "unable to set controller reference on create")}I should note: The operator is in a completely separate namespace than the resources it is managing. Both the DockerLogin and its accompanying Secret are in the same namespace (Namespace B) while the operator is in Namespace A.// SetupWithManager sets up the controller with the Manager.func (r *DockerLoginReconciler) SetupWithManager(mgr ctrl.Manager) error {return ctrl.NewControllerManagedBy(mgr).For(&entitiesv1alpha1.DockerLogin{}).Owns(&corev1.Secret{}).Owns(&corev1.ServiceAccount{}).Complete(r)}
// Set the ownerRef for the Deployment // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/ if err := ctrl.SetControllerReference(busybox, dep, r.Scheme); err != nil { return nil, err }
Example:
func (r *EnvironmentReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&entitiesv1alpha1.Environment{}).
Owns(&corev1.Namespace{}).
Owns(&istionetworkingv1beta1.Gateway{}).
Owns(&istiosecurityv1beta1.PeerAuthentication{}).
Owns(&istiosecurityv1beta1.AuthorizationPolicy{}).
Owns(&certmgrv1.Certificate{}).
Complete(r)
}
Example: For(&cachev1alpha1.Memcached{}).>> You will find it in the SDK tutorial. It will ensure that the manager will watch the changes in resources of this Kind. That means when we create a CR for the Memcached KIND it will trigger the reconciliation and we will be able to ensure that we have a Deployment on the cluster to run the Operand image
Example: Owns(&appsv1.Deployment{}).>> You will find it in the SDK tutorial. It will ensure that the manager will watch the changes in the Deployments resources which have the ownerRef ( which is owned/created by ). For example, if you change the number of replicas the reconciliation will be re-trigged. For the tutorial example, we ensure that the number of replicas is the same as what is specified in the CR via the spec size.
See the tutorial: https://sdk.operatorframework.io/docs/building-operators/golang/
--
You received this message because you are subscribed to the Google Groups "Operator Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to operator-framew...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/f50fee52-98f6-49e2-9b8a-046e2a2c6710n%40googlegroups.com.
Appreciate the detailed response Camila!
Does this work for resources that exist across namespaces as well?
For instance the CRD is placed in Namespace A, but it owns a resource that is in Namespace B?
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/de044f05-3217-4a69-b7da-18a8ff7d9267n%40googlegroups.com.
On Jul 28, 2022, at 5:56 AM, Camila Macedo <cma...@redhat.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/CACQ0tdAh%2BQGWs9Fx5Cr%2B%2B%3DiU39x5NS5efQDy-cpTTMHt_ZYzwQ%40mail.gmail.com.
Does this work for resources that exist across namespaces as well?For instance the CRD is placed in Namespace A, but it owns a resource that is in Namespace B?
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/A746B781-DCE8-44E3-90BB-B67A7CA05670%40redhat.com.