-
Hi, I'm trying to watch deleting Endpointslice resources. let endpointslices = Api::<EndpointSlice>::all(client);
tracing::info!(name=eps.name_any(),obj=?eps,"Reconcile Endpointslice");
finalizer(
&endpointslices,
ENDPOINTSLICE_FINALIZER,
eps,
|event| async {
match event {
Event::Apply(eps) => reconcile(&eps, ctx.clone()).await,
Event::Cleanup(eps) => cleanup(&eps, ctx.clone()).await,
}
},
)
.await
.unwrap(); I tried to get deleting resources with the finalizer function.
I'm not sure a way to watch resources with the event type, such as applying, updating, and deleting. How can I watch and get events and resources? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey. The I think your error is passing an |
Beta Was this translation helpful? Give feedback.
Hey. The
finalizer
fn is to help abstract the management of Kubernetes finalizers, not to give precise watch events.There are some docs on https://kube.rs/controllers/gc/#finalizers which talks about the
secret_syncer
example.I think your error is passing an
Api:all
tofinalizer
, but you have a namespaced resource. TheApi::all
can only be used to view events across namespaces, not to patch namespaced resources (see #1030). Note howsecret_syncer
is creating anApi::namespaced
for the namespace of the object.