-
Notifications
You must be signed in to change notification settings - Fork 1
/
WatchPods.java
32 lines (29 loc) · 1.19 KB
/
WatchPods.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package io.kubernetes;
import com.google.gson.reflect.TypeToken;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.util.Config;
import io.kubernetes.client.util.Watch;
import java.io.IOException;
public class WatchPods {
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
Watch<V1Pod> watch =
Watch.createWatch(
client,
api.listNamespacedPodCall("default", null, null, null, null, null, 5, null, null, 5, Boolean.TRUE, null),
new TypeToken<Watch.Response<V1Pod>>() {}.getType());
try {
for (Watch.Response<V1Pod> item : watch) {
System.out.printf("%s : %s%n", item.type, item.object.getMetadata().getName());
}
} finally {
watch.close();
}
}
}