Code Monkey home page Code Monkey logo

k8s-cronjob-api's Introduction

K8S job/cronjob solution

Implement a very simple API server in rust with the following routes that can interact with kubernetes.

  • POST /jobs (Create a new job that runs on a kubernetes cluster)
  • GET /jobs/stats (Returns aggregate job stats. Succeeded vs failed and no of retries)
  • POST /jobs/schedule (Schedule a job using cron syntax)

Job Requirement:

  • Each job should spawn a docker container with the following command.
  • If the job fails, retry 2 times with a small time delay ideally.

Directory structure:

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── data_processor.zip     -> Job
├── dockerfile             -> Containerize
├── makefile               -> CLI utils
├── src                    -> API server
│   └── main.rs
  1. Monitoring solution:

    • prometheus, grafana
  2. Fault tolerance solution:

    • retry, HA solution
  3. Scalability solution:

  4. Running 100s of these jobs in parallel:

Curl samples:

  1. POST /jobs
$ curl -XPOST localhost:8080/jobs \
-H 'Content-type: application/json' \
-d '{"name":"test-job"}'
  1. GET /jobs/stats
$ curl localhost:8080/jobs/stats
  1. POST /jobs/schedule
$ curl -XPOST localhost:8080/jobs/schedule \
-H 'Content-type: application/json' \
-d '{"name":"test-cronjob","syntax":"* * * * *"}'

k8s-cronjob-api's People

Contributors

scott-dn avatar

Watchers

 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.