'How to effectively schedule a microservice?

I have a python application, that performs some tasks. I run it inside a docker container. I need to schedule this script to run every 30 minutes. Currently, I take this 30 min as a command-line argument while running the script. I wrap my execution logic inside a forever running while loop that sleeps for 30 minutes. Is this pattern of running a microservice architecture pattern? Should I convert it into a flask API and schedule the API to run every 30 minutes?



Solution 1:[1]

You can use k8s cronjob which will work same like normal cronjob but it will run your container on scheduled time . ref# https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dhiraj Surve