Pass env vars from init container to main container

2/12/2019

I have an init container that gets key vault secrets and mounts it to a path available to the main container. How do I retrieve these secrets in main container as env vars?

-- Lumine
containers
init
kubernetes

1 Answer

2/12/2019

initContainers complete before the other container(s) are started. Ergo, you can assume your mount succeeded (because if it did not, the pod would be restarted), and can source the file as if it were always in the container to add it to the environment settings.

-- TinaC
Source: StackOverflow