docker - Hostpath 卷未安装在 Windows 的 Docker-desktop 上运行的 kubernetes 上
问题描述
我在 Docker-desktop for windows 上运行 kubernetes。我正在从我的 WSL 连接到集群。我所有的 pod 都运行正常。我正在尝试使用主机路径在我的 jupyterlab(pod)上安装一个卷。下面是我的配置
apiVersion: apps/v1
kind: Deployment
metadata:
name: jupyter
labels:
app: jupyter
spec:
replicas: 1
selector:
matchLabels:
app: jupyter
template:
metadata:
labels:
app: jupyter
spec:
containers:
- name: jupyter
image: jupyter:1.1
ports:
- containerPort: 8888
securityContext:
runAsNonRoot: true
runAsUser: 1000
volumeMounts:
- name: mydir
mountPath: /notebooks
volumes:
- name: mydir
hostPath:
# directory location on host
path: /home/<myuser>/data
# this field is optional
type: DirectoryOrCreate
吊舱启动没有任何问题。但我没有看到我保存在我的主机路径中的笔记本到我的 jupyter 实验室,反之亦然(如果我在 jupyter 实验室保存笔记本,它不会保存到我的主机路径)。
我按照https://kubernetes.io/docs/concepts/storage/volumes/#hostpath上的教程进行操作
我想指出我正在使用 @FROM jupyter/datascience-notebook:python-3.7.6" 作为我的 docker 映像。
我尝试安装 /home/jovyan/ 但它在启动 pod 时给了我访问相关的错误。所以我恢复到“/notebooks”
解决方案
在 Windows 上编写路径的方式似乎存在问题,我在下面的参考资料中看到了该问题。
解决方案:
- 如果您的文件位于 C: 驱动器中,则应将其转换为以下内容
/host_mnt/c/path/to/my/folder
- 如果上述方法不起作用,您可能需要删除“类型:DirectoryOrCreate”并重试。
参考资料: https ://github.com/kubernetes/kubernetes/issues/59876#issuecomment-628955935 https://github.com/docker/for-win/issues/1703#issuecomment-366701358。
推荐阅读
- excel - 将表格数据从电子邮件导出到 excel 列
- firebase - Firebase 函数/firestore 不起作用并捕获返回空对象
- html - 如何在 Angular Material 中增加垫选择表单的宽度?
- python - Python图形类实现
- angular - 如何在不导入 HTML 中的脚本标签的情况下导入作为 Angular 组件的自定义元素?
- apache - Apache HTTPD RewriteRule 中的 ^ 和 $ 是什么意思?
- angular - 查看行为异常的封装
- flutter - Flutter:将文件(图像)裁剪为圆形
- c# - 通过 http 请求从 SharePoint 下载文件 - Xamarin
- json - 带有 mutate 的 Logstash JSON 过滤器以添加新字段