Yes, you can use shared memory by setting hostIPC: true
in the Pod Security Policy:
hostIPC
- Use the host’s ipc namespace. Optional: Default to false.
Notice that you can't link 2 isolated Pods (Pods not allocated on the same Node) IPC spaces together but any hostIPC
Pod would be able to use shared memory with any other hostIPC
Pod.
You can make sure that the Pods are scheduled together by using nodeSelector or Affinity and anti-affinity.
Bear in ind that you also need to use a proper volume type. For example emptydir
will not work but hostPath can be used.
I know you mentioned that but I need to underline the fact that by using the hostIPC
you give ability to access data used by any pods that also use the host’s IPC namespace which creates a severe security risk. Here are some examples of it.