docker - Kubernetes 存储类型 Hostpath- 文件映射问题
问题描述
您好我正在使用最新的 kubernetes 1.13.1 和 docker-ce(Docker 版本 18.06.1-ce,构建 e68fc7a)。
我设置了一个部署文件,该文件从主机(主机路径)挂载文件并将其挂载到容器中(挂载路径)。
该错误是当我尝试将查找从主机安装到容器时,我收到一条错误消息,指出它不是文件。(Kubernetes由于某种原因认为该文件是一个目录)
当我尝试使用以下命令运行容器时: Kubectl create -f 它永远停留在 ContainerCreating 阶段。
在使用 Kubectl describe pod 对其进行深入研究后,它会说:
是有一条错误消息,文件未被识别为文件。
这是部署文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
io.kompose.service: notixxxion
name: notification
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: notification
spec:
containers:
- image: docker-registry.xxxxxx.com/xxxxx/nxxxx:laxxt
name: notixxxion
ports:
- containerPort: xxx0
#### host file configuration
volumeMounts:
- mountPath: /opt/notification/dist/hellow.txt
name: test-volume
readOnly: false
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /exec-ui/app-config/hellow.txt
# this field is optional
type: FileOrCreate
#type: File
status: {}
解决方案
我已经重新安装了 kubernetes 集群,它变得更好了。kubernetes 现在可以毫无问题地读取文件并且容器在创建和运行中但是,主机路径存储类型还有一些其他问题:
包含挂载的 hostPath 不会更新,因为它们在主机上发生更改,即使我删除了 pod 并再次创建它
推荐阅读
- webpack - ASP.NET Core + Webpack - 未捕获的 ReferenceError:使用 DllReferencePlugin 时未定义供应商
- php - 与 PHP 一起使用时,Imagemagick 转换命令返回错误代码 4
- php - plesk 中的 Codeigniter base_url
- excel - 用户窗体错误:对象“_VBComponent”的方法“属性”失败
- c++ - 为什么使用 make_unique<> 将函数传递给线程会导致 Valgrind 中的内存泄漏?
- java - 发送 json 数据时的空指针
- swift - Swift - 在 TabbarController 中切换选项卡时保持相同的实例化 UIViewController
- wordpress - Wordpress:使用 add_filter 函数将类添加到 div
- javascript - 如何在函数执行中管理 angularJS 优先级?
- mysql - 在mysql中成对查找重复项