Thankfully on Kubernetes, updates to the ephemeral containers feature and the addition of the --profile and --target options to kubectl debug have greatly simplified this process. There is now a fairly easy means of creating a privileged process context that shares a pid namespace with a specific target container.
https://www.enterprisedb.com/blog/debugging-processes-across-container-boundaries-kubernetes