use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class PodSelectionAssert method isPodReadyForPeriod.
/**
* Asserts that a pod is ready for this deployment all become ready within the given time and that each one keeps being ready for the given time
*/
public PodSelectionAssert isPodReadyForPeriod(long notReadyTimeoutMS, long readyPeriodMS) {
if (replicas.intValue() <= 0) {
LOG.warn("Not that the pod selection for: " + description + " has no replicas defined so we cannot assert there is a pod ready");
return this;
}
try (PodWatcher podWatcher = new PodWatcher(this, notReadyTimeoutMS, readyPeriodMS);
Watch watch = client.pods().withLabels(matchLabels).watch(podWatcher)) {
podWatcher.loadCurrentPods();
podWatcher.waitForPodReady();
}
return this;
}
use of io.fabric8.kubernetes.client.Watch in project fabric8 by fabric8io.
the class WatchPodsExample method main.
public static void main(String... args) throws Exception {
KubernetesClient client = new DefaultKubernetesClient();
client.pods().watch(new io.fabric8.kubernetes.client.Watcher<Pod>() {
@Override
public void eventReceived(Action action, Pod pod) {
System.out.println(action + ": " + pod);
}
@Override
public void onClose(KubernetesClientException e) {
System.out.println("Closed: " + e);
}
});
client.close();
}
Aggregations