Spark:Pi 範例在叢集 k8s 模式下拋出 SocketTimeoutException

Spark:Pi 範例在叢集 k8s 模式下拋出 SocketTimeoutException

我在 kubernetes 上設定了 Spark 2.3.1 集群,但是,我在向其發送範例 SparkPi 作業時遇到了問題:

我正在使用的提交腳本:

bin/spark-submit \
    --master k8s://https://10.0.15.7:7077 \
    --deploy-mode cluster \
    --name spark-pi \
    --class org.apache.spark.examples.SparkPi \
    --conf spark.kubernetes.container.image=gcr.io/my-project/spark:spark-test \
    --conf spark.kubernetes.authenticate.driver.serviceAccountName=spark \
    --conf spark.executor.instances=3 \
    local:///opt/spark/examples/jars/spark-examples_2.11-2.3.1.jar 1000

但得到

Exception in thread "main" io.fabric8.kubernetes.client.KubernetesClientException: Failed to start websocket
at io.fabric8.kubernetes.client.dsl.internal.WatchConnectionManager$2.onFailure(WatchConnectionManager.java:194)
...
Caused by: java.net.SocketTimeoutException: timeout
    at okio.Okio$4.newTimeoutException(Okio.java:230)
    ... 
Caused by: java.net.SocketException: Socket closed
    at java.net.SocketInputStream.read(SocketInputStream.java:204)
...

我的猜測是它無法存取k8s apiserver。但我不明白為什麼。我使用的--conf serviceAccountNameRBAC 已完全配置,如上面的 url 所示。

所有 Spark pod 都使用sparkserviceAccountName,定義為

apiVersion: v1
kind: ServiceAccount
metadata:
  name: spark
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: spark-role
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: edit
subjects:
- kind: ServiceAccount
  name: spark
  namespace: default

相關內容