86414

In a Watcher in the fabric8 Kubernetes client events() API, what resources can I watch?

Question:

I am exploring the <a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java#L104" rel="nofollow">(undocumented?) events() API</a> in <a href="https://github.com/fabric8io/kubernetes-client" rel="nofollow">Fabric8's Kubernetes client project</a>.

Specifically, I see that I can do something like the following:

client.events().inAnyNamespace().watch(new Watcher<Something>() { @Override public final void eventReceived(final Action action, final Something something) { } @Override public final void onClose(final KubernetesClientException kubernetesClientException) { if (kubernetesClientException != null) { // log? throw? } } });

What are the permitted values of something and Something for something useful to happen? I'm assuming they are <em>supposed</em> to be things like Pods, Services, etc. but I'm not sure.

<a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Watcher.java#L20" rel="nofollow">Watcher's sole type parameter is declared as <T></a>, so it would appear I could create a new Watcher<Integer>, but I'm willing to bet money that will never be called. This suggests that there is actually a bound in practice on <T>, but I don't know what it is, or why it would have been omitted if so.

If I had to guess, I'd guess from the parameter name, resource, that it would be something like T extends<a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java" rel="nofollow">Resource</a><?, ?> but again, that's only a guess.

Thanks for any pointers, particularly to other documentation I'm sure I've missed.

<strong>Update #1</strong>: From banging around in the source code, I can see that the only place that a Watcher.Action's eventReceived() method is called <a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java#L207-L217" rel="nofollow">forces the payload to be considered to be a HasMetadata object</a>. Maybe that's my answer?

Answer1:

You can watch a particular pod or particular job for example. The T type in that case is Pod or Job respectively. Try

kube.extensions().jobs().createNew()...done().watch(new Watcher<Job>(){...})

Recommend

  • Handle Form Failure when uploading to Appengine Blobstore
  • Is it possible to access raw iphone audio output?
  • MongoDB Compass Visually Insert Sub-Document
  • NoMethodError in Controller#action - undefined method `keynote' for #
  • Display forms choice in template-Django
  • How to make the tableview response pan gesture in ZUUIRevealController
  • Receive custom intent without activity restart
  • Contact form problem - I do receive messages, but no contents (blank page)
  • How to handle Back Button to remove current fragment In MvvmCross
  • Converting datatype Char to Nvarchar
  • QueryString id parameter not being used
  • Set the default timezone in symfony
  • How to integrate Paytm with Codeigniter
  • calling a fragment from fragment
  • Regex for URL rewrite with optional query string parameters
  • What is this error in fortran and how to stop the program when it occurs?
  • Ionic storage “get” returns null only on the second call within method
  • Action Pack components in Rails
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • redirect_to root_url and return unless @user.activated
  • Getting the scrolling offset when storing coordinates
  • Cloud Code function running twice
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • NUnit 3.0 TestCase const custom object arguments
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • Thread safety of a fluent like class using clone() and non final fields
  • Converting a WriteableBitmap image ToArray in UWP
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Perl system calls when running as another user using sudo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • what is the difference between the asp.net mvc application and asp.net web application
  • Upload files with Ajax and Jquery
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • LevelDB C iterator
  • How can i traverse a binary tree from right to left in java?