-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
Conversation
Jenkins, OK to test |
Thanks @onursatici! |
@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 |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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._ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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:- Load the contents of the template file from this process's local disk into a UTF-8 String
- 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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
Jenkins, ok to test |
@yifeih can we also modify |
Kubernetes integration test starting |
Test build #95112 has finished for PR 22146 at commit
|
test this please |
Test build #98231 has finished for PR 22146 at commit
|
Test build #98233 has finished for PR 22146 at commit
|
thanks @shaneknapp ! |
Kubernetes integration test starting |
Kubernetes integration test status failure |
retest this please |
Test build #98237 has finished for PR 22146 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
@mccheah integration testing is passing with the latest container selection policy, good to merge? |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping here
Kubernetes integration test starting |
Test build #98273 has finished for PR 22146 at commit
|
Kubernetes integration test status success |
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. |
@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! |
## 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>
## 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.
## 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>
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.
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.
## 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.
## 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.
## 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.
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