I installed vault agent in my K8s cluster and the vault server resides in another cluster. I’m using the AppRole auth method. The authentication works without any error. The secrets are also mounted to my application pod, but it won’t source it and take it as a variable. Below are the details.
Please share the command you are configuring in your Kubernetes yaml too, or the ENTRYPOINT of the Docker image being run. It is not possible to fully understand how args will be used without that.
Additionally, even if you successfully set environment variables this way to be present for your main process, I don’t think they will apply to kubectl exec sessions
i.e. you’re not actually sourcing your environment variables at all, rather you’re passing the sh -c '...' command as program arguments to your Java application (which probably ignores it).
You should be using command instead of args in your K8s YAML, so that the K8s configuration takes full control of the command to be run, in this case.