我在 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 serviceAccountName
并完全配置了 RBAC,如上面的 url 所示。
所有 spark pod 都使用spark
serviceAccountName,定义为
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