How to set up a watcher on a CR? #1727
Replies: 3 comments 4 replies
-
Not completely sure I understand the issue, but generally you create one The crd_reflector example should do basically what you want for CR watches in https://github.com/kube-rs/kube/blob/main/examples/crd_reflector.rs (just ignore the reflect/reflector calls and its spawned tokio::task). |
Beta Was this translation helpful? Give feedback.
-
I have written a CRD.yaml and loaded it into my cluster, but not in rust.
But, when I try to compile it, rustc complains:
Which kind of makes sense. But, k8s API knows about that CRD. So, how do I make rustc aware of that new Kind? I feel like I'm missing something, and it's probably a mix of lack of rust and lack of k8s knowledge. I checked the example of the reflector, but I don't see what I'm missing. The only that code does is the same I've done with "kubectl apply -f crd.yaml" is it not? |
Beta Was this translation helpful? Give feedback.
-
Right, if the type is not defined in the kube::api namespace, I need to provide a struct for it. But if I have a struct defined, like this:
Then I should be able to create a client on that type, in this case 'Foo'?
Because that derive macro is creating the type for me, is it not? Am I missing something about how the types work with that macro? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using:
I can create a client connection, and using that tell my watcher what kind of api objects I care about. Now, if I have created a CRD and loaded it in my cluster, Pods are not all I could be interested in watching for, right?
So, If I have a Book CR created in my cluster, how do I write the code above?
doesn't work. I'm missing a step, am I not? Documentation, explanations and examples welcome.
Beta Was this translation helpful? Give feedback.
All reactions