Reputation: 2844
I have container A with a directory like "/public/shared". Container b which is a reverse proxy running in the same pod needs access to this directory.
How can I share these? My understanding of sharing a volume is that it is either an exiting external volume/directory, or an empty directory. In this case I want to share an existing directory in container A without creating an external/additional volume.
Also, I know it is possible to adjust container A so that it copies its data on startup, or to have it expose this via a REST API. Without going into detail, I would like to avoid touching the container A image and just accomplish this with just modifying the deployment YAML. For example, via copying. But copying uses
command: ["/bin/sh"]
args: ["-c", "cp -r /public/shared /public/mounted"]
And this seems to overwrite the default startup script in the pod if I understand correctly.
Upvotes: 0
Views: 201
Reputation: 2844
Turns out you can add in a lifecycle command. This fixes it by copying into the empty dir without affecting the application startup. I feel like this still isn't great as it isn't guaranteed to run before startup. I guess I can also add a readiness probe to make sure these files are there. If anyone else has a better solution, I would be interested in seeing it:
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "cp -r /public/shared /public/mounted"]
Upvotes: 0