1

I have an API that describes itself through an openapi3 file. This app is contained in a pod that also has a sidecar app that is supposed to read this file at startup time.

My probleme is how my sidecar app can read the openapi file from the other container ?

I know I could do it using a volume (emptyDir) and modify the command so my api copies the file at startup time. I'd rather not go this route. I have been looking for a feature, where I define a volume which is mapped to an existing folder in my app, but without being empty. Is there such a thing ?

benjamin.d
  • 2,801
  • 3
  • 23
  • 35
  • Docker itself has a flag called --volumes-from, which does what you want. Maybe [this answer](https://stackoverflow.com/questions/30538210/how-to-mimic-volumes-from-in-kubernetes) can help. – char Aug 22 '19 at 12:27

1 Answers1

2

One of the simplest approaches is to use emptyDir: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir

In your container that generates the file that needs to be shared, mount emptyDir volume with write access and copy the file there. In your sidecar that needs to read the file, mount the same volume as read only and read the file. With this pattern, all containers in the pod can have access to the same file system with read / write as needed.

Keilo
  • 963
  • 1
  • 7
  • 13
  • As described in my question the `emptyDir` is a solution i'd like to avoid as I need to changed the `CMD` in my Docker because I need this volume to be populated at startup time – benjamin.d Aug 29 '19 at 15:42