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-24434][K8S] pod template files #22146

Closed
wants to merge 57 commits into from

Conversation

onursatici
Copy link
Contributor

@onursatici onursatici commented Aug 20, 2018

What changes were proposed in this pull request?

New feature to pass podspec files for driver and executor pods.

How was this patch tested?

new unit and integration tests

  • more overwrites in integration tests
  • invalid template integration test, documentation

@mccheah
Copy link
Contributor

mccheah commented Aug 20, 2018

@skonto @erikerlandson

@erikerlandson
Copy link
Contributor

Jenkins, OK to test

@erikerlandson
Copy link
Contributor

Thanks @onursatici!
Can you please resolve merge conflicts (rebase?), so CI can build it?

@yifeih
Copy link
Contributor

yifeih commented Aug 22, 2018

@onursatici is also away this week, so I discussed with him and have taken over the PR

This v0 implementation simply starts with the pod template instead of an empty pod, applying any sparkConf overrides, either user-specified or default values, on top of the template. It currently doesn't warn upon overriding anything that's also specified in the pod template

Copy link
Contributor

@mccheah mccheah left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Some comments. Also might want an integration test in KubernetesSuite?

try {
val pod = kubernetesClient.pods().load(templateFile).get()
val container = pod.getSpec.getContainers.asScala
.filter(_.getName == containerName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use require(...exists)

require(conf.get(Config.KUBERNETES_EXECUTOR_PODTEMPLATE_FILE).isDefined)
val podTemplateFile = conf.get(Config.KUBERNETES_EXECUTOR_PODTEMPLATE_FILE).get
val podWithVolume = new PodBuilder(pod.pod)
.editSpec()
Copy link
Contributor

Choose a reason for hiding this comment

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

Match the indentation here with the indentation style down below.

.build()

val containerWithVolume = new ContainerBuilder(pod.container)
.withVolumeMounts(new VolumeMountBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

addNewVolumeMount()

val sparkPod = KubernetesUtils.loadPodFromTemplate(
kubernetesClient,
file,
Constants.DRIVER_CONTAINER_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unclear if these container names should be configurable.

Copy link
Contributor

Choose a reason for hiding this comment

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

You may import org.apache.spark.deploy.k8s.Constants._ at the top of the file and then not need the Constants prefix here.

Copy link
Contributor

Choose a reason for hiding this comment

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

They're not configurable currently. We should probably make them configurable since I'd imagine people would want to rely on these names being consistent

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also make the driver container name configurable.


import org.apache.spark.{SparkConf, SparkException}
import org.apache.spark.deploy.k8s._
import org.apache.spark.deploy.k8s.features._
Copy link
Contributor

Choose a reason for hiding this comment

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

Undo these import changes. Keep the ordering correct, but import each class individually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping here

provideTemplateVolumeStep: (KubernetesConf[_ <: KubernetesRoleSpecificConf]
=> TemplateVolumeStep) =
new TemplateVolumeStep(_),
provideInitialSpec: KubernetesConf[KubernetesDriverSpecificConf]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not provideInitialPod to be consistent with the executor builder?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's because we need the KubernetesDriverSpec object instead of just the pod? which includes things like the entire sparkConf map

Copy link
Contributor

Choose a reason for hiding this comment

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

You can make the initial pod and wrap it in the KubernetesDriverSpec object.

.editSpec()
.addNewVolume()
.withName(Constants.POD_TEMPLATE_VOLUME)
.withHostPath(new HostPathVolumeSource(podTemplateFile))
Copy link
Contributor

Choose a reason for hiding this comment

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

hostPath is not the correct volume type here. Instead, do the following:

  • Override getAdditionalKubernetesResources() with the following:
    1. Load the contents of the template file from this process's local disk into a UTF-8 String
    2. Create and return a ConfigMap object containing the contents of that config map, with some given key
  • In configurePod, add the config map as a volume in the pod spec, and add a volume mount pointing to that volume as done here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also change the name of this class to something like PodTemplateConfigMapStep to make it clear that is uses a ConfigMap to ship the template file?


import org.apache.spark.deploy.k8s._

private[spark] class TemplateVolumeStep(
Copy link
Contributor

Choose a reason for hiding this comment

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

So this pushes the pod spec yml from the spark-submit process's local disk up to the driver pod. It may be worthwhile to support specifying the file as a location in the driver pod that hasn't been mounted by spark-submit, but I think doing it this way is fine for now.

@onursatici onursatici changed the title [WIP][SPARK-24434][K8S] pod template files [SPARK-24434][K8S] pod template files Aug 22, 2018
@mccheah
Copy link
Contributor

mccheah commented Aug 22, 2018

Jenkins, ok to test

@mccheah
Copy link
Contributor

mccheah commented Aug 22, 2018

@yifeih can we also modify docs/running-on-kubernetes.md and have a section specific to using this feature? Mark it as experimental also.

@SparkQA
Copy link

SparkQA commented Aug 22, 2018

@SparkQA
Copy link

SparkQA commented Aug 22, 2018

Test build #95112 has finished for PR 22146 at commit 8ef756e.

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

@shaneknapp
Copy link
Contributor

test this please

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

Test build #98231 has finished for PR 22146 at commit 80b56c1.

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

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

Test build #98233 has finished for PR 22146 at commit 80b56c1.

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

@erikerlandson
Copy link
Contributor

thanks @shaneknapp !

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

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

@mccheah
Copy link
Contributor

mccheah commented Oct 29, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

Test build #98237 has finished for PR 22146 at commit 80b56c1.

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

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

@SparkQA
Copy link

SparkQA commented Oct 29, 2018

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

@erikerlandson
Copy link
Contributor

@mccheah integration testing is passing with the latest container selection policy, good to merge?

Copy link
Contributor

@mccheah mccheah left a comment

Choose a reason for hiding this comment

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

Only two more nits and then will merge.

@skonto @aditanase FYI. Are any of your unresolved comments blocking?

If we don't get other feedback here we will probably merge in short order.

// Pod spec templates
val EXECUTOR_POD_SPEC_TEMPLATE_FILE_NAME = "pod-spec-template.yml"
val EXECUTOR_POD_SPEC_TEMPLATE_MOUNTHPATH = "/opt/spark/pod-template"
val POD_TEMPLATE_VOLUME = "podspec-volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ping here


import org.apache.spark.{SparkConf, SparkException}
import org.apache.spark.deploy.k8s._
import org.apache.spark.deploy.k8s.features._
Copy link
Contributor

Choose a reason for hiding this comment

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

Ping here

@SparkQA
Copy link

SparkQA commented Oct 30, 2018

@SparkQA
Copy link

SparkQA commented Oct 30, 2018

Test build #98273 has finished for PR 22146 at commit 3707e6a.

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

@SparkQA
Copy link

SparkQA commented Oct 30, 2018

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

@mccheah
Copy link
Contributor

mccheah commented Oct 30, 2018

Ok I'm going to merge this into master. Thanks everyone for the feedback. Follow up discussions around validation can be addressed in follow up patches.

@asfgit asfgit closed this in f6cc354 Oct 30, 2018
@aditanase
Copy link
Contributor

@mccheah agreed on all points, sorry for taking this long to respond. Happy to see this merged in, can't wait to take it for a spin!

srowen pushed a commit that referenced this pull request Jan 8, 2019
## What changes were proposed in this pull request?

Adding docs for an enhancement that came in late in this PR: #22146
Currently the docs state that we're going to use the first container in a pod template, which was the implementation for some time, until it was improved with 2 new properties.

## How was this patch tested?

I tested that the properties work by combining pod templates with client-mode and a simple pod template.

Please review http://spark.apache.org/contributing.html before opening a pull request.

Closes #23155 from aditanase/k8s-readme.

Authored-by: Adrian Tanase <atanase@adobe.com>
Signed-off-by: Sean Owen <sean.owen@databricks.com>
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
## What changes were proposed in this pull request?

New feature to pass podspec files for driver and executor pods.

## How was this patch tested?
new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
## What changes were proposed in this pull request?

Adding docs for an enhancement that came in late in this PR: apache#22146
Currently the docs state that we're going to use the first container in a pod template, which was the implementation for some time, until it was improved with 2 new properties.

## How was this patch tested?

I tested that the properties work by combining pod templates with client-mode and a simple pod template.

Please review http://spark.apache.org/contributing.html before opening a pull request.

Closes apache#23155 from aditanase/k8s-readme.

Authored-by: Adrian Tanase <atanase@adobe.com>
Signed-off-by: Sean Owen <sean.owen@databricks.com>
Udbhav30 pushed a commit to Udbhav30/spark that referenced this pull request May 8, 2019
New feature to pass podspec files for driver and executor pods.

new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
markterm pushed a commit to CodecLondon/spark that referenced this pull request Jul 4, 2019
New feature to pass podspec files for driver and executor pods.

new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
yidetu pushed a commit to yidetu/spark that referenced this pull request Sep 10, 2019
## What changes were proposed in this pull request?

New feature to pass podspec files for driver and executor pods.

## How was this patch tested?
new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
yidetu pushed a commit to yidetu/spark that referenced this pull request Sep 11, 2019
## What changes were proposed in this pull request?

New feature to pass podspec files for driver and executor pods.

## How was this patch tested?
new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
yidetu pushed a commit to yidetu/spark that referenced this pull request Oct 10, 2019
## What changes were proposed in this pull request?

New feature to pass podspec files for driver and executor pods.

## How was this patch tested?
new unit and integration tests

- [x] more overwrites in integration tests
- [ ] invalid template integration test, documentation

Author: Onur Satici <osatici@palantir.com>
Author: Yifei Huang <yifeih@palantir.com>
Author: onursatici <onursatici@gmail.com>

Closes apache#22146 from onursatici/pod-template.
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.