@@ -185,6 +185,21 @@ To use a secret through an environment variable use the following options to the
185
185
--conf spark.kubernetes.executor.secretKeyRef.ENV_NAME=name:key
186
186
```
187
187
188
+ ## Pod Template
189
+ Kubernetes allows defining pods from [ template files] ( https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates ) .
190
+ Spark users can similarly use template files to define the driver or executor pod configurations that Spark configurations do not support.
191
+ To do so, specify the spark properties ` spark.kubernetes.driver.podTemplateFile ` and ` spark.kubernetes.executor.podTemplateFile `
192
+ to point to local files accessible to the ` spark-submit ` process. To allow the driver pod access the executor pod template
193
+ file, the file will be automatically mounted onto a volume in the driver pod when it's created.
194
+
195
+ It is important to note that Spark is opinionated about certain pod configurations so there are values in the
196
+ pod template that will always be overwritten by Spark. Therefore, users of this feature should note that specifying
197
+ the pod template file only lets Spark start with a template pod instead of an empty pod during the pod-building process.
198
+ For details, see the [ full list] ( #pod-template-properties ) of pod template values that will be overwritten by spark.
199
+
200
+ Pod template files can also define multiple containers. In such cases, Spark will always assume that the first container in
201
+ the list will be the driver or executor container.
202
+
188
203
## Introspection and Debugging
189
204
190
205
These are the different ways in which you can investigate a running/completed Spark application, monitor progress, and
@@ -775,4 +790,168 @@ specific to Spark on Kubernetes.
775
790
This sets the major Python version of the docker image used to run the driver and executor containers. Can either be 2 or 3.
776
791
</td >
777
792
</tr >
793
+ <tr >
794
+ <td ><code >spark.kubernetes.driver.podTemplateFile</code ></td >
795
+ <td >(none)</td >
796
+ <td >
797
+ Specify the local file that contains the driver [ pod template] ( #pod-template ) . For example
798
+ <code >spark.kubernetes.driver.podTemplateFile=/path/to/driver-pod-template.yaml`</code >
799
+ </td >
800
+ </tr >
801
+ <tr >
802
+ <td ><code >spark.kubernetes.executor.podTemplateFile</code ></td >
803
+ <td >(none)</td >
804
+ <td >
805
+ Specify the local file that contains the executor [ pod template] ( #pod-template ) . For example
806
+ <code >spark.kubernetes.executor.podTemplateFile=/path/to/executor-pod-template.yaml`</code >
807
+ </td >
808
+ </tr >
809
+ </table >
810
+
811
+ #### Pod template properties
812
+
813
+ See the below table for the full list of pod specifications that will be overwritten by spark.
814
+
815
+ ### Pod Metadata
816
+
817
+ <table class =" table " >
818
+ <tr ><th >Pod metadata key</th ><th >Modified value</th ><th >Description</th ></tr >
819
+ <tr >
820
+ <td >name</td >
821
+ <td >Value of <code >spark.kubernetes.driver.pod.name</code ></td >
822
+ <td >
823
+ The driver pod name will be overwritten with either the configured or default value of
824
+ <code>spark.kubernetes.driver.pod.name</code>. The executor pod names will be unaffected.
825
+ </td >
826
+ </tr >
827
+ <tr >
828
+ <td >namespace</td >
829
+ <td >Value of <code >spark.kubernetes.namespace</code ></td >
830
+ <td >
831
+ Spark makes strong assumptions about the driver and executor namespaces. Both driver and executor namespaces will
832
+ be replaced by either the configured or default spark conf value.
833
+ </td >
834
+ </tr >
835
+ <tr >
836
+ <td >labels</td >
837
+ <td >Adds the labels from <code >spark.kubernetes.{driver,executor}.label.*</code ></td >
838
+ <td >
839
+ Spark will add additional labels specified by the spark configuration.
840
+ </td >
841
+ </tr >
842
+ <tr >
843
+ <td >annotations</td >
844
+ <td >Adds the annotations from <code >spark.kubernetes.{driver,executor}.annotation.*</code ></td >
845
+ <td >
846
+ Spark will add additional labels specified by the spark configuration.
847
+ </td >
848
+ </tr >
849
+ </table >
850
+
851
+ ### Pod Spec
852
+
853
+ <table class =" table " >
854
+ <tr ><th >Pod spec key</th ><th >Modified value</th ><th >Description</th ></tr >
855
+ <tr >
856
+ <td >imagePullSecrets</td >
857
+ <td >Adds image pull secrets from <code >spark.kubernetes.container.image.pullSecrets</code ></td >
858
+ <td >
859
+ Additional pull secrets will be added from the spark configuration to both executor pods.
860
+ </td >
861
+ </tr >
862
+ <tr >
863
+ <td >nodeSelector</td >
864
+ <td >Adds node selectors from <code >spark.kubernetes.node.selector.*</code ></td >
865
+ <td >
866
+ Additional node selectors will be added from the spark configuration to both executor pods.
867
+ </td >
868
+ </tr >
869
+ <tr >
870
+ <td >restartPolicy</td >
871
+ <td ><code >"never"</code ></td >
872
+ <td >
873
+ Spark assumes that both drivers and executors never restart.
874
+ </td >
875
+ </tr >
876
+ <tr >
877
+ <td >serviceAccount</td >
878
+ <td >Value of <code >spark.kubernetes.authenticate.driver.serviceAccountName</code ></td >
879
+ <td >
880
+ Spark will override <code>serviceAccount</code> with the value of the spark configuration for only
881
+ driver pods, and only if the spark configuration is specified. Executor pods will remain unaffected.
882
+ </td >
883
+ </tr >
884
+ <tr >
885
+ <td >serviceAccountName</td >
886
+ <td >Value of <code >spark.kubernetes.authenticate.driver.serviceAccountName</code ></td >
887
+ <td >
888
+ Spark will override <code>serviceAccountName</code> with the value of the spark configuration for only
889
+ driver pods, and only if the spark configuration is specified. Executor pods will remain unaffected.
890
+ </td >
891
+ </tr >
892
+ <tr >
893
+ <td >volumes</td >
894
+ <td >Adds volumes from <code >spark.kubernetes.{driver,executor}.volumes.[VolumeType].[VolumeName].mount.path</code ></td >
895
+ <td >
896
+ Spark will add volumes as specified by the spark conf, as well as additional volumes necessary for passing
897
+ spark conf and pod template files.
898
+ </td >
899
+ </tr >
778
900
</table >
901
+
902
+ ### Container spec
903
+
904
+ The following affect the driver and executor containers. All other containers in the pod spec will be unaffected.
905
+
906
+ <table class =" table " >
907
+ <tr ><th >Container spec key</th ><th >Modified value</th ><th >Description</th ></tr >
908
+ <tr >
909
+ <td >env</td >
910
+ <td >Adds env variables from <code >spark.kubernetes.driverEnv.[EnvironmentVariableName]</code ></td >
911
+ <td >
912
+ Spark will add driver env variables from <code>spark.kubernetes.driverEnv.[EnvironmentVariableName]</code>, and
913
+ executor env variables from <code>spark.executorEnv.[EnvironmentVariableName]</code>.
914
+ </td >
915
+ </tr >
916
+ <tr >
917
+ <td >image</td >
918
+ <td >Value of <code >spark.kubernetes.{driver,executor}.container.image</code ></td >
919
+ <td >
920
+ The image will be defined by the spark configurations.
921
+ </td >
922
+ </tr >
923
+ <tr >
924
+ <td >imagePullPolicy</td >
925
+ <td >Value of <code >spark.kubernetes.container.image.pullPolicy</code ></td >
926
+ <td >
927
+ Spark will override the pull policy for both driver and executors.
928
+ </td >
929
+ </tr >
930
+ <tr >
931
+ <td >name</td >
932
+ <td >See description.</code ></td >
933
+ <td >
934
+ The container name will be assigned by spark ("spark-kubernetes-driver" for the driver container, and
935
+ "executor" for each executor container) if not defined by the pod template. If the container is defined by the
936
+ template, the template's name will be used.
937
+ </td >
938
+ </tr >
939
+ <tr >
940
+ <td >resources</td >
941
+ <td >See description</td >
942
+ <td >
943
+ The cpu limits are set by <code>spark.kubernetes.{driver,executor}.limit.cores</code>. The cpu is set by
944
+ <code>spark.{driver,executor}.cores</code>. The memory request and limit are set by summing the values of
945
+ <code>spark.{driver,executor}.memory</code> and <code>spark.{driver,executor}.memoryOverhead</code>.
946
+
947
+ </td >
948
+ </tr >
949
+ <tr >
950
+ <td >volumeMounts</td >
951
+ <td >Add volumes from <code >spark.kubernetes.driver.volumes.[VolumeType].[VolumeName].mount.{path,readOnly}</code ></td >
952
+ <td >
953
+ Spark will add volumes as specified by the spark conf, as well as additional volumes necessary for passing
954
+ spark conf and pod template files.
955
+ </td >
956
+ </tr >
957
+ </table >
0 commit comments