Skip to content

Commit 90b20fd

Browse files
committed
moved config map mounts to driver/executors
1 parent a498eba commit 90b20fd

File tree

6 files changed

+113
-23
lines changed

6 files changed

+113
-23
lines changed

deploy/crd/sparkapplication.crd.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ spec:
9898
driver:
9999
nullable: true
100100
properties:
101+
configMapMounts:
102+
items:
103+
properties:
104+
configMapName:
105+
type: string
106+
path:
107+
type: string
108+
required:
109+
- configMapName
110+
- path
111+
type: object
112+
nullable: true
113+
type: array
101114
coreLimit:
102115
nullable: true
103116
type: string
@@ -222,6 +235,19 @@ spec:
222235
executor:
223236
nullable: true
224237
properties:
238+
configMapMounts:
239+
items:
240+
properties:
241+
configMapName:
242+
type: string
243+
path:
244+
type: string
245+
required:
246+
- configMapName
247+
- path
248+
type: object
249+
nullable: true
250+
type: array
225251
cores:
226252
format: uint
227253
minimum: 0.0

deploy/helm/spark-k8s-operator/crds/crds.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ spec:
100100
driver:
101101
nullable: true
102102
properties:
103+
configMapMounts:
104+
items:
105+
properties:
106+
configMapName:
107+
type: string
108+
path:
109+
type: string
110+
required:
111+
- configMapName
112+
- path
113+
type: object
114+
nullable: true
115+
type: array
103116
coreLimit:
104117
nullable: true
105118
type: string
@@ -224,6 +237,19 @@ spec:
224237
executor:
225238
nullable: true
226239
properties:
240+
configMapMounts:
241+
items:
242+
properties:
243+
configMapName:
244+
type: string
245+
path:
246+
type: string
247+
required:
248+
- configMapName
249+
- path
250+
type: object
251+
nullable: true
252+
type: array
227253
cores:
228254
format: uint
229255
minimum: 0.0

deploy/manifests/crds.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ spec:
101101
driver:
102102
nullable: true
103103
properties:
104+
configMapMounts:
105+
items:
106+
properties:
107+
configMapName:
108+
type: string
109+
path:
110+
type: string
111+
required:
112+
- configMapName
113+
- path
114+
type: object
115+
nullable: true
116+
type: array
104117
coreLimit:
105118
nullable: true
106119
type: string
@@ -225,6 +238,19 @@ spec:
225238
executor:
226239
nullable: true
227240
properties:
241+
configMapMounts:
242+
items:
243+
properties:
244+
configMapName:
245+
type: string
246+
path:
247+
type: string
248+
required:
249+
- configMapName
250+
- path
251+
type: object
252+
nullable: true
253+
type: array
228254
cores:
229255
format: uint
230256
minimum: 0.0

examples/ny-tlc-report-configmap.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,23 @@ spec:
2828
"spark.hadoop.fs.s3a.aws.credentials.provider": "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider"
2929
"spark.driver.extraClassPath": "/dependencies/jars/hadoop-aws-3.2.0.jar:/dependencies/jars/aws-java-sdk-bundle-1.11.375.jar"
3030
"spark.executor.extraClassPath": "/dependencies/jars/hadoop-aws-3.2.0.jar:/dependencies/jars/aws-java-sdk-bundle-1.11.375.jar"
31-
configMapMounts:
32-
- configMapName: cm-job-arguments
33-
path: /arguments
3431
driver:
3532
cores: 1
3633
coreLimit: "1200m"
3734
memory: "512m"
3835
volumeMounts:
3936
- name: job-deps
4037
mountPath: /dependencies
38+
configMapMounts:
39+
- configMapName: cm-job-arguments
40+
path: /arguments
4141
executor:
4242
cores: 1
4343
instances: 3
4444
memory: "512m"
4545
volumeMounts:
4646
- name: job-deps
4747
mountPath: /dependencies
48+
configMapMounts:
49+
- configMapName: cm-job-arguments
50+
path: /arguments

rust/crd/src/lib.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,6 @@ pub struct S3 {
111111
pub endpoint: Option<String>,
112112
}
113113

