I have been trying to watch some resources in my K8s cluster and after reading some blogs about watch vs informers, i've decided to go with Informers.
I came across this example of how to use one: https://github.com/Netflix-Skunkworks/kubernetes-client-java/blob/master/examples/src/main/java/io/kubernetes/client/examples/InformerExample.java
In the example, I see that the SharedIndexInformer is defined as such:
factory.sharedIndexInformerFor(
(CallGeneratorParams params) -> {
return coreV1Api.listNodeCall(
null,
null,
null,
null,
null,
params.resourceVersion,
params.timeoutSeconds,
params.watch,
null,
null);
},
V1Node.class,
V1NodeList.class);
Based on my understanding of how lambdas are written, this basically says that we're creating a sharedIndexInformer
from the factory by passing it a param Call (returned by coreV1Api.listNodeCall).
The Call object is created by this dynamic method which takes in a CallGeneratorParams
argument.
I do not seem to understand how and where this argument is passed in from in the case of a SharedInformerFactory. It's very evident that some fields within the params
variable is being used in building the listNodeCall
but where and how is this object constructed ?