如何解决主机路径卷未安装在 Windows Docker-desktop 上运行的 kubernetes 上
我在 Windows 的 Docker-desktop 上运行 kubernetes。我正在从我的 WSL 连接到集群。 我所有的豆荚都在正确运行。我正在尝试使用主机路径在我的 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
Pod 启动时没有任何问题。但我没有看到我在主机路径中保存的笔记本到我的 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 .
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。