use of io.kubernetes.client.openapi.models.V1PodStatus in project pravega by pravega.
the class K8sClient method getStatusOfPod.
/**
* Method used to fetch the status of a Pod. V1PodStatus also helps to indicate the container status.
* @param namespace Namespace.
* @param podName Name of the pod.
* @return A future representing the status of the pod.
*/
@SneakyThrows(ApiException.class)
public CompletableFuture<V1PodStatus> getStatusOfPod(final String namespace, final String podName) {
CoreV1Api api = new CoreV1Api();
K8AsyncCallback<V1PodList> callback = new K8AsyncCallback<>("listPods");
api.listNamespacedPodAsync(namespace, PRETTY_PRINT, ALLOW_WATCH_BOOKMARKS, null, null, "POD_NAME=" + podName, null, null, null, false, callback);
return callback.getFuture().thenApply(v1PodList -> {
Optional<V1Pod> vpod = v1PodList.getItems().stream().filter(v1Pod -> v1Pod.getMetadata().getName().equals(podName) && v1Pod.getMetadata().getNamespace().equals(namespace)).findFirst();
return vpod.map(V1Pod::getStatus).orElseThrow(() -> new RuntimeException("pod not found" + podName));
});
}
Aggregations