首页 > 解决方案 > 无法将卷挂载到 spark.kubernetes.executor

问题描述

我正在尝试使用 kubernetes 在 spark 集群模式下从服务器读取文件,因此我将文件放在所有工作人员上,并使用
val conf = new SparkConf().setAppName("sparksetuptest") .set("spark. kubernetes.driver.volumes.hostPath.host.mount.path", "/file-directory")

在这里一切正常,但是当我执行时,它显示在特定位置找不到该文件。所以我用 .set("spark.kubernetes.executor.volumes.hostPath.host.mount.path", "/file-directory") 将目录挂载到执行器但现在我无法执行它卡在一个永无止境的程序在获取数据的同时进行处理。

请提出一些建议,以便我可以使用执行程序挂载我的目录并读取该文件。

标签: scalaapache-sparkkubernetesserverdata-science

解决方案


这是来自nfs-example 的示例

spark.kubernetes.driver.volumes.nfs.images.options.server=example.com
spark.kubernetes.driver.volumes.nfs.images.options.path=/data

我认为您需要声明要挂载的路径,options.path并且spark.kubernetes.driver.volumes.[VolumeType].[VolumeName].mount.path是容器中的挂载路径

例如:

如果我想在 k8s 的节点上挂载到带有 VolumeName/home/lemon/data的 docker 容器的路径,那么/dataexepv

conf.set("spark.kubernetes.executor.volumes.hostPath.exepv.mount.path","/data")
conf.set("spark.kubernetes.executor.volumes.hostPath.exepv.options.path", "/home/lemon/data")

/data在此之后,您可以访问执行程序容器中的路径


推荐阅读