@@ -76,7 +76,8 @@ object SparkSubmit extends CommandLineUtils with Logging {
76
76
private val STANDALONE = 2
77
77
private val MESOS = 4
78
78
private val LOCAL = 8
79
- private val ALL_CLUSTER_MGRS = YARN | STANDALONE | MESOS | LOCAL
79
+ private val KUBERNETES = 16
80
+ private val ALL_CLUSTER_MGRS = YARN | STANDALONE | MESOS | LOCAL | KUBERNETES
80
81
81
82
// Deploy modes
82
83
private val CLIENT = 1
@@ -251,6 +252,7 @@ object SparkSubmit extends CommandLineUtils with Logging {
251
252
YARN
252
253
case m if m.startsWith(" spark" ) => STANDALONE
253
254
case m if m.startsWith(" mesos" ) => MESOS
255
+ case m if m.startsWith(" k8s" ) => KUBERNETES
254
256
case m if m.startsWith(" local" ) => LOCAL
255
257
case _ =>
256
258
printErrorAndExit(" Master must either be yarn or start with spark, mesos, local" )
@@ -296,6 +298,12 @@ object SparkSubmit extends CommandLineUtils with Logging {
296
298
case (STANDALONE , CLUSTER ) if args.isR =>
297
299
printErrorAndExit(" Cluster deploy mode is currently not supported for R " +
298
300
" applications on standalone clusters." )
301
+ case (KUBERNETES , CLIENT ) =>
302
+ printErrorAndExit(" Client mode is currently not supported for Kubernetes." )
303
+ case (KUBERNETES , _) if args.isPython =>
304
+ printErrorAndExit(" Python applications are currently not supported for Kubernetes." )
305
+ case (KUBERNETES , _) if args.isR =>
306
+ printErrorAndExit(" R applications are currently not supported for Kubernetes." )
299
307
case (LOCAL , CLUSTER ) =>
300
308
printErrorAndExit(" Cluster deploy mode is not compatible with master \" local\" " )
301
309
case (_, CLUSTER ) if isShell(args.primaryResource) =>
@@ -316,6 +324,7 @@ object SparkSubmit extends CommandLineUtils with Logging {
316
324
val isYarnCluster = clusterManager == YARN && deployMode == CLUSTER
317
325
val isMesosCluster = clusterManager == MESOS && deployMode == CLUSTER
318
326
val isStandAloneCluster = clusterManager == STANDALONE && deployMode == CLUSTER
327
+ val isKubernetesCluster = clusterManager == KUBERNETES && deployMode == CLUSTER
319
328
320
329
if (! isMesosCluster && ! isStandAloneCluster) {
321
330
// Resolve maven dependencies if there are any and add classpath to jars. Add them to py-files
@@ -555,20 +564,24 @@ object SparkSubmit extends CommandLineUtils with Logging {
555
564
OptionAssigner (args.principal, YARN , ALL_DEPLOY_MODES , confKey = " spark.yarn.principal" ),
556
565
OptionAssigner (args.keytab, YARN , ALL_DEPLOY_MODES , confKey = " spark.yarn.keytab" ),
557
566
567
+ // Kubernetes only
568
+ OptionAssigner (args.kubernetesNamespace, KUBERNETES , ALL_DEPLOY_MODES ,
569
+ confKey = " spark.kubernetes.namespace" ),
570
+
558
571
// Other options
559
- OptionAssigner (args.executorCores, STANDALONE | YARN , ALL_DEPLOY_MODES ,
572
+ OptionAssigner (args.executorCores, STANDALONE | YARN | KUBERNETES , ALL_DEPLOY_MODES ,
560
573
confKey = " spark.executor.cores" ),
561
- OptionAssigner (args.executorMemory, STANDALONE | MESOS | YARN , ALL_DEPLOY_MODES ,
574
+ OptionAssigner (args.executorMemory, STANDALONE | MESOS | YARN | KUBERNETES , ALL_DEPLOY_MODES ,
562
575
confKey = " spark.executor.memory" ),
563
- OptionAssigner (args.totalExecutorCores, STANDALONE | MESOS , ALL_DEPLOY_MODES ,
576
+ OptionAssigner (args.totalExecutorCores, STANDALONE | MESOS | KUBERNETES , ALL_DEPLOY_MODES ,
564
577
confKey = " spark.cores.max" ),
565
578
OptionAssigner (args.files, LOCAL | STANDALONE | MESOS , ALL_DEPLOY_MODES ,
566
579
confKey = " spark.files" ),
567
580
OptionAssigner (args.jars, LOCAL , CLIENT , confKey = " spark.jars" ),
568
581
OptionAssigner (args.jars, STANDALONE | MESOS , ALL_DEPLOY_MODES , confKey = " spark.jars" ),
569
- OptionAssigner (args.driverMemory, STANDALONE | MESOS | YARN , CLUSTER ,
582
+ OptionAssigner (args.driverMemory, STANDALONE | MESOS | YARN | KUBERNETES , CLUSTER ,
570
583
confKey = " spark.driver.memory" ),
571
- OptionAssigner (args.driverCores, STANDALONE | MESOS | YARN , CLUSTER ,
584
+ OptionAssigner (args.driverCores, STANDALONE | MESOS | YARN | KUBERNETES , CLUSTER ,
572
585
confKey = " spark.driver.cores" ),
573
586
OptionAssigner (args.supervise.toString, STANDALONE | MESOS , CLUSTER ,
574
587
confKey = " spark.driver.supervise" ),
@@ -702,6 +715,18 @@ object SparkSubmit extends CommandLineUtils with Logging {
702
715
}
703
716
}
704
717
718
+ if (isKubernetesCluster) {
719
+ childMainClass = " org.apache.spark.deploy.k8s.submit.Client"
720
+ childArgs ++= Array (" --primary-java-resource" , args.primaryResource)
721
+ childArgs ++= Array (" --main-class" , args.mainClass)
722
+ if (args.childArgs != null ) {
723
+ args.childArgs.foreach { arg =>
724
+ childArgs += " --arg"
725
+ childArgs += arg
726
+ }
727
+ }
728
+ }
729
+
705
730
// Load any properties specified through --conf and the default properties file
706
731
for ((k, v) <- args.sparkProperties) {
707
732
sparkConf.setIfMissing(k, v)
0 commit comments