Apache spark 如何使用Kubernetes在Spark中设置短暂存储

Apache spark 如何使用Kubernetes在Spark中设置短暂存储,apache-spark,kubernetes,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, executo

使用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

看起来您的作业可能正在临时存储器的pod中请求
0
。如果查看,您将看到临时存储是节点上根磁盘的一部分。因此,您可以尝试指定装载

我的猜测是,PVC发生了一些事情,容器正在使用临时卷,或者如果指定卷,则可能需要一个hostPath和一个PVC(对于
/mnt/tmp
)。我想检查一下:

$ kubectl describe pvc
$ kubectl describe pv

在撰写本文时,中没有发布临时存储限制Kubernetes的选项。

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

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

$kubectl get-pod spark-kub-1558558662866-exec-67-o json | jq'.spec.containers[0].资源.请求.“临时存储”'
“1Gi”

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

我尝试将每个执行器的/tmp映射到具有hostPath的节点上的本地卷,但似乎没有效果。您认为如果我的PCV上没有足够的空间,会发生这种情况吗,据我所知,SPARK_LOCAL_DIRS连接到一个emptyDir,需要临时存储。是否有方法更改此行为并将其附加到主机路径?能否为部署提供.yaml文件?API告知
节点资源不足
,您是否尝试附加更多空间?问题是执行器吊舱在根
/var/data/spark-1b1495d5-ad6d-4a56-92cd-b10eb81e28fe
中创建一个emptyDir来存储计算结果。我们节点的根确实有足够的空间,我们需要将
SPARK\u LOCAL\u DIRS
设置到另一个位置,但我们不知道怎么做?
apiVersion: v1
kind: LimitRange
metadata:
  name: ephemeral-storage-limit-range
spec:
  limits:
  - default:
      ephemeral-storage: 8Gi
    defaultRequest:
      ephemeral-storage: 1Gi
    type: Container