How to use the --tmpfs mount in the Kubernetes YAML file?

Viewed 2127

I am trying to use the --tmpfs flag from the docker run command in the Kubernetes YAML file but could not find the way.

sudo docker run --name=ubuntu-gnome -d --rm \
  --tmpfs /run --tmpfs /run/lock --tmpfs /tmp \
  --cap-add SYS_BOOT --cap-add SYS_ADMIN \
  -v /sys/fs/cgroup:/sys/fs/cgroup \
  -p 5901:5901 -p 6901:6901 \
  darkdragon001/ubuntu-gnome-vnc
1 Answers

You're looking for an emptyDir volume, such as the following:

apiVersion: v1
kind: Pod
metadata:
  name: demo
spec:
  containers:
  - name: container
    ...
    volumeMounts:
    - mountPath: /tmp
      name: tmp
      subPath: tmp
    - mountPath: /run
      name: tmp
      subPath: run
    - mountPath: /run/lock
      name: tmp
      subPath: run-lock
  volumes:
  - name: tmp
    emptyDir:
      medium: Memory
      sizeLimit: 64Mi
Related