We have our database either in aws rds or azure postgres or even on a different online server based on customer.
But our product will be running in azure kubernetes as a pod and service with database details in configmap.
Before we launch our app, it is mandatory that an sql file should be running in the database as preconfiguration.
What is the best approach we can set it so that we can automate this?
There are many possible solutions for this and it will depend on the way you do the deploy and what tools you use to do the deploy.
First of all be aware that it's an antipattern to launch a pod and execute an SQL (init or migration script). Containers should do one thing and you should not assume how the containers will be executed. For example, what happens if you launch multiple containers at the same time? If all of them run migrations at start, they will trip over each other. So, initcontainers should also be discarded as a solution.
The simplest solution is to run as a separate job as part of your CI/CD pipeline. You execute the init/migration. Once it's applied, you deploy your code.
If you are you using helm, you can use pre-install or pre-update hook
As I tried to explain, there are many alternatives to do exactly what you want. The main thing is that you need to control "when" the database changes are applied specially because you can't control "how" they will be running.