I'm creating a ram based emptyDir volume for a pod.
volumes:
- name: ram-disk
emptyDir:
medium: "Memory"
Because this is a ram disk, I need to set the maximum size which it will take from the ram. Is there a parameter to set maximum size and minimum size?
Adding an example (extending @flyer' answer):
apiVersion: v1
kind: Pod
...
spec:
volumes:
- emptyDir:
sizeLimit: 1Gi
name: log
Since Kubernetes 1.20 there is the feature gate SizeMemoryBackedVolumes (currently alpha feature) which does exactly this.
Enable kubelets to determine the size limit for memory-backed volumes (mainly emptyDir volumes).
For kubernetes-1.7.x, it's possible to set the sizeLimit
for an EmptyDir
.
TL;DR: No, at least not for now.
This is an open issue, see 13479. Since I don't know your use case, I suppose my only suggestion is to try and use hostPath
as a workaround, see also the docs for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With