dotfiles/home/.bin/kube-trigger-cronjob
Marcus Noble 381adefe87
Make things pretty
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
2022-03-11 18:38:32 +00:00

41 lines
810 B
Bash
Executable File

#!/usr/bin/env bash
source .utils
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
set -e
NAMESPACE=${NAMESPACE:-default}
print_usage() {
blue "kube-trigger-cronjob - Triggers a CronJob by creating a new job based on it"
echo " "
underline "Usage:"
echo "kube-trigger-cronjob [options] CRONJOB_NAME"
echo " "
underline "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the to search in"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
NAME=${1}
kubectl create job --namespace ${NAMESPACE} ${NAME}-manual --from=cronjob/${NAME} ${@:3}