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屋!
查看全文