Resolved: How to mount Vault secret as a file in Kubernetes?

In this post, we will see how to resolve How to mount Vault secret as a file in Kubernetes?

Question:

I’m using Hashicorp Vault in Kubernetes. I’m trying to mount secret file into main folder where my application resides. It would look like that: /usr/share/nginx/html/.env while application files are in /usr/share/nginx/html. But the container is not starting because of that. I suspect that that /usr/share/nginx/html was overwritten by Vault (annotation: vault.hashicorp.com/secret-volume-path). How can I mount only file /usr/share/nginx/html/.env?
My annotations:

Best Answer:

I tried to replicate the use case, but I got an error
so it seems like vault changed the directory permission as well, as it create .env in the path, here is the config
The work around was to overide the command of the desired container, for this use case, i used nginx
Here is the compelete example with dummy value of my-app

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com