The title again. The problem is that the I fetch the date from an API and once the container is run on that date, I fetch the next date on which I want to run the container on. Is there any cloud service on any cloud platform which provides this service?
5
Answers
if you want to run a specific logic(piece of code) at specific time then go with server-less application, almost all cloud provider provide sever-less implementation with different name.
like AWS, they have lambda in place to provide server-less capability. great way to save a cost and you don’t have to maintain your resources.
now coming to your question if you choose aws platform then write your piece of code in lambda function and then trigger/run that function with cloudWatch event.(trigger at specific time).
best of luck.
You are looking for container orchestration. One option is to use ECS on AWS, but a simpler option would be Lambda (with Docker) + Eventbrdige. You could also optionally use Cloudwatch instead of event bridge, but afaik EventBrdige is the improved way of doing pretty much what you could do with Cloudwatch, however, there are some differences – https://aws.amazon.com/blogs/compute/upgrading-to-amazon-eventbridge-from-amazon-cloudwatch-events/
You could go through the ECS route, but it will be a bit more complex and time-consuming and if Lambda serves your purpose, then that would be much more convenient for you.
Lambda also supports Docker images, or you could code in the language of your choice.
Also, these services are specific to AWS, but pretty much all cloud hosting providers, and a lot of third-party SaaS applications would provide similar functionalities if you are interested.
maybe you wanna give "Kubernetes CronJobs" a try.
A daily job for your container could look like this :
Full details can be found on Kubernetes CronJob Webpage
One way to go about this is:
Programmatically repeat 3-4.
For eg., updating the EventBridge Rule through
aws events put-rule --name <RULE_NAME> --schedule-expression <CRON_VALUE> --role-arn <IAM_ROLE_ARN>
You can have the cron value easily this way:
NOTE: This is not a good practice as EventBridge will be a serious limiting factor – only invoking the execution of container at a desired time, one at a time. This limits running to a single container invocation.
If you need a better concurrent scheduling method you can have Docker setup in EC2 and use
at
command to schedule.See example: https://www.redhat.com/sysadmin/single-use-cron
You can use aws ECS (Elastic container service) to run scheduled containerized workloads, hosted either on ec2 instances, external devices or server-less on
AWS Fargate.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduling_tasks.html