Search in sources :

Example 36 with Watch

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;
}
Also used : Watch(io.fabric8.kubernetes.client.Watch) PodWatcher(io.fabric8.kubernetes.assertions.support.PodWatcher)

Example 37 with Watch

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();
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)13 Watch (io.fabric8.kubernetes.client.Watch)12 Pod (io.fabric8.kubernetes.api.model.Pod)10 Watcher (io.fabric8.kubernetes.client.Watcher)10 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)8 PodList (io.fabric8.kubernetes.api.model.PodList)7 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)4 Logger (io.fabric8.maven.docker.util.Logger)4 IOException (java.io.IOException)4 DoneablePod (io.fabric8.kubernetes.api.model.DoneablePod)3 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)3 Build (io.fabric8.openshift.api.model.Build)3 Map (java.util.Map)3 ConfigMapList (io.fabric8.kubernetes.api.model.ConfigMapList)2