Trying to move my services to K8s. I am using helm for that and I want to describe my example with issue:
I need to move few services with own Apache`s. Yes, I understand, that this is working something like:
external traffic -> K8s nginx ingress -> pod Apache
But I cant change it for now. Apache is working with PHP. So, I have deployment for two images: php-fpm
and Apache
. And, in this case, I need to share php files from my first php-fpm container with Apache.
For now - I am using shared volumeMounts
to copying files from one container to second (all date is preparing/compiling in the first container, php-fpm, during the build):
volumeMounts:
- name: shared-files
mountPath: /var/shared-www
And
lifecycle:
postStart:
exec:
command: ["/bin/bash", "-c", "cp -r XXX /var/shared-www/"]
And it is working, but I would like to find solution to have one common point, like a symlink, to store files. I want to have ability to change files in one place and have changed files in both containers.
Is it possible?
PS I am using AWS EKS. And I don`t want to use network storage (like a EFS).
Why not use subPath as per official documentation:
it is useful to share one volume for multiple uses in a single pod. The volumeMounts.subPath property specifies a sub-path inside the referenced volume instead of its root.
So instead of running the command something like (to share XXX towards):
volumeMounts:
- name: shared-files
mountPath: /var/shared-www
subpath: XXX
Update:
Kubernetes subpath vulnerability article