简体   繁体   English

如何在 Kubernetes 上向 Spark 发送作业。 无法实例化外部调度程序

[英]How to send a job to Spark on Kubernetes. External scheduler cannot be instantiated

I have started a Minikube cluster but when I make spark-submit, job get an error.我已经启动了一个 Minikube 集群,但是当我进行 spark-submit 时,作业出错。

My command:我的命令:

bin/spark-submit --master k8s://https://192.168.99.101:8443 --deploy-mode cluster --name spark-test --class org.apache.spark.examples.SparkPi --conf spark.executor.instances=5 --conf spark.kubernetes.container.image=spark local:///opt/spark/examples/jars/spark-examples_2.11-2.4.0.jar

And I get the following error:我收到以下错误:

2019-03-13 18:26:57 ERROR SparkContext:91 - Error initializing SparkContext. 2019-03-13 18:26:57 错误 SparkContext:91 - 初始化 SparkContext 时出错。 org.apache.spark.SparkException: External scheduler cannot be instantiated at org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:2794) ...30 more Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://kubernetes.default.svc/api/v1/namespaces/default/pods/spark-test-1552501611130-driver . org.apache.spark.SparkException: 外部调度程序不能在 org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:27​​94) ... 30 更多 引起:io. fabric8.kubernetes.client.KubernetesClientException:执行失败:GET at: https://kubernetes.default.svc/api/v1/namespaces/default/pods/spark-test-1552501611130-driver Message: Forbidden!Configured service account doesn't have access.消息:禁止!配置的服务帐户无权访问。 Service account may have been revoked.服务帐户可能已被撤销。 pods "spark-test-1552501611130-driver" is forbidden: User "system:serviceaccount:default:default" cannot get resource "pods" in API group "" in the namespace "default". pods“spark-test-1552501611130-driver”被禁止:用户“system:serviceaccount:default:default”无法在命名空间“default”的API组“”中获取资源“pods”。 ... 30 more ... 30 多个

You need to create ServiceAccount in Kubernetes.您需要在 Kubernetes 中创建 ServiceAccount。 It can be done if you download the YAML config from this link如果您从此链接下载 YAML 配置,则可以完成

And then run然后运行

kubectl apply -f spark-rbac.yaml

The YAML file will create the namespace and ServiceAccount, which are needed for Spark on Kubernetes. YAML 文件将创建命名空间和 ServiceAccount,这是 Spark on Kubernetes 所需的。 However, you also need to modify your spark-submit command to be like:但是,您还需要将 spark-submit 命令修改为:

bin/spark-submit --master k8s://https://192.168.99.101:8443 --deploy-mode cluster --name spark-test --class org.apache.spark.examples.SparkPi \
--conf spark.kubernetes.namespace=spark \
--conf spark.kubernetes.authenticate.driver.serviceAccountName=spark-sa \
--conf spark.executor.instances=5 \
--conf spark.kubernetes.container.image=spark local:///opt/spark/examples/jars/spark-examples_2.11-2.4.0.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM