Skip to content

[SPARK-23078] [CORE] [K8s] allow Spark Thrift Server to run in Kubernetes Cluster mode #20272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ozzieba
Copy link

@ozzieba ozzieba commented Jan 15, 2018

What changes were proposed in this pull request?

allow Spark Thrift Server to run in Kubernetes Cluster mode

How was this patch tested?

Edit: see apache-spark-on-k8s/spark-integration#38

@foxish
Copy link
Contributor

foxish commented Jan 15, 2018

@ozzieba, can we add a test to our integration test set to ensure this works? It's rather late in the Spark 2.3 release, and I'd be apprehensive about adding things that haven't been extensively tested.

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add [K8s] to the PR title.
we really need to test this...

@@ -328,7 +328,7 @@ object SparkSubmit extends CommandLineUtils with Logging {
printErrorAndExit("Cluster deploy mode is not applicable to Spark shells.")
case (_, CLUSTER) if isSqlShell(args.mainClass) =>
printErrorAndExit("Cluster deploy mode is not applicable to Spark SQL shell.")
case (_, CLUSTER) if isThriftServer(args.mainClass) =>
case (_, CLUSTER) if (clusterManager != KUBERNETES) && isThriftServer(args.mainClass) =>
printErrorAndExit("Cluster deploy mode is not applicable to Spark Thrift server.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't dug through but this might break if there has been any assumption that thrift is not running in cluster mode?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on what might go wrong? I have been using it successfully to run queries, is there anything else that should be tested?

@ozzieba
Copy link
Author

ozzieba commented Jan 17, 2018

@foxish @felixcheung I wrote a test, but I'm having trouble with Minikube on Windows, and I can't run on a remote Kubernetes cluster. I'll try to get minikube running in a different way and keep you updated

@ozzieba
Copy link
Author

ozzieba commented Jan 19, 2018

@foxish @felixcheung Now verified my test runs successfully apache-spark-on-k8s/spark-integration#38

@ozzieba ozzieba changed the title [SPARK-23078] [CORE] allow Spark Thrift Server to run in Kubernetes Cluster mode [SPARK-23078] [CORE] [k8s] allow Spark Thrift Server to run in Kubernetes Cluster mode Jan 19, 2018
@ozzieba ozzieba changed the title [SPARK-23078] [CORE] [k8s] allow Spark Thrift Server to run in Kubernetes Cluster mode [SPARK-23078] [CORE] [K8s] allow Spark Thrift Server to run in Kubernetes Cluster mode Jan 19, 2018
@jiangxb1987
Copy link
Contributor

cc @liyinan926 Do you have some time to verify this?

@foxish
Copy link
Contributor

foxish commented Jan 24, 2018

@jiangxb1987 Is there any specific owner of the thrift server that we can ping here? The testing looks good - so, all we're waiting for is confirmation from them on the original intent behind disallowing the thrift server in cluster mode; and if this is safe.

@ozzieba
Copy link
Author

ozzieba commented Jan 24, 2018

@foxish per SPARK-5176 and the associated PR, it seems there was a technical issue with spark-internal that wouldn't allow Thrift Server to run on YARN cluster mode. It was deemed a minor fix at the time, so perhaps the changes were made in the meantime. Regardless, it does now work at least on Kubernetes

@ozzieba
Copy link
Author

ozzieba commented Jan 24, 2018

@andrewor14 @liancheng can you chime in?

@jiangxb1987
Copy link
Contributor

IIUC there was a issue in launching Thrift Server on YARN cluster mode, and I'm not sure whether it has been fixed (maybe @jerryshao can kindly check that?) Anyway that is not a problem on Spark side, therefore should not affect the Kubernetes cluster mode.

@foxish
Copy link
Contributor

foxish commented Jan 29, 2018 via email

@jerryshao
Copy link
Contributor

IIUC there was a issue in launching Thrift Server on YARN cluster mode, and I'm not sure whether it has been fixed (maybe @jerryshao can kindly check that?)

Sorry I cannot remember the issue. Yarn cluster mode doesn't support thriftserver.

@vanzin
Copy link
Contributor

vanzin commented Feb 1, 2018

So how are you expected to contact the thrift server after it's up, and even figure out where it started? Isn't the container unreachable from the outside world unless you do some port mapping on the host?

I see part of that is explained in the bug, but sounds like this change needs better user documentation.

@ozzieba
Copy link
Author

ozzieba commented Feb 2, 2018

@vanzin In general Kubernetes makes this super easy:

  • The most basic workflow is to use the driver pod name (which is in the output of Spark Submit, or can be found with kubectl get pods), and run kubectl port-forward spark-app-driver-podname 31416:10000, which will automatically forward localhost:31416 to the pod's port 10000. Any jdbc client can then be used to query jdbc:hive2://localhost:31416. This is the approach I took in the integration tests linked above.
  • Alternatively, any other application on the cluster can simply use spark-app-driver-podname:10000, which will be resolved by kube-dns.
  • For persistent external access one can run kubectl expose pod spark-app-driver-podname --type=NodePort --port 10000 to create a Kubernetes Service which will accept connections on a particular port of every node on the cluster and send them to the driver's port 10000.
  • On a cloud environment, using type=LoadBalancer in the above will create a global load balancer that can be used to access Thrift from across the Internet.
  • One can also define a service that automatically selects the driver using a user-specified label (eg bin/spark-submit.sh --conf spark.kubernetes.driver.label.mythriftserver=true followed by kubectl expose pod --selector=mythriftserver=true)

Perhaps the key point is that these are all core Kubernetes features, and not specific to Spark in any way. Users familiar with Kubernetes should be able to find the approach that works best for their environment and use case.

@vanzin
Copy link
Contributor

vanzin commented Feb 2, 2018

Great, how about explaining that in some place more visible to Spark users than a PR on github.

@ozzieba
Copy link
Author

ozzieba commented Feb 2, 2018

Ultimately I see this as being in the realm of Kubernetes knowledge, rather than Spark knowledge. These features are well-documented in Kubernetes documentation, and I am not sure there's a need to replicate that here. For a user new to both Spark and Kubernetes a combined tutorial could certainly be helpful, but that should likely be a more comprehensive undertaking.

@vanzin
Copy link
Contributor

vanzin commented Feb 2, 2018

It's really not that much work to write a couple of sentences about this in the running-on-k8s docs, even if you're just pointing people to the kubernetes documentation. Is that really so controversial?

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: Jenkins hasn't run on this.

@ah-
Copy link

ah- commented May 21, 2018

Is anyone still looking at this? It seems like it should just work?

@nrchakradhar
Copy link

Its working for us in our test environment. No issues so far. Only thing to take care is the clean-up of the driver manually when the thrift server is re-installed or started due to any reason.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@felixcheung
Copy link
Member

Is this aligned with the "in cluster client"? @foxish @mccheah

@liyinan926
Copy link
Contributor

@felixcheung I think yes and with #21748, users should be able to run the Thrift server in a pod.

@srowen
Copy link
Member

srowen commented Jul 27, 2018

If this can get a rebase, and maybe a few sentences in the k8s docs, I'll merge.

@felixcheung
Copy link
Member

still need to run tests #20272 (review)

@deveshk0
Copy link

deveshk0 commented Aug 1, 2018

I have built spark with the same changes for thrift server. It is running fine for me.

@deveshk0
Copy link

is this coming with spark 2.4 ?

@suryag10
Copy link

If this can get a rebase, and maybe a few sentences in the k8s docs, I'll merge.

Hi, I had rebased this patch to the latest master and this patch was missing another fix to run the STS on K8S cluster mode. Following is the PR

#22433

Can you please review this once?

@vanzin
Copy link
Contributor

vanzin commented Dec 21, 2018

I'm closing this for now since there's another PR, and also I haven't seen an answer to my questions on the bug.

@vanzin vanzin closed this Dec 21, 2018
@piyush9194
Copy link

Is this feature available in spark 2.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.