Skip to content

Commit

Permalink
introduce support for deployment via kubectl apply of CronJob objec…
Browse files Browse the repository at this point in the history
…ts for files with the extension `.cronjob.yml\.
  • Loading branch information
emalloy committed Aug 21, 2017
1 parent 72432e3 commit 97f2d6c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ JOBS=()
# List of files ending in '.blockingjob.yml' in the kube directory
BLOCKING_JOBS=()
# List of files ending in '.cronjob.yml' in the kube directory
CRONJOBS=()
```

Expand Down
17 changes: 17 additions & 0 deletions bin/k8s-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ done
echo "Done deploying Jobs"
echo ""

echo "Deploying CronJobs"
for index in "${!CRONJOB_FILES[@]}"
do
CRONJOB=${CRONJOBS[$index]##*/}
CRONJOB_FILE=${CRONJOB_FILES[$index]}
if [ -n "$CI_SHA1" ]
then
echo "Updating image tag from latest to ${CI_SHA1} for ${CRONJOB_FILE}"
sed 's/:latest/':${CI_SHA1}'/g;' ${CRONJOB_FILE} > ${CRONJOB_FILE}-${CI_SHA1}
echo "Updating ${CRONJOB_FILE}-${CI_SHA1}"
CRONJOB_FILE=${CRONJOB_FILE}-${CI_SHA1}
fi
kubectl apply -f ${CRONJOB_FILE} --namespace=$NAMESPACE --record
done
echo "Done deploying CronJobs"
echo ""

echo "Deploying Blocking Jobs"
for index in "${!BLOCKING_JOBS_FILES[@]}"
do
Expand Down
2 changes: 2 additions & 0 deletions bin/k8s-example-config
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ JOBS=()
# List of files ending in '.blockingjob.yml' in the kube directory (Not supported yet)
BLOCKING_JOBS=()
# List of files ending in '.cronjob.yml' in the kube directory
CRONJOBS=()
EOT

echo "Wrote example config to $CONFIG"
1 change: 1 addition & 0 deletions bin/k8s-lint
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ main() {
files_exist "${INGRESS_FILES[@]}"
files_exist "${BLOCKING_JOBS_FILES[@]}"
files_exist "${JOBS_FILES[@]}"
files_exist "${CRONJOB_FILES[@]}"
files_exist "${DEPLOYMENT_FILES[@]}"
files_exist "${HORIZONTAL_POD_AUTOSCALER_FILES[@]}"
files_exist "${POD_DISRUPTION_BUDGET_FILES[@]}"
Expand Down
10 changes: 10 additions & 0 deletions bin/k8s-read-config
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,13 @@ do
done
echo "[blocking_jobs_files]: ${BLOCKING_JOBS_FILES[@]}"
echo ""


echo "[cronjobs]: ${CRONJOBS[@]}"
CRONJOB_FILES=()
for i in "${CRONJOBS[@]}"
do
CRONJOB_FILES+=($BASEDIR/deploy/$i.cronjob.yml)
done
echo "[cronjobs_files]: ${CRONJOB_FILES[@]}"
echo ""
3 changes: 3 additions & 0 deletions k8s-scripts.config
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ JOBS=()
# List of files ending in '.blockingjob.yml' in the kube directory
BLOCKING_JOBS=()

# List of files ending in '.cronjob.yml' in the kube directory
CRONJOBS=()

0 comments on commit 97f2d6c

Please sign in to comment.