Created
March 24, 2022 12:44
-
-
Save martin-g/2ac3a324962afea7c4f96f4e64546ba9 to your computer and use it in GitHub Desktop.
Bash shell script to run Spark Pi example on Volcano using PodGroup template
This file contains 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
#!/usr/bin/env bash | |
K8S_NAMESPACE="spark-on-k8s" | |
K8S_SERVICE_ACCOUNT_NAME="spark-account-name" | |
K8S_CLUSTER_ROLE="spark-on-k8s-cluster-role" | |
CURRENT_CONTEXT=(kubectl config view -o jsonpath="{.current-context}") | |
K8S_MASTER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CURRENT_CONTEXT\")].cluster.server}") | |
DRIVER_CORES=1 | |
DRIVER_MEM=2048m | |
EXECUTOR_INSTANCES=3 | |
EXECUTOR_CORES=2 | |
EXECUTOR_MEM=2048m | |
CONTAINER_IMAGE="spark:3.3.0-SNAPSHOT-scala_2.12-11-jre-slim" | |
PATH=$SPARK_HOME/bin:$PATH | |
spark-submit \ | |
--class org.apache.spark.examples.SparkPi \ | |
--deploy-mode cluster \ | |
--master k8s://$K8S_MASTER \ | |
--name {$K8S_NAMESPACE}-app \ | |
--conf spark.kubernetes.namespace=$K8S_NAMESPACE \ | |
--conf spark.network.timeout=300 \ | |
--conf spark.executor.instances=$EXECUTOR_INSTANCES \ | |
--conf spark.driver.extraJavaOptions="-Dio.netty.tryReflectionSetAccessible=true" \ | |
--conf spark.executor.extraJavaOptions="-Dio.netty.tryReflectionSetAccessible=true" \ | |
--conf spark.driver.cores=$DRIVER_CORES \ | |
--conf spark.executor.cores=$EXECUTOR_CORES \ | |
--conf spark.driver.memory=$DRIVER_MEM \ | |
--conf spark.executor.memory=$EXECUTOR_MEM \ | |
--conf spark.kubernetes.driver.container.image=$CONTAINER_IMAGE \ | |
--conf spark.kubernetes.executor.container.image=$CONTAINER_IMAGE \ | |
--conf spark.kubernetes.driver.pod.featureSteps=org.apache.spark.deploy.k8s.features.VolcanoFeatureStep \ | |
--conf spark.kubernetes.executor.pod.featureSteps=org.apache.spark.deploy.k8s.features.VolcanoFeatureStep \ | |
--conf spark.kubernetes.authenticate.driver.serviceAccountName=$K8S_SERVICE_ACCOUNT_NAME \ | |
--conf spark.kubernetes.scheduler.volcano.podGroupTemplateFile=$HOME/spark/templates/my-podgroup-template.yaml \ | |
--verbose \ | |
local:///opt/spark/examples/jars/spark-examples_2.12-3.3.0-SNAPSHOT.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment