Skip to content

Commit 9ffb187

Browse files
committed
expose spark connect pods via listener classes
1 parent 90d4f03 commit 9ffb187

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

docs/modules/spark-k8s/pages/usage-guide/listenerclass.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
= History service exposition with listener classes
2-
:description: Configure the Spark history service exposure with listener classes: cluster-internal, external-unstable, or external-stable.
1+
= Service exposition with listener classes
2+
:description: Configure the Spark connect and history services exposure with listener classes: cluster-internal, external-unstable, or external-stable.
3+
4+
== History services
35

46
The operator deploys a xref:listener-operator:listener.adoc[Listener] for each spark history pod.
57
The default is to only being accessible from within the Kubernetes cluster, but this can be changed by setting `.spec.clusterConfig.listenerClass`:
@@ -17,3 +19,7 @@ spec:
1719
<1> Specify one of `external-stable`, `external-unstable`, `cluster-internal` (the default setting is `cluster-internal`).
1820

1921
For the example above, the listener operator creates a service named `spark-history-node-default-0-listener` where `spark-history` is the name of the SparkHistoryServer, `node` is the service role (the only service role available for history servers) and `default` is the role group.
22+
23+
== Connect services
24+
25+
Connect pods can be exposed using listener classes in exactly tha same fashion as history servers.

rust/operator-binary/src/connect/server.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ use crate::{
3838
},
3939
},
4040
crd::constants::{
41-
APP_NAME, JVM_SECURITY_PROPERTIES_FILE, LOG4J2_CONFIG_FILE, MAX_SPARK_LOG_FILES_SIZE,
42-
METRICS_PROPERTIES_FILE, POD_TEMPLATE_FILE, SPARK_DEFAULTS_FILE_NAME, SPARK_UID,
43-
VOLUME_MOUNT_NAME_CONFIG, VOLUME_MOUNT_NAME_LOG, VOLUME_MOUNT_NAME_LOG_CONFIG,
44-
VOLUME_MOUNT_PATH_CONFIG, VOLUME_MOUNT_PATH_LOG, VOLUME_MOUNT_PATH_LOG_CONFIG,
41+
APP_NAME, JVM_SECURITY_PROPERTIES_FILE, LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME,
42+
LOG4J2_CONFIG_FILE, MAX_SPARK_LOG_FILES_SIZE, METRICS_PROPERTIES_FILE, POD_TEMPLATE_FILE,
43+
SPARK_DEFAULTS_FILE_NAME, SPARK_UID, VOLUME_MOUNT_NAME_CONFIG, VOLUME_MOUNT_NAME_LOG,
44+
VOLUME_MOUNT_NAME_LOG_CONFIG, VOLUME_MOUNT_PATH_CONFIG, VOLUME_MOUNT_PATH_LOG,
45+
VOLUME_MOUNT_PATH_LOG_CONFIG,
4546
},
4647
product_logging,
4748
};
@@ -196,12 +197,15 @@ pub(crate) fn build_deployment(
196197
config_map: &ConfigMap,
197198
args: Vec<String>,
198199
) -> Result<Deployment, Error> {
200+
let server_role = SparkConnectRole::Server.to_string();
201+
let recommended_object_labels =
202+
common::labels(scs, &resolved_product_image.app_version_label, &server_role);
203+
204+
let recommended_labels =
205+
Labels::recommended(recommended_object_labels.clone()).context(LabelBuildSnafu)?;
206+
199207
let metadata = ObjectMetaBuilder::new()
200-
.with_recommended_labels(common::labels(
201-
scs,
202-
&resolved_product_image.app_version_label,
203-
&SparkConnectRole::Server.to_string(),
204-
))
208+
.with_recommended_labels(recommended_object_labels)
205209
.context(MetadataBuildSnafu)?
206210
.with_label(Label::try_from(("prometheus.io/scrape", "true")).context(LabelBuildSnafu)?)
207211
.build();
@@ -226,6 +230,12 @@ pub(crate) fn build_deployment(
226230
.build(),
227231
)
228232
.context(AddVolumeSnafu)?
233+
.add_listener_volume_by_listener_class(
234+
LISTENER_VOLUME_NAME,
235+
&scs.spec.cluster_config.listener_class.to_string(),
236+
&recommended_labels.clone(),
237+
)
238+
.context(AddVolumeSnafu)?
229239
.security_context(PodSecurityContext {
230240
run_as_user: Some(SPARK_UID),
231241
run_as_group: Some(0),
@@ -260,6 +270,8 @@ pub(crate) fn build_deployment(
260270
.context(AddVolumeMountSnafu)?
261271
.add_volume_mount(VOLUME_MOUNT_NAME_LOG, VOLUME_MOUNT_PATH_LOG)
262272
.context(AddVolumeMountSnafu)?
273+
.add_volume_mount(LISTENER_VOLUME_NAME, LISTENER_VOLUME_DIR)
274+
.context(AddVolumeMountSnafu)?
263275
.readiness_probe(probe())
264276
.liveness_probe(probe());
265277

0 commit comments

Comments
 (0)