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
-
Monitoring solution:
- prometheus, grafana
-
Fault tolerance solution:
- retry, HA solution
-
Scalability solution:
-
Running 100s of these jobs in parallel:
- POST /jobs
$ curl -XPOST localhost:8080/jobs \
-H 'Content-type: application/json' \
-d '{"name":"test-job"}'
- GET /jobs/stats
$ curl localhost:8080/jobs/stats
- POST /jobs/schedule
$ curl -XPOST localhost:8080/jobs/schedule \
-H 'Content-type: application/json' \
-d '{"name":"test-cronjob","syntax":"* * * * *"}'