-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-36061][K8S] Add volcano module and feature step
#35422
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
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/VolcanoFeatureStep.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.deploy.k8s.features | ||
|
|
||
| import io.fabric8.kubernetes.api.model._ | ||
| import io.fabric8.volcano.scheduling.v1beta1.PodGroupBuilder | ||
|
|
||
| import org.apache.spark.deploy.k8s.{KubernetesConf, KubernetesDriverConf, KubernetesExecutorConf, SparkPod} | ||
|
|
||
| private[spark] class VolcanoFeatureStep extends KubernetesDriverCustomFeatureConfigStep | ||
| with KubernetesExecutorCustomFeatureConfigStep { | ||
|
|
||
| private var kubernetesConf: KubernetesConf = _ | ||
|
|
||
| private val POD_GROUP_ANNOTATION = "scheduling.k8s.io/group-name" | ||
|
|
||
| private lazy val podGroupName = s"${kubernetesConf.appId}-podgroup" | ||
| private lazy val namespace = kubernetesConf.namespace | ||
|
|
||
| override def init(config: KubernetesDriverConf): Unit = { | ||
| kubernetesConf = config | ||
| } | ||
|
|
||
| override def init(config: KubernetesExecutorConf): Unit = { | ||
| kubernetesConf = config | ||
| } | ||
|
|
||
| override def getAdditionalPreKubernetesResources(): Seq[HasMetadata] = { | ||
| val podGroup = new PodGroupBuilder() | ||
| .editOrNewMetadata() | ||
| .withName(podGroupName) | ||
| .withNamespace(namespace) | ||
| .endMetadata() | ||
| .build() | ||
| Seq(podGroup) | ||
| } | ||
|
|
||
| override def configurePod(pod: SparkPod): SparkPod = { | ||
| val k8sPodBuilder = new PodBuilder(pod.pod) | ||
| .editMetadata() | ||
| .addToAnnotations(POD_GROUP_ANNOTATION, podGroupName) | ||
| .endMetadata() | ||
| val k8sPod = k8sPodBuilder.build() | ||
| SparkPod(k8sPod, pod.container) | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...es/core/src/test/scala/org/apache/spark/deploy/k8s/features/VolcanoFeatureStepSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.deploy.k8s.features | ||
|
|
||
| import io.fabric8.volcano.scheduling.v1beta1.PodGroup | ||
|
|
||
| import org.apache.spark.{SparkConf, SparkFunSuite} | ||
| import org.apache.spark.deploy.k8s._ | ||
|
|
||
| class VolcanoFeatureStepSuite extends SparkFunSuite { | ||
|
|
||
| test("SPARK-36061: Driver Pod with Volcano PodGroup") { | ||
| val sparkConf = new SparkConf() | ||
| val kubernetesConf = KubernetesTestConf.createDriverConf(sparkConf) | ||
| val step = new VolcanoFeatureStep() | ||
| step.init(kubernetesConf) | ||
| val configuredPod = step.configurePod(SparkPod.initialPod()) | ||
|
|
||
| val annotations = configuredPod.pod.getMetadata.getAnnotations | ||
|
|
||
| assert(annotations.get("scheduling.k8s.io/group-name") === s"${kubernetesConf.appId}-podgroup") | ||
| val podGroup = step.getAdditionalPreKubernetesResources().head.asInstanceOf[PodGroup] | ||
| assert(podGroup.getMetadata.getName === s"${kubernetesConf.appId}-podgroup") | ||
| } | ||
|
|
||
| test("SPARK-36061: Executor Pod with Volcano PodGroup") { | ||
| val sparkConf = new SparkConf() | ||
| val kubernetesConf = KubernetesTestConf.createExecutorConf(sparkConf) | ||
| val step = new VolcanoFeatureStep() | ||
| step.init(kubernetesConf) | ||
| val configuredPod = step.configurePod(SparkPod.initialPod()) | ||
| val annotations = configuredPod.pod.getMetadata.getAnnotations | ||
| assert(annotations.get("scheduling.k8s.io/group-name") === s"${kubernetesConf.appId}-podgroup") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ation-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/VolcanoSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.deploy.k8s.integrationtest | ||
|
|
||
| import org.scalatest.Tag | ||
|
|
||
| class VolcanoSuite extends KubernetesSuite with VolcanoTestsSuite { | ||
|
|
||
| override protected def setUpTest(): Unit = { | ||
| super.setUpTest() | ||
| sparkAppConf | ||
| .set("spark.kubernetes.driver.scheduler.name", "volcano") | ||
| .set("spark.kubernetes.executor.scheduler.name", "volcano") | ||
| } | ||
| } | ||
|
|
||
| private[spark] object VolcanoSuite { | ||
| val volcanoTag = Tag("volcano") | ||
| } |
70 changes: 70 additions & 0 deletions
70
...-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/VolcanoTestsSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.deploy.k8s.integrationtest | ||
|
|
||
| import io.fabric8.kubernetes.api.model.Pod | ||
| import io.fabric8.volcano.client.VolcanoClient | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.deploy.k8s.features.VolcanoFeatureStep | ||
| import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite.k8sTestTag | ||
| import org.apache.spark.deploy.k8s.integrationtest.VolcanoSuite.volcanoTag | ||
|
|
||
| private[spark] trait VolcanoTestsSuite { k8sSuite: KubernetesSuite => | ||
| import VolcanoTestsSuite._ | ||
|
|
||
| protected def checkScheduler(pod: Pod): Unit = { | ||
| assert(pod.getSpec.getSchedulerName === "volcano") | ||
| } | ||
|
|
||
| protected def checkAnnotaion(pod: Pod): Unit = { | ||
| val appId = pod.getMetadata.getLabels.get("spark-app-selector") | ||
| val annotations = pod.getMetadata.getAnnotations | ||
| assert(annotations.get("scheduling.k8s.io/group-name") === s"$appId-podgroup") | ||
| } | ||
|
|
||
| protected def checkPodGroup(pod: Pod): Unit = { | ||
| val appId = pod.getMetadata.getLabels.get("spark-app-selector") | ||
| val podGroupName = s"$appId-podgroup" | ||
| val volcanoClient = kubernetesTestComponents.kubernetesClient.adapt(classOf[VolcanoClient]) | ||
| val podGroup = volcanoClient.podGroups().withName(podGroupName).get() | ||
| assert(podGroup.getMetadata.getOwnerReferences.get(0).getName === pod.getMetadata.getName) | ||
| } | ||
|
|
||
| test("Run SparkPi with volcano scheduler", k8sTestTag, volcanoTag) { | ||
| sparkAppConf | ||
| .set("spark.kubernetes.driver.pod.featureSteps", VOLCANO_FEATURE_STEP) | ||
| .set("spark.kubernetes.executor.pod.featureSteps", VOLCANO_FEATURE_STEP) | ||
| runSparkPiAndVerifyCompletion( | ||
| driverPodChecker = (driverPod: Pod) => { | ||
| doBasicDriverPodCheck(driverPod) | ||
| checkScheduler(driverPod) | ||
| checkAnnotaion(driverPod) | ||
| checkPodGroup(driverPod) | ||
| }, | ||
| executorPodChecker = (executorPod: Pod) => { | ||
| doBasicExecutorPodCheck(executorPod) | ||
| checkScheduler(executorPod) | ||
| checkAnnotaion(executorPod) | ||
| } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private[spark] object VolcanoTestsSuite extends SparkFunSuite { | ||
| val VOLCANO_FEATURE_STEP = classOf[VolcanoFeatureStep].getName | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.