1. create a Secret that defines the file as a key
2. mount that Secret into the container (.secret.secretName in the volume definition) under an arbitrary conventional path, e.g. /secrets
3. define an env-var that gives the path to the file; where the assumption when this env-var isn't defined is to find the file in the working directory. If your own code uses the file, it can read the path from this env-var; while if the core of your container is some opaque tool that doesn't know about the env-var but does take the file's path on the command-line, then you can wrap the tool in an entrypoint script that reads the env-var and passes it as a command-line arg to the tool.
IMHO, this approach is flexible but principle-of-least-surprise obeying for both development and production deployment.
A .env file allows you to go from knowing/assuming where a particular file is, to having environment variables.
What I'm describing is that you can go from being passed environment variables directly, to knowing where certain files are; which therefore allows those files to be mounted into a container-image in arbitrary places, rather than encoding brittle assumptions about config-file locations into the binary within the container-image — assumptions that usually get in the way during development, when you're not running the binary inside a container.
The entire point here is that 12-factor isn't the be-all, end-all, so this is irrelevant.
> The intent is for the app to consume the secrets but have no knowledge or care where they came from.
This doesn't really make sense, and is an impossible requirement. The app will always have to know where configuration or secrets come from. Environment variables is just one option of "knowing where they come from". Choosing file storage is just as valid.
We use a custom setup in which the config values are loaded from multiple sources actually, so we could put everything into secrets manager, or load them all from env vars or HOCON files.
If we had to set every config value in ECS / lambda using env vars, it would be a major pain in the ass, and error prone.
And how your apps authenticate to Secrets Manager ? Did you ever call `env` on a pod that has IRSA configured ?
This is just a middle step to do exactly the same thing but instead of using envFromSecret you use envFromSM
That if you dont want to pull in k8s dependencies to the code, at the end every approach ends up as a mounted file or env vars.
Now you're getting away from the spirit of 12factor and hard-coupling them again. The intent is for the app to consume the secrets but have no knowledge or care where they came from.
Edit: misread as "load the secrets directly into the app." Yeah, this is just env vars but different.