I have my deployment scaled across multiple pods. The requirement is that whenever the app starts up I want a piece of code to be executed. But I just want one pod to execute this code. How can this be achieved?
Right now I have a way - I set a flag in my DB and have my pods read the flag, which ever reads and locks the flag first will have to process the task.
Are there any drawbacks in my approach ? Is there any better way to do this?