如何使用Kubernetes在Spark中设置临时存储

时间:2018-11-30 14:30:34

标签: apache-spark kubernetes

在使用Kubernetes集群运行Spark作业时,出现以下错误:

2018-11-30 14:00:47 INFO  DAGScheduler:54 - Resubmitted ShuffleMapTask(1, 58), so marking it as still running.
2018-11-30 14:00:47 WARN  TaskSetManager:66 - Lost task 310.0 in stage 1.0 (TID 311, 10.233.71.29, executor 3): ExecutorLostFailure (executor 3 exited caused by one of the running tasks) Reason: 
The executor with id 3 exited with exit code -1.
The API gave the following brief reason: Evicted
The API gave the following message: The node was low on resource: ephemeral-storage. Container executor was using 515228Ki, which exceeds its request of 0. 
The API gave the following container statuses:

如何配置作业,以便我们可以增加每个容器的临时存储大小?

我们使用spark 2.4.0和Kubernetes 1.12.1

spark提交选项如下

--conf spark.local.dir=/mnt/tmp \
--conf spark.executor.instances=4 \
--conf spark.executor.cores=8 \
--conf spark.executor.memory=100g \
--conf spark.driver.memory=4g \
--conf spark.driver.cores=1 \
--conf spark.kubernetes.memoryOverheadFactor=0.1 \
--conf spark.kubernetes.container.image=spark:2.4.0 \
--conf spark.kubernetes.namespace=visionlab \
--conf spark.kubernetes.authenticate.driver.serviceAccountName=spark \
--conf spark.kubernetes.container.image.pullPolicy=Always \
--conf spark.kubernetes.driver.volumes.persistentVolumeClaim.myvolume.options.claimName=pvc \
--conf spark.kubernetes.driver.volumes.persistentVolumeClaim.myvolume.mount.path=/mnt/ \
--conf spark.kubernetes.driver.volumes.persistentVolumeClaim.myvolume.mount.readOnly=false \
--conf spark.kubernetes.executor.volumes.persistentVolumeClaim.myvolume.options.claimName=pvc \
--conf spark.kubernetes.executor.volumes.persistentVolumeClaim.myvolume.mount.path=/mnt/ \
--conf spark.kubernetes.executor.volumes.persistentVolumeClaim.myvolume.mount.readOnly=false

2 个答案:

答案 0 :(得分:0)

看起来您的工作可能是在临时存储区的Pod中请求0。如果查看docs,您会发现临时存储是节点上根磁盘的一部分。因此,您可以尝试指定一个hostPath安装。

我的猜测是PVC正在发生某些事情,并且该容器正在使用临时卷,或者如果您要指定卷,则可能同时需要hostPath和PVC(用于/mnt/tmp) 。我会检查:

$ kubectl describe pvc
$ kubectl describe pv

在撰写本文时,Spark Driver中没有选择发布Kubernetes Request来限制临时存储。

答案 1 :(得分:0)

正如@Rico所说,从spark 2.4.3开始,无法通过驱动程序配置来设置临时存储限制。相反,您可以使用LimitRange为命名空间中的所有新容器设置临时存储限制:

apiVersion: v1
kind: LimitRange
metadata:
  name: ephemeral-storage-limit-range
spec:
  limits:
  - default:
      ephemeral-storage: 8Gi
    defaultRequest:
      ephemeral-storage: 1Gi
    type: Container

这会将默认值应用于在LimitRange命名空间中创建的执行程序:

$ kubectl get pod spark-kub-1558558662866-exec-67 -o json | jq '.spec.containers[0].resources.requests."ephemeral-storage"'
"1Gi"

这有点麻烦,因为它将默认值应用于名称空间中的所有容器,但是如果您的工作量是统一的,则可能是一个解决方案。