How to create cron jobs on Hasura?

1/4/2018

How can I create, deploy and run and manage Cron jobs on Hasura?

-- ecthiender
cron
hasura
kubernetes

1 Answer

1/4/2018

Hasura suggests two ways to deploy and run Cron jobs.

Cron microservice

Hasura already has a microservice to run Cron jobs.

If you already have a Hasura project run:

hasura microservice create mycron --template=python-cron

Change mycron to whatever you want to name your microservice. This will create a custom Python microservice designed to run Cron jobs. (Follow further instructions as prompted by hasura CLI)

To deploy this on Hasura, git commit and push to your cluster's remote.

$ git add .
$ git commit -m "Add cron job"
$ git push hasura master

To know more about how to customize this microservice, you can read the docs.

Kubernetes Cron jobs

Since, Hasura runs on Kubernetes and Kubernetes (>= v1.8) already provides Cron Jobs as a first class resource, it is recommended to use Kubernetes Cron jobs wherever possible.

If you have kubectl installed you can check your Kubernetes version by running: kubectl version. In the output, the "server version" shows the version of the Kubernetes cluster. If you are running Kubernetes >= v1.8, we recommend you to use Kubernetes Cron jobs.

When using Kubernetes Cron jobs, you can version control your cron job specs inside your Hasura project, and use the kubectl tool to create and manage them.

-- ecthiender
Source: StackOverflow