<p>I have started a Minikube cluster but when I make spark-submit, job get an error. </p>

<p>My command: </p>

<pre><code>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
</code></pre>

<p>And I get the following error: </p>

<blockquote>
  <p>2019-03-13 18:26:57 ERROR SparkContext:91 - Error initializing
  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:
  <a href="https://kubernetes.default.svc/api/v1/namespaces/default/pods/spark-test-1552501611130-driver" rel="nofollow noreferrer">https://kubernetes.default.svc/api/v1/namespaces/default/pods/spark-test-1552501611130-driver</a>.
  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".  ... 30 more</p>
</blockquote>

Sergio Fonseca
<p>You need to create ServiceAccount in Kubernetes. It can be done if you download the YAML config from this <a href="https://github.com/apache/spark/blob/885aa553c5e8f478b370f8a733102b67f6cd2d99/resource-managers/kubernetes/integration-tests/dev/spark-rbac.yaml" rel="nofollow noreferrer">link</a></p>

<p>And then run </p>

<pre><code>kubectl apply -f spark-rbac.yaml
</code></pre>

<p>The YAML file will create the namespace and ServiceAccount, which are needed for Spark on Kubernetes.
However, you also need to modify your spark-submit command to be like:</p>

<pre><code>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
</code></pre>
