Reputation: 14368
I have a pod with the following volume specified
- name: file-storage
emptyDir:
medium: Memory
also have the ephemeral storage specified in the requests and limits:
limits:
cpu: 2
ephemeral-storage: 2Gi
memory: 2Gi
requests:
cpu: 1
ephemeral-storage: 2Gi
memory: 2Gi
Now I am wondering, will the emptyDir.medium take precedence so that I get to use the RAM or the I get the ephemeral-storage and let kubernetes decide the best for me?
Upvotes: 7
Views: 19055
Reputation: 191
The emptyDir spec with medium: Memory
get stored on RAM and count towards your request and limits of memory that you specify. If you remove the medium: Memory
then they will be stored on the ephemeral-storage
.
This is because medium: Memory
spec is created on tmpfs
that is allocated from RAM.
If you would like to read more about this please look at the following links:
https://kubernetes.io/docs/concepts/storage/volumes/#emptydir https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-emphemeralstorage-consumption
Hope this answers your question, let me know if you need more clarity on this.
Upvotes: 8
Reputation: 1711
If you do not specify where to create an emptyDir , it gets created on the disk space of the Kubernetes node.
If you need a small scratch volume, you can define it to be created in RAM. As soon as you start using emptyDir.medium it starts using RAM.
You can check the same by creating a deployment of busybox, exec into the pod and run df -h and then you can check you would get a tmpfs (RAM) FileSystem type.
The default size of a RAM-based emptyDir is half the RAM of the node it runs on. With limits and requests please try and check what the size of disk comes out to be. Is it still from the node or does it pick up from limits values.
Please check this excercise for better understanding https://www.alibabacloud.com/blog/kubernetes-volume-basics-emptydir-and-persistentvolume_594834
Upvotes: 6