Giter Club home page Giter Club logo

container-crontab's Introduction

container-crontab

A microservice that will perform actions on a Docker container based on cron schedule.

Building

make

Running

Standard Docker mode:

./bin/container-crontab

Rancher Mode:

./bin/container-crontab --rancher-mode [--metadata-url http://rancher-metadata/latest]

Usage

Standard Mode:

Once container-crontab is up and running it watches Docker socket events for create, start and destroy events. If a container is found to have the label cron.schedule then it will be added to the crontab based on the schedule.

Cron scheduling rules follow: Expression Format

Use Cron Expression Generator & Explainer to quickly generate cron expressions and convert them to readable text format.

Rancher Mode:

When running in Rancher mode, the service watches Rancher metadata for service state. If the service is in any other mode then Active, then the job is disabled.

It watches metadata on a 5 second interval, so there is a small window where a job could be run when the state is changing. If the container is stopped as part of the upgrade or service deactivate, that event will be immediate. When services are reactivated there is a 5 second window for the job to be re-activated.

Override labels that can be applied

To override the default start action on the container, set the label cron.action equal to stop or restart.

To override the default 10 second restart/stop timeout set the label cron.restart_timeout to the number of seconds you would like. For instance for 20 seconds: cron.restart_timeout=20.

Examples

# Restart every minute
> docker run -d --label=cron.schedule="0 * * * * ?" ubuntu:16.04 date

Metrics

Starting in v0.3.0 the container-crontab exposes a prometheus metrics endpoint http://<ip>:9191/metrics when started with the --metrics CLI option. From that you can get a guage on the number of Jobs sliced by Active/Inactive states. It also provides other golang information about the program.

rancher_container_crontab_jobs_total{hostname, state}

License

Copyright (c) 2014-2017 Rancher Labs, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

container-crontab's People

Contributors

cloudnautique avatar flaccid avatar galal-hussein avatar quba avatar rancher-sy-bot avatar superseb avatar wiesendaniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.