Skip to content

Commit

Permalink
Merge pull request #76 from reactiveops/em/add-cronjob
Browse files Browse the repository at this point in the history
add `CronJob` support
  • Loading branch information
emalloy authored Aug 21, 2017
2 parents 543df33 + 97f2d6c commit 45cfc5c
Show file tree
Hide file tree
Showing 7 changed files with 72 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 ""
37 changes: 37 additions & 0 deletions examples/production-ready/deploy/minimal-production.cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: foo
spec:
schedule: "17 * * * *"
failedJobsHistoryLimit: 10
successfulJobsHistoryLimit: 20
jobTemplate:
spec:
template:
spec:
volumes:
- name: foo
persistentVolumeClaim:
claimName: foo
containers:
- name: foo
image: foo/bar:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 50m
memory: 256Mi
requests:
cpu: 50m
memory: 256Mi
volumeMounts:
- mountPath: /var/foo
name: foo
args: ["foo-job", "-t", "-c", "foo-arg_1", "foo-arg_2"]
env:
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
restartPolicy: OnFailure
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 45cfc5c

Please sign in to comment.