I set up a Spark 2.3.1 cluster on kubernetes, however, I have trouble sending a sample SparkPi job to it:

The submit script I'm using:

bin/spark-submit \
    --master k8s:// \
    --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

but get

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)

My guess is that it cannot access k8s apiserver. But I don't understand why. I use --conf serviceAccountName and RBAC is fully configured as in the above url.

All spark pods use the spark serviceAccountName, defined as

apiVersion: v1
kind: ServiceAccount
  name: spark
  namespace: default
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
  name: spark-role
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: edit
- kind: ServiceAccount
  name: spark
  namespace: default
  • Did you solve the problem? Jun 19 '21 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.