有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java轮询Pod的就绪状态

我正在使用fabric8 java库在Kubernetes集群上部署应用程序

我想调查豆荚的状态,知道它们什么时候准备好了。我开始写我自己的,直到我读到了《守望者》的故事

我实现了类似的东西

deployment =
          kubeClient.extensions().deployments().inNamespace(namespaceName).create(deployment);
      kubeClient.pods().inNamespace(namespaceName).watch(new Watcher<Pod>() {
        @Override
        public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action,
            Pod resource) {
          logger.info("Pod event {} {}", action, resource);
          logger.info("Pod status {} , Reason {} ", resource.getStatus().getPhase(),
              resource.getStatus().getReason());
        }

        @Override
        // What causes the watcher to close?
        public void onClose(KubernetesClientException cause) {
          if (cause != null) {
            // throw?
            logger.error("Pod event {} ", cause);
          }
        }

      });

我不确定我是否正确理解了Watcher的功能。超时了吗?还是我仍然在eventReceivedMethod()中编写我的轮询器?观察者的用例是什么


共 (0) 个答案