question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use SharedIndexInformer with CustomResource

See original GitHub issue

Hello,

I wrote the watching for CustomResource. At first, I used Watcher, but I got the error “Kubernetes too old resource version”. Then, I referred this thread https://stackoverflow.com/questions/61409596/kubernetes-too-old-resource-version to use SharedIndexInformer, but the method sharedIndexInformerForCustomResource() is deprecated in openshift-client 5.9.0. Can anyone show me an example to watching CustomResource event?

SharedInformerFactory sharedInformerFactory = openShiftClient.informers();
SharedIndexInformer<GenericKubernetesResource> podInformer = sharedInformerFactory.sharedIndexInformerForCustomResource(context, 30 * 1000L);
...

Thanks,

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
shawkinscommented, Nov 12, 2021

it doesn’t look like he is using any POJO for his custom resource

Sorry, I should have included:

client.genericKubernetesResources(context)…inform

Why was this method marked Deprecated?

We don’t want to expose the OperationContext for direct usage. It also gets confusing in terms of keeping track of existing informers.

0reactions
nautiamcommented, Nov 12, 2021

I used SharedInformer in order to update events happening to my resource after a certain interval of time. But it always get the status of all resources, I just want to see the status of changed resources since the last time. For example, if a resource is deleted or added, it will be shown, but if it unchanged in the interval, it will be skipped. Is there anyway to do it?

The answer is set resync to 0L. Thanks @rohanKanojia for your help.

kubernetesClient.genericKubernetesResources(context).inNamespace("default").inform(new ResourceEventHandler<GenericKubernetesResource>() {
                @Override
                public void onAdd(GenericKubernetesResource genericKubernetesResource) {

                }

                @Override
                public void onUpdate(GenericKubernetesResource genericKubernetesResource, GenericKubernetesResource t1) {

                }

                @Override
                public void onDelete(GenericKubernetesResource genericKubernetesResource, boolean b) {

                }
            }, 0);
Read more comments on GitHub >

github_iconTop Results From Across the Web

SharedIndexInformer for Custom resource stuck in "Start ...
This is a static function which has been written by me. The Virtual Machine Class has been autogenerated using the instructions from the...
Read more >
java - SharedIndexInformer for Custom resource stuck in "Start ...
I am trying to create a SharedIndexInformer for a Kubevirt Virtual Machine Instance (custom resource ...
Read more >
SharedInformerFactory (Fabric8 :: Kubernetes - javadoc.io
Constructs and returns a shared index informer with resync period specified for custom resources. <T extends CustomResource<?,?>,L extends io.fabric8.kubernetes ...
Read more >
How to Create a Kubernetes Custom Controller Using client-go
One happens in SharedIndexInformer , the other one is in custom controller. 1. Reflector performs object (such as namespace, pod etc) ...
Read more >
Introduction to Fabric8 Kubernetes Java Client Informer API
SharedIndexInformer <Job> jobInformer = client.batch().v1().jobs() ... In case you want to use Informer API for some CustomResource , you can do it in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found