Skip to content

Commit bd19c4a

Browse files
Logging (#226)
# Description Add log aggregation
1 parent 2113e1c commit bd19c4a

File tree

68 files changed

+2595
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2595
-240
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88

99
- Deploy default and support custom affinities ([#217])
1010
- BREAKING: Dropped support for old spec.{driver,executor}.nodeSelector field. Use spec.{driver,executor}.affinity.nodeSelector instead ([#217])
11+
- Log aggregation added ([#226]).
1112

1213
### Changed
1314

@@ -19,6 +20,7 @@ All notable changes to this project will be documented in this file.
1920
[#207]: https://github.com/stackabletech/spark-k8s-operator/pull/207
2021
[#217]: https://github.com/stackabletech/spark-k8s-operator/pull/217
2122
[#223]: https://github.com/stackabletech/spark-k8s-operator/pull/223
23+
[#226]: https://github.com/stackabletech/spark-k8s-operator/pull/226
2224

2325
## [23.1.0] - 2023-01-23
2426

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

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.

docs/modules/spark-k8s/pages/history_server.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ include::example$example-history-app.yaml[]
4848
<6> Credentials used to write event logs. These can, of course, differ from the credentials used to process data.
4949

5050

51+
== Log aggregation
52+
53+
The logs can be forwarded to a Vector log aggregator by providing a discovery
54+
ConfigMap for the aggregator and by enabling the log agent:
55+
56+
[source,yaml]
57+
----
58+
spec:
59+
vectorAggregatorConfigMapName: vector-aggregator-discovery
60+
nodes:
61+
config:
62+
logging:
63+
enableVectorAgent: true
64+
----
65+
66+
Further information on how to configure logging, can be found in
67+
xref:home:concepts:logging.adoc[].
5168

5269
== History Web UI
5370

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,28 @@ Spark allocates a default amount of non-heap memory based on the type of job (JV
177177

178178
NOTE: It is possible to define Spark resources either directly by setting configuration properties listed under `sparkConf`, or by using resource limits. If both are used, then `sparkConf` properties take precedence. It is recommended for the sake of clarity to use *_either_* one *_or_* the other.
179179

180+
== Log aggregation
181+
182+
The logs can be forwarded to a Vector log aggregator by providing a discovery
183+
ConfigMap for the aggregator and by enabling the log agent:
184+
185+
[source,yaml]
186+
----
187+
spec:
188+
vectorAggregatorConfigMapName: vector-aggregator-discovery
189+
job:
190+
logging:
191+
enableVectorAgent: true
192+
driver:
193+
logging:
194+
enableVectorAgent: true
195+
executor:
196+
logging:
197+
enableVectorAgent: true
198+
----
199+
200+
Further information on how to configure logging, can be found in
201+
xref:home:concepts:logging.adoc[].
180202

181203
== CRD argument coverage
182204

rust/crd/src/constants.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
pub const APP_NAME: &str = "spark-k8s";
22

3-
pub const VOLUME_MOUNT_NAME_POD_TEMPLATES: &str = "pod-template";
4-
pub const VOLUME_MOUNT_PATH_POD_TEMPLATES: &str = "/stackable/spark/pod-templates";
3+
pub const VOLUME_MOUNT_NAME_DRIVER_POD_TEMPLATES: &str = "driver-pod-template";
4+
pub const VOLUME_MOUNT_PATH_DRIVER_POD_TEMPLATES: &str = "/stackable/spark/driver-pod-templates";
5+
6+
pub const VOLUME_MOUNT_NAME_EXECUTOR_POD_TEMPLATES: &str = "executor-pod-template";
7+
pub const VOLUME_MOUNT_PATH_EXECUTOR_POD_TEMPLATES: &str =
8+
"/stackable/spark/executor-pod-templates";
9+
10+
pub const POD_TEMPLATE_FILE: &str = "template.yaml";
11+
12+
pub const VOLUME_MOUNT_NAME_CONFIG: &str = "config";
513

6-
pub const CONTAINER_NAME_JOB: &str = "job";
714
pub const VOLUME_MOUNT_NAME_JOB: &str = "job-files";
815
pub const VOLUME_MOUNT_PATH_JOB: &str = "/stackable/spark/jobs";
916

10-
pub const CONTAINER_NAME_REQ: &str = "requirements";
1117
pub const VOLUME_MOUNT_NAME_REQ: &str = "req-files";
1218
pub const VOLUME_MOUNT_PATH_REQ: &str = "/stackable/spark/requirements";
1319

14-
pub const CONTAINER_IMAGE_NAME_DRIVER: &str = "dummy-overwritten-by-command-line";
15-
pub const CONTAINER_NAME_DRIVER: &str = "spark-driver";
20+
pub const VOLUME_MOUNT_NAME_LOG_CONFIG: &str = "log-config";
21+
pub const VOLUME_MOUNT_PATH_LOG_CONFIG: &str = "/stackable/log_config";
1622

17-
pub const CONTAINER_IMAGE_NAME_EXECUTOR: &str = "dummy-overwritten-by-command-line";
18-
pub const CONTAINER_NAME_EXECUTOR: &str = "spark-executor";
23+
pub const VOLUME_MOUNT_NAME_LOG: &str = "log";
24+
pub const VOLUME_MOUNT_PATH_LOG: &str = "/stackable/log";
25+
26+
pub const LOG4J2_CONFIG_FILE: &str = "log4j2.properties";
1927

2028
pub const ACCESS_KEY_ID: &str = "accessKey";
2129
pub const SECRET_ACCESS_KEY: &str = "secretKey";
@@ -25,6 +33,11 @@ pub const MIN_MEMORY_OVERHEAD: u32 = 384;
2533
pub const JVM_OVERHEAD_FACTOR: f32 = 0.1;
2634
pub const NON_JVM_OVERHEAD_FACTOR: f32 = 0.4;
2735

36+
pub const MAX_SPARK_LOG_FILES_SIZE_IN_MIB: u32 = 10;
37+
pub const MAX_INIT_CONTAINER_LOG_FILES_SIZE_IN_MIB: u32 = 1;
38+
pub const LOG_VOLUME_SIZE_IN_MIB: u32 =
39+
MAX_SPARK_LOG_FILES_SIZE_IN_MIB + MAX_INIT_CONTAINER_LOG_FILES_SIZE_IN_MIB;
40+
2841
pub const OPERATOR_NAME: &str = "spark.stackable.tech";
2942
pub const CONTROLLER_NAME: &str = "sparkapplication";
3043
pub const POD_DRIVER_CONTROLLER_NAME: &str = "pod-driver";

rust/crd/src/history.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ use stackable_operator::{
2727
transform_all_roles_to_config, validate_all_roles_and_groups_config, Configuration,
2828
ValidatedRoleConfigByPropertyKind,
2929
},
30+
product_logging::{self, spec::Logging},
3031
role_utils::{Role, RoleGroupRef},
3132
schemars::{self, JsonSchema},
3233
};
33-
use strum::Display;
34+
use strum::{Display, EnumIter};
3435

3536
#[derive(Snafu, Debug)]
3637
pub enum Error {
@@ -62,6 +63,10 @@ pub enum Error {
6263
#[serde(rename_all = "camelCase")]
6364
pub struct SparkHistoryServerSpec {
6465
pub image: ProductImage,
66+
/// Name of the Vector aggregator discovery ConfigMap.
67+
/// It must contain the key `ADDRESS` with the address of the Vector aggregator.
68+
#[serde(skip_serializing_if = "Option::is_none")]
69+
pub vector_aggregator_config_map_name: Option<String>,
6570
pub log_file_directory: LogFileDirectorySpec,
6671
#[serde(skip_serializing_if = "Option::is_none")]
6772
pub spark_conf: Option<BTreeMap<String, String>>,
@@ -180,6 +185,26 @@ pub struct S3LogFileDirectorySpec {
180185
)]
181186
pub struct HistoryStorageConfig {}
182187

188+
#[derive(
189+
Clone,
190+
Debug,
191+
Deserialize,
192+
Display,
193+
Eq,
194+
EnumIter,
195+
JsonSchema,
196+
Ord,
197+
PartialEq,
198+
PartialOrd,
199+
Serialize,
200+
)]
201+
#[serde(rename_all = "kebab-case")]
202+
#[strum(serialize_all = "kebab-case")]
203+
pub enum SparkHistoryServerContainer {
204+
SparkHistory,
205+
Vector,
206+
}
207+
183208
#[derive(Clone, Debug, Default, JsonSchema, PartialEq, Fragment)]
184209
#[fragment_attrs(
185210
derive(
@@ -200,6 +225,8 @@ pub struct HistoryConfig {
200225
#[fragment_attrs(serde(default))]
201226
pub resources: Resources<HistoryStorageConfig, NoRuntimeLimits>,
202227
#[fragment_attrs(serde(default))]
228+
pub logging: Logging<SparkHistoryServerContainer>,
229+
#[fragment_attrs(serde(default))]
203230
pub affinity: StackableAffinity,
204231
}
205232

@@ -218,6 +245,7 @@ impl HistoryConfig {
218245
},
219246
storage: HistoryStorageConfigFragment {},
220247
},
248+
logging: product_logging::spec::default_logging(),
221249
affinity: history_affinity(cluster_name),
222250
}
223251
}

0 commit comments

Comments
 (0)