Stitch together a Docker job scheduler, distributed locking, task runner
This repo outputs reaps and alerts on finished kubernetes jobs.
Project: [https://github.com/sstarcher/job-runner] (https://github.com/sstarcher/job-runner)
Docker image: [https://registry.hub.docker.com/u/sstarcher/job-runner/] (https://registry.hub.docker.com/u/sstarcher/job-runner/)
- Job Scheduler: Cron
- Distributed Locking: Consul
- Task Runners: Kubernetes
- Cron
- If ran with no command argument it will start in cron mode and run on the cron schedule.
- Single Job
- If a job name is specified it will run the job and print out the pod name
- Lockers are disabled in this mode
apiVersion: v1
kind: Deployment
metadata:
name: job-runner
spec:
replicas: 1
template:
metadata:
labels:
name: job-runner
spec:
containers:
- name: job-runner
image: sstarcher/job-runner:latest
- Set
KUBERNETES_MASTER
to your Kubernetes cluster url examplehttp://127.0.0.1:8080
- Consul
- CONSUL_HOST to an address without your cluster - default
localhost
- CONSUL_PORT to the port your cluster is listening on - default
8500
- CONSUL_HOST to an address without your cluster - default
- Lockers are disabled by default
- Example job formats are in the
example-jobs
folder - Job names must be unique
- example-jobs
- This project utilizes docker ONBUILD so any yaml files added under a
jobs
directory will be added and processed
- Create a Dockerfile
FROM sstarcher/job-runner:latest
- Create a folder called jobs
- Create a job
Example:
image: debian:jessie #This value is overriding what is set in the DEFAULTS.yaml
Jobs:
- Test:
time: '* * * * *'
command: echo $job
- docker build --pull -t jobs .
- docker run jobs