在一个观察者的fabric8 Kubernetes客户端事件()API中,我可以看什么资源? [英] In a Watcher in the fabric8 Kubernetes client events() API, what resources can I watch?

查看:199
本文介绍了在一个观察者的fabric8 Kubernetes客户端事件()API中,我可以看什么资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在探索(未记录?) events() API fabric8的kbernetes客户端rel =nofollow noreferrer> Fabric8的Kubernetes客户端项目。



具体来说,我看到我可以执行以下操作:

  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?
}
}
});

某些的允许值是某些有用的东西我假设他们是应该像Pods,Services等等,但我不确定。



Watcher 的唯一类型参数被声明为< T> ,所以看起来我可以创建一个新的 Watcher< Integer> ,但我愿意投注永远不会被打的钱。这表明实际上在< T> 中实际上有一个约束,但是我不知道是什么,或者为什么会这样被省略。 / p>

如果我不得不猜测,我可以从参数名称 resource 中猜出, T extends 资源 <?,?> ,但再次,这只是一个猜测。



感谢任何指针,特别是其他文档我确信我错过了。 p>

更新#1 :从源代码中跳出来,我可以看到唯一的一个 Watcher.Action eventReceived()方法称为强制有效载荷被认为是一个 HasMetadata 对象。也许这是我的答案?

解决方案

您可以观看特定的pod或特定作业。在这种情况下,T型分别是Pod或Job。尝试

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


I am exploring the (undocumented?) events() API in Fabric8's Kubernetes client project.

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 supposed to be things like Pods, Services, etc. but I'm not sure.

Watcher's sole type parameter is declared as <T>, 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 extendsResource<?, ?> but again, that's only a guess.

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

Update #1: From banging around in the source code, I can see that the only place that a Watcher.Action's eventReceived() method is called forces the payload to be considered to be a HasMetadata object. Maybe that's my answer?

解决方案

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>(){...})

这篇关于在一个观察者的fabric8 Kubernetes客户端事件()API中,我可以看什么资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