Coder Social home page Coder Social logo

crond's Introduction

Crond for OpenShift

This repo contains Dockerfile and OpenShift templates to run Crond.

Jobs may be configured to run as Kubernetes Jobs, from within a user defined docker images.

It uses ConfigMaps for jobs configuration and definition.

This is a temporary solution until CronJobs hit production

Usage

Create the ImageStream in your project and import it:

$ oc create -f imagestream.yaml
$ oc import-image crond

Give permission to create Job objects to service account cron:

$ oc policy add-role-to-user admin -z cron

Now, let's create a cron application named cron:

## Change "myproj" and "app" for the name of the project and image you want to execute the job in
$ oc process -f template.yaml -v NAME=cron,JOB_IMAGE_NAMESPACE=myproj,JOB_IMAGE_NAME=app | oc create -f -

Valid parameters are:

  • NAME: the name of the app
  • CRON_SCHEDULE: Cron schedule to excute the job
  • COMMAND: Command to execute
  • DOCKER_REGISTRY, JOB_IMAGE_NAMESPACE, JOB_IMAGE_NAME and JOB_IMAGE_TAG: Define image to use to run the job
  • JOBS_DIR: Where to mount job's ConfigMap files

It will create the following objects:

  • DeploymentConfig/cron: the crond itself, plus job management scritps from dir root/
  • ConfigMap/cron-config: crond configuration
  • ConfigMas/cron-jobs: list of Job objects to execute

Configure

Configs for both crond and Jobs are stored in ConfigMaps

$ oc edit configmaps/cron-config
$ oc edit configmaps/cron-jobs

In order to create new jobs simply add entries to ConfigMap/cron-jobs under key data

apiVersion: v1
kind: ConfigMap
metadata:
  name: ${NAME}-jobs
data:
  myjob: |-
    # Here goes a Pod template

Then add an entry to execute your job myjob in ConfigMaps/cron-config:

# runs job `myjob` everydat at 3:05AM
5 3 * * * cron run-job myjob

After editing ConfigMaps you must re-deploy the application:

$ oc deploy cron --latest

Job cleanup

The docker image ships with clean-jobs script to delete old Job objects and it's Pods. It's highly recomended to run it periodically:

*/5  *  *  *  * cron clean-jobs

crond's People

Contributors

caruccio avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.