Kubernetes将本地系统中的目录共享到kubernetes容器 [英] Kubernetes share a directory from your local system to kubernetes container
本文介绍了Kubernetes将本地系统中的目录共享到kubernetes容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以从本地系统将目录/文件共享到kubernetes容器?
Is there any way to share the directory/files to kubernetes container from your local system?
我有一个部署yaml文件.我想不使用kubectl cp
共享目录.
I have a deployment yaml file. I want to share the directory without using kubectl cp
.
我尝试使用configmap
,但后来我知道configmap不能具有整个目录,而只能具有一个文件.
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.
请注意:我不想将文件托管到minikube中,但我想将目录直接推送到容器中
Please note: I do not want to host the file into minikube but I want to push the directory directly to container
推荐答案
我找到了一种方法.
我们可以使用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
这篇关于Kubernetes将本地系统中的目录共享到kubernetes容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文