0

I have an issue with k8s volumes

The structure

We talk about 2 services (pods) that service one generates files and the other service expose those files over the web.

Service number one needs a UDP connection open to the world and also a TCP connection to communicate between other pods.
(two services, one for UDP and one for TCP)

Service Number two needs a connection to the world (web).
(one service that connects to ingress)


The Issue
I need volume in memory between those two pods, to speed up the R/W process.

The solution I checked, to work with the multi-container structure using EmptyDir volume (there is an option to run this volume in memory)

The problem with this solution is that I can't connect the k8s service object for those containers, service connects only to pods, and only the pod gets IP but containers not.

there is any solution or idea for this situation?

p.s. I'm running on AKS if it's matters.

m_g
  • 61
  • 1
  • 6
  • 1
    Can service A send the file to service B using a TCP connection, instead of using a shared filesystem? This may or may not be faster (it's not clear what your current setup is) but it will be generally easier to manage in Kubernetes; trying to share files between pods adds a lot of complication. – David Maze Jan 10 '21 at 12:47

1 Answers1

0

If you really want to use a multi-container pod, why don’t you create two Kubernetes service resources? One mapping to ContainerPort A and one mapping to containerPort B? This way you would Expose every Container independently.

Keep in mind, that EmptyDir is not „in memory“ it is just a shared volume on the same host, accessible only for the containers that are sharing the emptyDir.
Edit: as @Matt pointed out I was wrongly informed: I was not aware of the emptyDir.medium="Memory" setting.

So another solution could be to go with two independent pods and a dedicated volume (either on host level or a Kubernetes persistent volume). With taints and tolerations you can then ensure, that both pods are scheduled on the same node where the actual volume is attached.

cvoigt
  • 517
  • 5
  • 16
  • 2
    "Keep in mind, that EmptyDir is not „in memory“ - Read the docs one more time, and notice the `medium` field and its allowed values: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir – Matt Jan 11 '21 at 10:05
  • 1
    Thank you @Matt for correcting me. Edited my answer. – cvoigt Jan 15 '21 at 16:14