java - Spark Kubernetes - 使用 --files 或 spark.files 将配置文件从驱动程序复制到执行程序时出现 FileNotFoundException
问题描述
我们正在将 Spark 工作负载从 Cloudera 迁移到 Kubernetes。
出于演示目的,我们希望在集群模式下使用 spark-submit 在 minikube 集群中运行我们的 spark 作业之一。
我想使用 spark.file conf 将类型安全的配置文件传递给我的执行程序(我也尝试过 --files )。配置文件已在构建时复制到 /opt/spark/conf 目录中的 spark docker 映像。
然而,当我提交我的工作时,我有一个java.io.FileNotFoundException: File file:/opt/spark/conf/application.conf does not exist。
我的理解是 spark.files 将文件从驱动程序复制到执行程序的工作目录。
我错过了什么吗?谢谢您的帮助。
这是我的 spark-submit 命令
spark-submit \
--master k8s://https://192.168.49.2:8443 \
--driver-memory ${SPARK_DRIVER_MEMORY} --executor-memory ${SPARK_EXECUTOR_MEMORY} \
--deploy-mode cluster \
--class "${MAIN_CLASS}" \
--conf spark.driver.defaultJavaOptions="-Dconfig.file=local://${POD_CONFIG_DIR}/application.conf $JAVA_ARGS" \
--conf spark.files="file:///${POD_CONFIG_DIR}/application.conf,file:///${POD_CONFIG_DIR}/tlereg.properties" \
--conf spark.executor.defaultJavaOptions="-Dconfig.file=local://./application.conf" \
--conf spark.executor.instances=5 \
--conf spark.kubernetes.container.image=$SPARK_CONTAINER_IMAGE \
--conf spark.kubernetes.authenticate.driver.serviceAccountName=spark \
--conf spark.kryoserializer.buffer.max=512M \
--conf spark.driver.maxResultSize=8192M \
--conf spark.kubernetes.authenticate.caCertFile=$HOME/.minikube/ca.crt \
--conf spark.executor.extraClassPath="./" \
local:///path/to/uber/jar.jar \
"${PROG_ARGS[@]}" > $LOG_FILE 2>&1
解决方案
我已经想通了。spark-submit
向 kubernetes master 的 api-server 发送请求以创建驱动程序 pod。configmap 卷安装到驱动程序的 pod 上mountPath: /opt/spark/conf
,它会覆盖位于 docker 容器中该路径的我的配置文件。解决方法:在 Dockerfile 中将 /opt/spark/conf 编辑为 /opt/spark/config,以便从后者复制我的配置文件。
推荐阅读
- java - 如何在运行 Aeron 示例时设置 Aeron 订阅者和发布者数量的限制
- python - 在 Python 中迭代字典时出错
- javascript - Html / javascript - 下拉选择不适用于提交按钮
- java - 将数据从 Firebase 检索到 Recycler View
- sql - 使用 LIKE %x% 的 Access SQL 查询中出现意外结果
- arrays - 我将如何制作 3D 棋盘阵列
- r - 总结具有不同 nrow 长度组的函数的组
- python - 运行烧瓶项目的问题
- php - 为什么 rtrim 删除尾随零?
- python - 如何让 tkinter mainloop 等待 matplotlib 点击事件