114-
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
115-
#[serde(rename_all = "camelCase")]
116-
pub struct ConfigMapMount {
117-
pub config_map_name: String,
118-
pub path: String,
119-
}
120-
121-
impl ConfigMapMount {}
122-
123114
impl SparkApplication {
124115
pub fn enable_monitoring(&self) -> Option<bool> {
125116
let spec: &SparkApplicationSpec = &self.spec;
@@ -180,8 +171,22 @@ impl SparkApplication {
180171
tmp.iter().flat_map(|v| v.iter()).cloned().collect()
181172
}
182173

183-
pub fn config_map_mounts(&self) -> Vec<ConfigMapMount> {
184-
let tmp = self.spec.config_map_mounts.as_ref();
174+
pub fn executor_config_map_mounts(&self) -> Vec<ConfigMapMount> {
175+
let tmp = self
176+
.spec
177+
.executor
178+
.as_ref()
179+
.and_then(|executor_conf| executor_conf.config_map_mounts.clone());
180+
181+
tmp.iter().flat_map(|v| v.iter()).cloned().collect()
182+
}
183+
184+
pub fn driver_config_map_mounts(&self) -> Vec<ConfigMapMount> {
185+
let tmp = self
186+
.spec
187+
.driver
188+
.as_ref()
189+
.and_then(|driver_conf| driver_conf.config_map_mounts.clone());
185190

186191
tmp.iter().flat_map(|v| v.iter()).cloned().collect()
187192
}
@@ -304,6 +309,13 @@ pub struct CommonConfig {
304309
pub enable_monitoring: Option<bool>,
305310
}
306311

312+
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
313+
#[serde(rename_all = "camelCase")]
314+
pub struct ConfigMapMount {
315+
pub config_map_name: String,
316+
pub path: String,
317+
}
318+
307319
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
308320
#[serde(rename_all = "camelCase")]
309321
pub struct DriverConfig {
@@ -312,6 +324,8 @@ pub struct DriverConfig {
312324
pub memory: Option<String>,
313325
#[serde(default, skip_serializing_if = "Option::is_none")]
314326
pub volume_mounts: Option<Vec<VolumeMount>>,
327+
#[serde(default, skip_serializing_if = "Option::is_none")]
328+
pub config_map_mounts: Option<Vec<ConfigMapMount>>,
315329
}
316330

317331
impl DriverConfig {
@@ -340,6 +354,8 @@ pub struct ExecutorConfig {
340354
pub memory: Option<String>,
341355
#[serde(default, skip_serializing_if = "Option::is_none")]
342356
pub volume_mounts: Option<Vec<VolumeMount>>,
357+
#[serde(default, skip_serializing_if = "Option::is_none")]
358+
pub config_map_mounts: Option<Vec<ConfigMapMount>>,
343359
}
344360

345361
impl ExecutorConfig {

rust/operator-binary/src/spark_k8s_controller.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ fn pod_template_config_map(
241241
volumes.as_ref(),
242242
spark_application.driver_volume_mounts().as_ref(),
243243
spark_application.env().as_ref(),
244-
spark_application.config_map_mounts(),
244+
spark_application.driver_config_map_mounts(),
245245
)?;
246246
let executor_template = pod_template(
247247
CONTAINER_NAME_EXECUTOR,
@@ -250,7 +250,7 @@ fn pod_template_config_map(
250250
volumes.as_ref(),
251251
spark_application.executor_volume_mounts().as_ref(),
252252
spark_application.env().as_ref(),
253-
spark_application.config_map_mounts(),
253+
spark_application.executor_config_map_mounts(),
254254
)?;
255255

256256
let mut builder = ConfigMapBuilder::new();
@@ -306,13 +306,6 @@ fn spark_job(
306306
}];
307307
volumes.extend(spark_application.volumes());
308308

309-
// add the volumes/volume mounts for the configMaps in the job container
310-
apply_configmap_mounts(
311-
spark_application.config_map_mounts(),
312-
&mut volume_mounts,
313-
&mut volumes,
314-
);
315-
316309
let commands = spark_application
317310
.build_command(serviceaccount.metadata.name.as_ref().unwrap())
318311
.context(BuildCommandSnafu)?;

0 commit comments

Comments
 (0)