【问题标题】:kubernetes - volume mapping via commandkubernetes - 通过命令进行卷映射
【发布时间】:2018-04-02 08:46:23
【问题描述】:

我需要在启动容器时映射一个卷,我可以使用 yaml 文件来做到这一点。

有没有一种方法可以在不使用 yaml 文件的情况下通过命令行完成卷映射?就像 docker 中的
-v 选项?

【问题讨论】:

    标签: kubernetes kubernetes-container


    【解决方案1】:

    不使用yaml文件

    从技术上讲,是的:您需要一个 json 文件,如“Create kubernetes pod with volume using kubectl run”中所示

    kubectl run

    kubectl run -i --rm --tty ubuntu --overrides='
    {
      "apiVersion": "batch/v1",
      "spec": {
        "template": {
          "spec": {
            "containers": [
              {
                "name": "ubuntu",
                "image": "ubuntu:14.04",
                "args": [
                  "bash"
                ],
                "stdin": true,
                "stdinOnce": true,
                "tty": true,
                "volumeMounts": [{
                  "mountPath": "/home/store",
                  "name": "store"
                }]
              }
            ],
            "volumes": [{
              "name":"store",
              "emptyDir":{}
            }]
          }
        }
      }
    }
    '  --image=ubuntu:14.04 --restart=Never -- bash
    

    【讨论】:

    • 看起来kubectl run 链接已被劫持。
    • @ErikB 谢谢。我已恢复链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    • 2017-10-09
    相关资源
    最近更新 更多