2018-01-08 10:38:03 +01:00
|
|
|
#!/bin/bash
|
2018-08-28 16:37:59 +02:00
|
|
|
set -ex
|
2018-01-08 10:38:03 +01:00
|
|
|
name=toolbox-${USER}
|
|
|
|
image='dlneintr/toolbox:latest'
|
|
|
|
labels="app=toolbox,owner=${USER},cookie=0xdeadbeef"
|
|
|
|
|
|
|
|
existing=$(kubectl get pod -l ${labels} --output='jsonpath={.items..metadata.name}')
|
|
|
|
|
|
|
|
if [ "${existing}" == "" ]; then
|
|
|
|
kubectl run --image=${image} --image-pull-policy=Always --labels=${labels} ${name}
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in {1..10}; do
|
|
|
|
ready=$(kubectl get pod --field-selector=status.phase=Running -l ${labels} --output='jsonpath={.items..metadata.name}')
|
|
|
|
if [ "${ready}" != "" ]; then
|
|
|
|
exec kubectl exec -it ${ready} /bin/sh
|
|
|
|
fi
|
|
|
|
echo "Waiting for pod to be ready"
|
|
|
|
sleep 1
|
|
|
|
done
|