Kubernetes 从本地系统共享一个目录到 kubernetes 容器

Kubernetes share a directory from your local system to kubernetes container

有什么方法可以从您的本地系统共享 directory/files 到 kubernetes 容器吗?

我有一个部署 yaml 文件。我想在不使用 kubectl cp.

的情况下共享目录

我试过 configmap 但后来我知道 configmap 不能有整个目录,只能有一个文件。

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

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

我找到方法了。

我们可以在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