Kubernetes Volume mountpath

3/2/2017

I'm running multiple web pods for the same application and I have this folder in my application where clients can upload their files. the folder is sitting in this directory(if my war file name is sample.war) /usr/local/tomcat/webapps/sample/uploadfiles and I want it to be shared between all the web pods, in case the client login to a random session within a specific web POD 1 and upload some files there, can find them next time he logs in to another random session within another web POD N I'm using Google Cloud Platform container engine and Google persistent disk as persistent volume

my dockerfile looks something like this

FROM tomcat:8-jre8
ADD sample.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"] 

I have this in my Kubernetes Deployment YAML file

volumeMounts:
    - mountPath: /usr/local/tomcat/webapps/    

but I get an empty /usr/local/tomcat/webapps/ directory inside my pod with only lost+found and even when I mountpath any sub-directory of /usr/local/tomcat/webapps/ that sub-directory is empty too.

So should I edit my application in a way the files gets uploaded to a directory outside /usr/local/tomcat/webapps/ like /usr/local/tomcat/uploadfiles, or there is a way to share /usr/local/tomcat/webapps/sample/uploadfiles between the pods.

-- montatich
docker
google-kubernetes-engine
java
kubernetes
tomcat

1 Answer

3/2/2017

Sharing the same writeable volume between different pods is not something that is supported by all volume types. Have a read of the Persistent Volumes manual and look for volume types that support ReadWriteMany

-- Janos Lenart
Source: StackOverflow