kubernetescontainersresourcestmpfs

How to take tmpfs usage into account in Kubernetes resource allocation?


I have a Kubernetes cluster and some applications running on it. All of the Pods have their own resource limit/request settings.

One of my applications uses tmpfs (/dev/shm) for its data processing, so I have described its volume setting like below to expand available tmpfs size:

volumes:
- name: tmpfs
  emptyDir:
    medium: Memory
    sizeLimit: 1G

However, as Kubernetes doesn't take tmpfs usage into account when it schedules new Pods, some Pods may not be able to use their allocated memory despite being successfully scheduled based on its memory request.

Is it possible to let Kubernetes consider the use of tmpfs? I want to set the memory request to the sum of its memory limit and tmpfs usage but it's not possible as the request must be less than or equal to the limit. I wonder there may be a proper way to do this.


Solution

  • tmpfs volume is treated as container memory usage, you should add the 1Gi to your resources.limits.memory for the scheduler to take this into consideration. It is fine to have the resources.requests.memory lower than your limits.