Does the nodes of a Kubernetes cluster share memory

12/19/2018

We want to deploy an application that utilizes memory cache using docker and kubernetes with horizontal pod auto-scale, but we have no idea if the containerized application inside the pods would use the same cache since it won't be guaranteed that the pods would be in the same node when scaled by the auto-scaler.

I've tried searching for information regarding cache memory on kubernetes clusters, and all I found is a statement in a Medium article that states

the CPU and RAM resources of all nodes are effectively pooled and managed by the cluster

and a sentence in a Mirantis blog

Containers in a Pod share the same IPC namespace, which means they can also communicate with each other using standard inter-process communications such as SystemV semaphores or POSIX shared memory.

But I can't find anything regarding pods in different nodes having access to the same cache. And these are all on 3rd party sites and not in the official kubernetes site.

I'm expecting the cache to be shared between all pods in all nodes, but I just want confirmation regarding the matter.

-- Ken Gopert Gerada
caching
docker
kubernetes
memory

1 Answer

12/20/2018

No, separate pods do not generally share anything even if running on the same physical node. There are ways around this if you are very very careful and fancy but the idea is for pods to be independent anyway. Within a single pod it's easier, you can use normal shmem, but this is pretty rare since there isn't much reason to do that usually.

-- coderanger
Source: StackOverflow