2016-07-14 14:56:43 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-05-08 11:31:55 +00:00
|
|
|
this=`basename $0`
|
2019-05-28 14:13:52 +00:00
|
|
|
if [ $# -gt 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
2019-05-14 17:53:57 +00:00
|
|
|
echo Usage: $this [IMAGE[:TAG]]
|
2019-05-08 11:31:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-28 14:13:52 +00:00
|
|
|
IMAGE=$1
|
|
|
|
if [ -n "$IMAGE" ]; then
|
|
|
|
if [ ! -f nfd-worker-job.yaml ]; then
|
|
|
|
make IMAGE_TAG=$IMAGE nfd-worker-job.yaml
|
|
|
|
else
|
|
|
|
# Keep existing nfd-worker-job.yaml, only update image.
|
|
|
|
sed -E "s,^(\s*)image:.+$,\1image: $IMAGE," -i nfd-worker-job.yaml
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f nfd-worker-job.yaml ]; then
|
|
|
|
# Missing image info for the labeling job.
|
|
|
|
echo "nfd-worker-job.yaml missing."
|
|
|
|
echo "Run 'make nfd-worker-job.yaml', use the template or provide IMAGE (see --help)."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2018-02-23 10:53:22 +00:00
|
|
|
# Get the number of nodes in Ready state in the Kubernetes cluster
|
2018-07-26 12:20:57 +00:00
|
|
|
NumNodes=$(kubectl get nodes | grep -i ' ready ' | wc -l)
|
2016-07-12 00:30:49 +00:00
|
|
|
|
2016-07-14 14:56:43 +00:00
|
|
|
# We set the .spec.completions and .spec.parallelism to the node count
|
2019-05-28 14:13:52 +00:00
|
|
|
# We set the NODE_NAME environment variable to get the Kubernetes node object.
|
|
|
|
sed -e "s/completions:.*$/completions: $NumNodes/" \
|
|
|
|
-e "s/parallelism:.*$/parallelism: $NumNodes/" \
|
|
|
|
-i nfd-worker-job.yaml
|
2019-05-14 17:53:57 +00:00
|
|
|
|
2019-05-08 11:31:55 +00:00
|
|
|
kubectl create -f nfd-worker-job.yaml
|