run cron jobs inside container in background when i am having a nodejs application as endpoint in foreground

0 votes
I am trying to deploy my application inside a kubernetes cluster by helm package. I have a nodejs application which queries cron jobs from database and should add these jobs to crontab file inside the same container.

So when I expose my container as a nodejs app in a port, I will make a add job request and these jobs are formatted to cron job type, and these entries needed to be added to crontab and execute these jobs in background.

Can this be achieved?
Sep 17, 2018 in Kubernetes by lina
• 8,220 points
2,302 views

2 answers to this question.

0 votes

I think that you are looking for a job scheduler, you should try putting more than 1 process per container, maybe you can use another approach using an extra microservice that runs that jobs.

I recommend using Agenda

https://github.com/agenda/agenda

You can create an Agenda worker that has the code for the different jobs and the only thing that you need is to send a scheduled job or now execution, by this architecture you can have multiple agendas also as a sidecar container inside the same pod of your node application.

answered Sep 17, 2018 by Kalgi
• 52,350 points
0 votes

You can define a health check in the dockerfile. This is also possible in docker-compose and running docker container via cli.

HEALTHCHECK <options> CMD <your command with args> || exit 1

That will provoke that when you do docker ps you'll see if a container is running or stopped, and in case it's running, if it's healthy or not, i.e, if your command is being executed / has been executed properly.

answered Sep 17, 2018 by lina
• 8,220 points

Related Questions In Kubernetes

+1 vote
1 answer

Run a cron job once in N hours

If you want your cron job to ...READ MORE

answered Sep 18, 2018 in Kubernetes by Kalgi
• 52,350 points
853 views
0 votes
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,477 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
0 votes
1 answer

Pods IP address from inside a container in the pod

Make sure that your pod yaml file ...READ MORE

answered Aug 29, 2018 in Kubernetes by Kalgi
• 52,350 points
2,437 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP