Independent Tech & Cryptocurrency News
Bitcoin
$3,930.84
-50.29
(-1.26%)
Ethereum
$145.28
-3.7
(-2.48%)
Ripple
$0.32
Litecoin
$48.77
-3.31
(-6.36%)
EOS
$3.79
-0.16
(-4.05%)
Cardano
$0.04
-0
(-4.61%)
Stellar
$0.09
-0
(-2.14%)
NEO
$8.78
-0.54
(-5.79%)
NEM
$0.04
0
(+0.3%)
DigitalCash
$84.02
-4.03
(-4.58%)
Tether
$0.99
-0
(-0.12%)
Binance Coin
$10.92
-0.78
(-6.67%)
QTUM
$2.05
-0.07
(-3.3%)
Verge
$0.01
0
(+0.67%)
Ontology
$0.71
-0.16
(-17.69%)
ZCash
$53.97
-1.91
(-3.42%)
Steem
$0.34

wait like a boss – Hacker Noon

3


Meet the kubectl wait command and see it in action here.

First, let’s create a job called worker that does something utterly useless in itself (print the word blah to stdout and pause for 3 seconds ten times):

$ kubectl version --short
Client Version: v1.12.0
Server Version: v1.11.0
$ kubectl create ns waitplayground
$ kubectl -n waitplayground 
create job worker
--image centos:7 --
sh -c
'for i in {1..10} ; do echo blah ; sleep 3; done'

You could keep an eye on the resources with:

$ kubectl -n waitplayground get job,po

But what if you’d like to kick off another job after worker has completed? Here you go:

$ kubectl -n waitplayground 
wait --for=condition=complete --timeout=32s
job/worker
job.batch/worker condition met

Note that above I’ve set the timeout (32 sec) slightly higher than what I’d expect the worker job to take (ca. 10 * 3 sec). Once the kubectl wait command returns, you just need to inspect its output and you can then make a decision based on this to, for example, launch a dependent job or retry the original one.



coindesk.com

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.