private void waitUntilPodIsReady ( String podName , int nAwaitTimeout , final Logger log ) throws InterruptedException { final CountDownLatch readyLatch = new CountDownLatch ( 1 ) ; try ( Watch watch = client . pods ( ) . withName ( podName ) . watch ( new Watcher < Pod > ( ) { @ Override public void eventReceived ( Action action , Pod aPod ) { if ( KubernetesHelper . isPodReady ( aPod ) ) { readyLatch . countDown ( ) ; } } @ Override public void onClose ( KubernetesClientException e ) { // Ignore } } ) ) { readyLatch . await ( nAwaitTimeout , TimeUnit . SECONDS ) ; } catch ( KubernetesClientException | InterruptedException e ) { log . error ( "Could not watch pod" , e ) ; } }
A Simple utility function to watch over pod until it gets ready