我需要将一个压缩文件从我的主机复制到pod/容器。为此使用hostPath卷,如下所示
volumeMounts:
- mountPath: "/tmp/delivery/AB_Database.zip"
name: db-volume
subPath: AB_Database.zip
volumes:
- name: db-volume
hostPath:
path: /delivery/oracle 但是,当我在pod中检查时,AB_Database.zip就被看作是目录。
发布于 2022-03-07 16:57:05
这是因为您在子路径中指定了名称
volumeMounts:
- mountPath: "/tmp/delivery/AB_Database.zip"
name: db-volume
subPath: AB_Database.zip
volumes:
- name: db-volume
hostPath:
path: /delivery/oracle 子路径工作方式如下
volumeMounts:
- name: test-path
mountPath: /a/b/c
subPath: d在c目录中有一些文件-- 1.txt,2.txt --子路径将重写c中的这些内容,并创建新的目录d
您可以在以下站点查看更多信息:https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath
如果您只想将zip挂载到POD中,可以使用挂载路径执行类似的操作。
- mountPath: /var/local/aaa/1.txt
name: myfilehttps://kubernetes.io/docs/concepts/storage/volumes/#hostpath-fileorcreate-example
https://stackoverflow.com/questions/71384194
复制相似问题