【问题标题】:How to use the --tmpfs mount in the Kubernetes YAML file?如何在 Kubernetes YAML 文件中使用 --tmpfs 挂载?
【发布时间】:2021-06-17 10:37:58
【问题描述】:

我正在尝试在 Kubernetes YAML 文件中使用 docker run 命令中的 --tmpfs 标志,但找不到方法。

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

【问题讨论】:

  • (请注意,合理配置的 Kubernetes 集群可能会阻止您声明 SYS_ADMIN Linux 功能或挂载主机的 /sys 目录。如果您需要完整的 GNOME 桌面环境,虚拟机可能是更好的匹配。)

标签: docker kubernetes


【解决方案1】:

您正在寻找一个 emptyDir 卷,如下所示:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-10
    • 2022-01-21
    • 1970-01-01
    • 2020-06-04
    • 2019-10-18
    • 2023-01-03
    • 1970-01-01
    • 2017-11-11
    相关资源
    最近更新 更多