Kubernetes share a directory from your local system to kubernetes container

岁酱吖の 提交于 2020-04-29 09:35:10

问题


Is there any way to share the directory/files to kubernetes container from your local system?

I have a deployment yaml file. I want to share the directory without using kubectl cp.

I tried with configmap but I later came to know that configmap can not have the whole directory but only a single file.

If anyone has any idea please share.

Please note: I do not want to host the file into minikube but I want to push the directory directly to container


回答1:


I found a way.

We can specify the directory we want to add into container by using hostPath in volumes

      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


来源:https://stackoverflow.com/questions/52037957/kubernetes-share-a-directory-from-your-local-system-to-kubernetes-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!