Stitch together a Docker job scheduler, distributed locking, task runner, and alerting system
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: Docker, Kubernetes
- Job Alerting: Sensu
- Cron
- If ran with no command argument it will start in cron mode and run on the cron schedule.
- Cron functionality can be disabled for an entire jobs yaml file by adding
SCHEDULED
under the configuration for a job yaml
- Single Job
- If a job name is specified it will run the job, tail the logs, and exit when the job is finished.
- Lockers and Alerters are disabled in this mode
-
Docker
- docker run sstarcher/job-runner:latest
-
Kubernetes
- Example pod for running under Kubernetes
apiVersion: v1
kind: ReplicationController
metadata:
name: job-runner
spec:
replicas: 1
selector:
name: job-runner
template:
metadata:
labels:
name: job-runner
spec:
containers:
- name: job-runner
image: sstarcher/job-runner:latest
env:
- name: RUNNER
value: kubernetes
- name: KUBERNETES_MASTER
value: http://kubernetes:8080
- Docker
- Mount either the docker socket or set DOCKER_HOST
- Kubernetes
- Set
KUBERNETES_MASTER
to your Kubernetes cluster url examplehttp://127.0.0.1:8080
- compose2kube binary has been built from - https://github.com/sstarcher/compose2kube
- IGNORE_OVERRUN - if this variable is false if a job is running and a new job is launched of the same name this will alert to the alerter
- Set
- 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
- Sensu
- SENSU_HOST to an address for Sensu - default
127.0.0.1
- SENSU_PORT to the port Sensu is listening on for the client - default
3030
- KIBANA_HOST optional URL. If set a Kibana link will be sent to the sensu data
- SENSU_HOST to an address for Sensu - default
- Kubernetes
- Will delete any pods containing a "jobrunner" label
- Processes any alerting logic needed
- Alerters, Lockers are disabled by default
- Docker is the default runner
- 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