Search in sources :

Example 56 with Watch

use of io.fabric8.kubernetes.client.Watch in project fabric8 by jboss-fuse.

the class KubernetesConfigAdminBridge method watchConfigMapList.

private void watchConfigMapList() {
    if (configWatch) {
        KubernetesClient client = kubernetesClient.get();
        if (client != null) {
            FilterWatchListDeletable<ConfigMap, ConfigMapList, Boolean, Watch, Watcher<ConfigMap>> configMapsSelector = client.configMaps().withLabel(pidLabel);
            for (String key : filters.keySet()) {
                configMapsSelector.withLabelIn(key, filters.get(key).toArray(new String[filters.get(key).size()]));
            }
            watch = configMapsSelector.watch(this);
        } else {
            throw new RuntimeException("KubernetesClient not set");
        }
    }
}
Also used : ConfigMapList(io.fabric8.kubernetes.api.model.ConfigMapList) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Watch(io.fabric8.kubernetes.client.Watch) Watcher(io.fabric8.kubernetes.client.Watcher)

Example 57 with Watch

use of io.fabric8.kubernetes.client.Watch in project fabric8 by jboss-fuse.

the class WatchServicesExample method main.

public static void main(String... args) throws Exception {
    KubernetesClient client = new DefaultKubernetesClient();
    client.services().watch(new io.fabric8.kubernetes.client.Watcher<Service>() {

        @Override
        public void eventReceived(Action action, Service service) {
            System.out.println(action + ": " + service);
        }

        @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) Service(io.fabric8.kubernetes.api.model.Service) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

Watch (io.fabric8.kubernetes.client.Watch)19 Pod (io.fabric8.kubernetes.api.model.Pod)16 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)16 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)13 Watcher (io.fabric8.kubernetes.client.Watcher)11 Test (org.junit.Test)10 PodList (io.fabric8.kubernetes.api.model.PodList)9 IOException (java.io.IOException)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)7 KubernetesMockServer (io.fabric8.kubernetes.client.server.mock.KubernetesMockServer)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 WatchEvent (io.fabric8.kubernetes.api.model.WatchEvent)5 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)5 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 PodListBuilder (io.fabric8.kubernetes.api.model.PodListBuilder)4 Service (io.fabric8.kubernetes.api.model.Service)4