Mounting container filesystem into sidecar in k8s

12/9/2020

I'd like to run perf record and perf script on a process running in a container in Kubernetes (actually on Openshift). Following the approach from this blogpost I was able to get perf record working (in the sidecar). However the perf script cannot read symbols (in sidecar) because these are present only in the main container.

Therefore I'd like to mount the complete filesystem of the main container into the sidecar, e.g. under /main and then run perf script --symfs=/main. I don't want to copy the complete filesystem into an emptyDir. I've found another nice blogpost about using overlay filesystem; however IIUC I would need to create the overlay in the main container and I don't want to run that as a privileged container and require commands (like mount) to be present.

Is there any way to create sort of reverse mount, exposing a part of container to be mounted by other containers within the same pod?

-- Radim Vansa
kubernetes
openshift
overlayfs
persistent-volumes

0 Answers