Skip to content
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

[SPARK-24960][K8S] explicitly expose ports on driver container #21884

Closed
wants to merge 1 commit into from

Conversation

adelbertc
Copy link

@adelbertc adelbertc commented Jul 26, 2018

https://issues.apache.org/jira/browse/SPARK-24960

What changes were proposed in this pull request?

Expose ports explicitly in the driver container. The driver Service created expects to reach the driver Pod at specific ports which before this change, were not explicitly exposed and would likely cause connection issues (see apache-spark-on-k8s#617).

This is a port of the original PR created in the now-deprecated Kubernetes fork: apache-spark-on-k8s#618

How was this patch tested?

Failure in apache-spark-on-k8s#617 reproduced on Kubernetes 1.6.x and 1.8.x. Built the driver image with this patch and observed fixed apache-spark-on-k8s#617 on Kubernetes 1.6.x.

@felixcheung
Copy link
Member

can you update the format of the title and description as described here
"Pull Request" in https://spark.apache.org/contributing.html

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from 48d07c5 to c537779 Compare July 27, 2018 17:15
@adelbertc adelbertc changed the title k8s: explicitly expose ports on driver container [Scheduler][K8s]: explicitly expose ports on driver container Jul 27, 2018
@adelbertc
Copy link
Author

@felixcheung Done I think, is that OK?

@mccheah
Copy link
Contributor

mccheah commented Jul 27, 2018

This needs a Spark ticket. I also don't think pods specifically have to expose ports. My understanding was that the ports field on the pod was only to assign ports names, so that the ports can be referenced by name and not by number on service objects.

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from c537779 to a2f2667 Compare July 28, 2018 19:33
@adelbertc adelbertc changed the title [Scheduler][K8s]: explicitly expose ports on driver container [SPARK-24960][Kubernetes] explicitly expose ports on driver container Jul 28, 2018
@adelbertc
Copy link
Author

@mccheah Done https://issues.apache.org/jira/browse/SPARK-24960

Re: Exposing ports, my understanding of Kubernetes' networking model is it is possible for a cluster to be setup such that Pod ports are closed, perhaps as a security measure. At least in our Kubernetes cluster (tested both on 1.6.x and 1.8.x) the SparkPi example failed with a connection error without this change, and succeeded after. (I've also added this information to the JIRA)

val driverContainer = new ContainerBuilder(pod.container)
.withName(DRIVER_CONTAINER_NAME)
.withImage(driverContainerImage)
.withImagePullPolicy(conf.imagePullPolicy())
.addNewPort()
Copy link
Contributor

Choose a reason for hiding this comment

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

The driver UI port should also be explicitly exposed.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@mccheah
Copy link
Contributor

mccheah commented Jul 30, 2018

At least in our Kubernetes cluster (tested both on 1.6.x and 1.8.x) the SparkPi example failed with a connection error without this change, and succeeded after. (I've also added this information to the JIRA)

@adelbertc Just to clarify, by "succeeded later", do you mean after this change was applied? Or do you mean "succeeded later" as in a retry worked with the same code?

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from a2f2667 to 1fc6faa Compare July 31, 2018 00:07
@adelbertc
Copy link
Author

@mccheah After the change was applied

Copy link
Contributor

@liyinan926 liyinan926 left a comment

Choose a reason for hiding this comment

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

LGTM.

@mccheah
Copy link
Contributor

mccheah commented Jul 31, 2018

Can you quickly change [Kubernetes] to [K8S] in the PR title? Will merge after that is done.

@mccheah
Copy link
Contributor

mccheah commented Jul 31, 2018

Actually can you also update the unit test? Thanks!

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from 1fc6faa to 9000a2f Compare July 31, 2018 21:58
@adelbertc adelbertc changed the title [SPARK-24960][Kubernetes] explicitly expose ports on driver container [SPARK-24960][K8S] explicitly expose ports on driver container Jul 31, 2018
@adelbertc
Copy link
Author

@mccheah Done and done

@@ -87,6 +87,10 @@ class BasicDriverFeatureStepSuite extends SparkFunSuite {
assert(configuredPod.container.getImage === "spark-driver:latest")
assert(configuredPod.container.getImagePullPolicy === CONTAINER_IMAGE_PULL_POLICY)

val expectedPortNames = Set(DRIVER_PORT_NAME, BLOCK_MANAGER_PORT_NAME, UI_PORT_NAME)
val foundPortNames = configuredPod.container.getPorts.asScala.map(port => port.getName).toSet
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to be safer here and check the protocol and the target port numbers. You can just compare against a list of expected ContainerPort objects - Kubernetes objects in our Java API have been good about giving us sane equals implementations.

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from 9000a2f to 4215fc2 Compare August 1, 2018 03:16
@adelbertc
Copy link
Author

@mccheah Done - unfortunately I seem to be having some issues running tests locally, I assume there is some CI checking this as well?

@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

ok to test


def containerPort(name: String, portNumber: Int): ContainerPort = {
val port = new ContainerPort()
port.setName(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the indention here is incorrect.

Copy link
Author

Choose a reason for hiding this comment

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

@liyinan926 Is it? It looks OK on my end I think unless I'm missing something

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry my bad, I misread it as something like:

return new ContainerPort()
  .setName(name)
 ...

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/1565/

@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

jenkins, test this please

@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

(Not sure why the unit test build didn't run just now, only the integration tests did)

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/1575/

@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

@shaneknapp the unit test build doesn't seem to be triggering on this PR, any idea as to what's going on?

@@ -203,4 +212,12 @@ class BasicDriverFeatureStepSuite extends SparkFunSuite {
"spark.files" -> "https://localhost:9000/file1.txt,/opt/spark/file2.txt")
assert(additionalProperties === expectedSparkConf)
}

def containerPort(name: String, portNumber: Int): ContainerPort = {
val port = new ContainerPort()
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ContainerPortBuilder

Copy link
Author

Choose a reason for hiding this comment

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

Done

@shaneknapp
Copy link
Contributor

jenkins test this please

@shaneknapp
Copy link
Contributor

@mccheah the tests didn't run because you're not an admin for the regular (non-k8s) pull request builder.

i added you to that list and you'll be able to trigger tests now.

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/1581/

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

Test build #93901 has finished for PR 21884 at commit 4215fc2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@adelbertc adelbertc force-pushed the k8s-expose-driver-ports branch from 4215fc2 to 66d1e62 Compare August 1, 2018 20:48
@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

Thanks @shaneknapp, I'll merge this now.

@mccheah
Copy link
Contributor

mccheah commented Aug 1, 2018

Thanks @adelbertc for the contribution!

@asfgit asfgit closed this in f5113ea Aug 1, 2018
@SparkQA
Copy link

SparkQA commented Aug 1, 2018

@SparkQA
Copy link

SparkQA commented Aug 1, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/1583/

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.

Trouble running SparkPi example on Kubernetes 1.8.x
6 participants