【问题标题】:Kubernetes share a directory from your local system to kubernetes containerKubernetes 将本地系统中的目录共享到 Kubernetes 容器
【发布时间】:2019-02-01 21:53:09
【问题描述】:

有没有办法将目录/文件从本地系统共享到 kubernetes 容器?

我有一个部署 yaml 文件。我想在不使用kubectl cp 的情况下共享目录。

我尝试使用configmap,但后来我知道 configmap 不能拥有整个目录,而只能拥有一个文件。

如果有人有任何想法,请分享。

请注意:我不想将文件托管到 minikube 中,但我想将目录直接推送到容器中

【问题讨论】:

标签: kubernetes kubectl minikube


【解决方案1】:

我找到了办法。

我们可以在volumes中使用hostPath来指定我们要添加到容器中的目录

      volumeMounts:
        - name: crypto-config
          mountPath: <PATH IN CONTAINER>
        - name: channel-artifacts
          mountPath: /opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
        - name: chaincode
          mountPath: /opt/gopath/src/github.com/chaincode
  volumes:
    - name: crypto-config
      hostPath:
        path: <YOUR LOCAL DIR PATH>
    - name: channel-artifacts
      hostPath:
        path: /Users/akshaysood/Blockchain/Kubernetes/Fabric/network/channel-artifacts
    - name: chaincode
      hostPath:
        path: /Users/akshaysood/Blockchain/Kubernetes/Fabric/network/chaincode

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-14
  • 1970-01-01
  • 1970-01-01
  • 2021-10-04
  • 1970-01-01
相关资源
最近更新 更多