Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Spark history server #187

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
91f5936
Remove zombie test definition.
razvan Jan 2, 2023
0fc5125
wip : history server
razvan Jan 2, 2023
e5044f4
Consolidate constants.
razvan Jan 3, 2023
057f37c
wip: create deployment, service and config map
razvan Jan 3, 2023
a5abf76
Update changelog
razvan Jan 3, 2023
34c3dd5
Use framework image struct, update crds and more.
razvan Jan 4, 2023
e587200
Use roles and role groups.
razvan Jan 4, 2023
79ea167
Kuttl tests almost green
razvan Jan 5, 2023
8362df5
Populate spark config automatically.
razvan Jan 5, 2023
8f593c2
Use S3 secrets for the logs bucket
razvan Jan 6, 2023
9d2c661
Successfuly started histo server, cleanups, replicas.
razvan Jan 6, 2023
c82335c
collect all three controllers
adwk67 Jan 10, 2023
dfb7d7b
write logs to history server and check results
adwk67 Jan 12, 2023
16ff530
merged main
adwk67 Jan 12, 2023
0027f45
re-format
adwk67 Jan 12, 2023
a9622f7
added resources using fragments
adwk67 Jan 13, 2023
6e26cb7
service account
adwk67 Jan 13, 2023
2895ab4
added sleep in tests for minio
adwk67 Jan 13, 2023
b2765f8
regenerate charts
adwk67 Jan 13, 2023
3c99f0d
use same clusterrole for history server, and add pvc permissions
adwk67 Jan 13, 2023
935d9bf
documentation
adwk67 Jan 13, 2023
21a20c3
added operator-rs update to changelog
adwk67 Jan 13, 2023
6cec93c
parse cleaner config
adwk67 Jan 16, 2023
9b382ba
use history api for test
adwk67 Jan 16, 2023
977eb05
linting
adwk67 Jan 16, 2023
bfbc8dd
Extract cleaner settings into their own function.
razvan Jan 16, 2023
3b04da8
The operator chooses the appropriate s3 credentials provider
razvan Jan 16, 2023
d14788a
Extract S3LogDir to it's own module.
razvan Jan 16, 2023
d9c76c4
Automatically configure event logs for applications that require it.
razvan Jan 16, 2023
ad26663
removed unused dependency
adwk67 Jan 16, 2023
918a2dd
Clean eventual orphaned resources.
razvan Jan 17, 2023
2d20012
Update docs.
razvan Jan 17, 2023
a21bc75
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 17, 2023
6af52e6
Update docs/modules/ROOT/examples/example-history-server.yaml
razvan Jan 17, 2023
3070945
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 17, 2023
ae9e5d4
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 17, 2023
e211669
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 17, 2023
213e223
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 17, 2023
1650f09
Mount credentials in separate folders and configure bucket specific p…
razvan Jan 17, 2023
b3158b1
Use different endpoints for data and event logs.
razvan Jan 18, 2023
664e6ec
Implement fix for "S3 reference inconsistency #162"
razvan Jan 18, 2023
f308142
main merge
razvan Jan 18, 2023
1fd5ebb
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 19, 2023
bd49457
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 19, 2023
30479f5
Update docs/modules/ROOT/pages/history_server.adoc
razvan Jan 19, 2023
149bc1f
Update CHANGELOG, docs and clean up
razvan Jan 19, 2023
91bb1df
Remove alternative Dockerfile
razvan Jan 19, 2023
6ab2278
Merge branch 'main' into 124-implement-adr-22-spark-history-server
razvan Jan 19, 2023
685b292
Use references to S3 objects in tests.
razvan Jan 19, 2023
2c843b7
Update rust/operator-binary/src/spark_k8s_controller.rs
razvan Jan 19, 2023
9037986
Update rust/operator-binary/src/history_controller.rs
razvan Jan 19, 2023
3f95292
Update rust/operator-binary/src/history_controller.rs
razvan Jan 19, 2023
e0c7d8c
Update rust/operator-binary/src/history_controller.rs
razvan Jan 19, 2023
2de8ee4
Update rust/crd/src/history.rs
razvan Jan 19, 2023
fe169a1
Update docs/modules/ROOT/pages/usage.adoc
razvan Jan 19, 2023
702b828
Update Rust code with review feedback.
razvan Jan 19, 2023
5bc89dd
Update rust/crd/src/s3logdir.rs
sbernauer Jan 19, 2023
78210d5
Update rust/crd/src/s3logdir.rs
sbernauer Jan 19, 2023
3e5d845
Update rust/operator-binary/src/history_controller.rs
sbernauer Jan 19, 2023
12cb8d9
Update rust/operator-binary/src/history_controller.rs
sbernauer Jan 19, 2023
73aad65
Fix services and watch more objects.
razvan Jan 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Create and manage history servers ([#187])

[#187]: https://github.com/stackabletech/spark-k8s-operator/pull/187

### Changed

- Updated stackable image versions ([#176])
- `operator-rs` `0.22.0` → `0.27.1` ([#178])
- `operator-rs` `0.27.1` -> `0.30.2` ([#187])
- Don't run init container as root and avoid chmod and chowning ([#183])
- [BREAKING] Implement fix for S3 reference inconsistency as described in the issue #162 ([#187])

[#176]: https://github.com/stackabletech/spark-k8s-operator/pull/176
[#178]: https://github.com/stackabletech/spark-k8s-operator/pull/178
Expand Down Expand Up @@ -43,7 +51,6 @@ All notable changes to this project will be documented in this file.
- Update RBAC properties for OpenShift compatibility ([#126]).

[#112]: https://github.com/stackabletech/spark-k8s-operator/pull/112
[#114]: https://github.com/stackabletech/spark-k8s-operator/pull/114
[#126]: https://github.com/stackabletech/spark-k8s-operator/pull/126

## [0.4.0] - 2022-08-03
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

857 changes: 769 additions & 88 deletions deploy/helm/spark-k8s-operator/crds/crds.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions deploy/helm/spark-k8s-operator/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ rules:
- spark.stackable.tech
resources:
- sparkapplications
- sparkhistoryservers
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ rules:
- ""
resources:
- configmaps
- persistentvolumeclaims
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird but it is what it is

- pods
- secrets
- serviceaccounts
Expand Down
34 changes: 34 additions & 0 deletions docs/modules/ROOT/examples/example-history-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
apiVersion: spark.stackable.tech/v1alpha1
kind: SparkApplication
metadata:
name: spark-pi-s3-1
spec:
version: "1.0"
sparkImage: docker.stackable.tech/stackable/spark-k8s:3.3.0-stackable0.3.0
sparkImagePullPolicy: IfNotPresent
mode: cluster
mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: s3a://my-bucket/spark-examples_2.12-3.3.0.jar
s3connection: # <1>
razvan marked this conversation as resolved.
Show resolved Hide resolved
inline:
host: test-minio
port: 9000
accessStyle: Path
credentials:
secretClass: s3-credentials-class # <2>
logFileDirectory: # <3>
s3:
prefix: eventlogs/ # <4>
bucket:
inline:
bucketName: spark-logs # <5>
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
credentials:
secretClass: history-credentials-class # <6>
executor:
instances: 1
29 changes: 29 additions & 0 deletions docs/modules/ROOT/examples/example-history-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
apiVersion: spark.stackable.tech/v1alpha1
kind: SparkHistoryServer
metadata:
name: spark-history
spec:
image:
productVersion: 3.3.0
stackableVersion: 0.3.0
logFileDirectory: # <1>
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
s3:
prefix: eventlogs/ # <2>
bucket: # <3>
inline:
bucketName: spark-logs
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
credentials:
secretClass: history-credentials-class
sparkConf: # <4>
nodes:
roleGroups:
cleaner:
replicas: 1 # <5>
config:
cleaner: true # <6>
15 changes: 6 additions & 9 deletions docs/modules/ROOT/examples/example-sparkapp-s3-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ spec:
mode: cluster
mainApplicationFile: s3a://my-bucket/spark-examples_2.12-3.3.0.jar # <1>
mainClass: org.apache.spark.examples.SparkPi # <2>
s3bucket: # <3>
s3connection: # <3>
inline:
bucketName: my-bucket
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
credentials: # <4>
secretClass: s3-credentials-class
host: test-minio
port: 9000
accessStyle: Path
credentials: # <4>
secretClass: s3-credentials-class
sparkConf: # <5>
spark.hadoop.fs.s3a.aws.credentials.provider: "org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider" # <6>
spark.driver.extraClassPath: "/dependencies/jars/hadoop-aws-3.2.0.jar:/dependencies/jars/aws-java-sdk-bundle-1.11.375.jar"
Expand Down
Binary file added docs/modules/ROOT/images/history-server-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* xref:usage.adoc[]
* xref:job_dependencies.adoc[]
* xref:rbac.adoc[]
* xref:history_server.adoc[]
66 changes: 66 additions & 0 deletions docs/modules/ROOT/pages/history_server.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
= Spark History Server

== Overview

The Stackable Spark-on-Kubernetes operator runs Apache Spark workloads in a Kubernetes cluster, whereby driver- and executor-pods are created for the duration of the job and then terminated. One or more Spark History Server instances can be deployed independently of `SparkApplication` jobs and used as an end-point for spark logging, so that job information can be viewed once the job pods are no longer available.

== Deployment

The example below demonstrates how to set up the history server running in one Pod with scheduled cleanups of the event logs. The event logs are loaded from an S3 bucket named `spark-logs` and the folder `eventlogs/`. The credentials for this bucket are provided by the secret class `s3-credentials-class`. For more details on how the Stackable Data Platform manages S3 resources see the xref:home:concepts:s3.adoc[S3 resources] page.


[source,yaml]
----
include::example$example-history-server.yaml[]
----

<1> The location of the event logs. Must be a S3 bucket. Future implementations might add support for other shared filesystems such as HDFS.
<2> Folder within the S3 bucket where the log files are located. This folder is required and must exist before setting up the history server.
<3> The S3 bucket definition, here provided in-line.
<4> Additional history server configuration properties can be provided here as a map. For possible properties see: https://spark.apache.org/docs/latest/monitoring.html#spark-history-server-configuration-options
<5> This deployment has only one Pod. Multiple history servers can be started, all reading the same event logs by increasing the replica count.
<6> This history server will automatically clean up old log files by using default properties. You can change any of these by using the `sparkConf` map.

NOTE: Only one role group can have scheduled cleanups enabled (`cleaner: true`) and this role group cannot have more than 1 replica.

The secret with S3 credentials must contain at least the following two keys:

* `accessKey` - the access key of a user with read and write access to the event log bucket.
* `secretKey` - the secret key of a user with read and write access to the event log bucket.

Any other entries of the Secret are ignored by the operator.

== Application configuration


The example below demonstrates how to configure Spark applications to write log events to an S3 bucket.

[source,yaml]
----
include::example$example-history-app.yaml[]
----

<1> Location of the data that is being processed by the application.
<2> Credentials used to access the data above.
<3> Instruct the operator to configure the application with logging enabled.
<4> Folder to store logs. This must match the prefix used by the history server.
<5> Bucket to store logs. This must match the bucket used by the history server.
<6> Credentials used to write event logs. These can, of course, differ from the credentials used to process data.



== History Web UI

To access the history server web UI, use one of the `NodePort` services created by the operator. For the example above, the operator created two services as shown:

[source,bash]
----
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
spark-history-node NodePort 10.96.222.233 <none> 18080:30136/TCP 52m
spark-history-node-cleaner NodePort 10.96.203.43 <none> 18080:32585/TCP 52m
----

By setting up port forwarding on 18080 the UI can be opened by pointing your browser to `http://localhost:18080`:

image::history-server-ui.png[History Server Console]
59 changes: 26 additions & 33 deletions docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,57 +92,50 @@ include::example$example-sparkapp-configmap.yaml[]

You can specify S3 connection details directly inside the `SparkApplication` specification or by referring to an external `S3Bucket` custom resource.

To specify S3 connection details directly as part of the `SparkApplication` resource you add an inline bucket configuration as shown below.
To specify S3 connection details directly as part of the `SparkApplication` resource you add an inline connection configuration as shown below.

[source,yaml]
----
s3bucket: # <1>
s3connection: # <1>
inline:
bucketName: my-bucket # <2>
connection:
inline:
host: test-minio # <3>
port: 9000 # <4>
accessStyle: Path
credentials:
secretClass: s3-credentials-class # <5>
host: test-minio # <2>
port: 9000 # <3>
accessStyle: Path
credentials:
secretClass: s3-credentials-class # <4>
----
<1> Entry point for the bucket configuration.
<2> Bucket name.
<3> Bucket host.
<4> Optional bucket port.
<5> Name of the `Secret` object expected to contain the following keys: `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY`
<1> Entry point for the S3 connection configuration.
<2> Connection host.
<3> Optional connection port.
<4> Name of the `Secret` object expected to contain the following keys: `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY`

It is also possible to configure the bucket connection details as a separate Kubernetes resource and only refer to that object from the `SparkApplication` like this:
It is also possible to configure the connection details as a separate Kubernetes resource and only refer to that object from the `SparkApplication` like this:

[source,yaml]
----
s3bucket:
reference: my-bucket-resource # <1>
s3connection:
reference: s3-connection-resource # <1>
----
<1> Name of the bucket resource with connection details.
<1> Name of the connection resource with connection details.

The resource named `my-bucket-resource` is then defined as shown below:
The resource named `s3-connection-resource` is then defined as shown below:

[source,yaml]
----
---
apiVersion: s3.stackable.tech/v1alpha1
kind: S3Bucket
kind: S3Connection
metadata:
name: my-bucket-resource
name: s3-connection-resource
spec:
bucketName: my-bucket-name
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
credentials:
secretClass: minio-credentials-class
host: test-minio
port: 9000
accessStyle: Path
credentials:
secretClass: minio-credentials-class
----

This has the advantage that bucket configuration can be shared across `SparkApplication`s and reduces the cost of updating these details.
This has the advantage that one connection configuration can be shared across `SparkApplications` and reduces the cost of updating these details.

== Resource Requests

Expand Down Expand Up @@ -228,8 +221,8 @@ Below are listed the CRD fields that can be defined by the user:
|`spec.args`
|Arguments passed directly to the job artifact

|`spec.s3bucket`
|S3 bucket and connection specification. See the <<S3 bucket specification>> for more details.
|`spec.s3connection`
|S3 connection specification. See the <<S3 bucket specification>> for more details.

|`spec.sparkConf`
|A map of key/value strings that will be passed directly to `spark-submit`
Expand Down
11 changes: 4 additions & 7 deletions examples/ny-tlc-report-external-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ spec:
deps:
requirements:
- tabulate==0.8.9
s3bucket:
s3connection:
inline:
bucketName: my-bucket
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
host: test-minio
port: 9000
accessStyle: Path
sparkConf:
spark.hadoop.fs.s3a.aws.credentials.provider: "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider"
spark.driver.extraClassPath: "/dependencies/jars/*"
Expand Down
11 changes: 4 additions & 7 deletions examples/ny-tlc-report-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ spec:
deps:
requirements:
- tabulate==0.8.9
s3bucket:
s3connection:
inline:
bucketName: my-bucket
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
host: test-minio
port: 9000
accessStyle: Path
sparkConf:
spark.hadoop.fs.s3a.aws.credentials.provider: "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider"
executor:
Expand Down
11 changes: 4 additions & 7 deletions examples/ny-tlc-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ spec:
name: cm-job-arguments
args:
- "--input /arguments/job-args.txt"
s3bucket:
s3connection:
inline:
bucketName: my-bucket
connection:
inline:
host: test-minio
port: 9000
accessStyle: Path
host: test-minio
port: 9000
accessStyle: Path
sparkConf:
spark.hadoop.fs.s3a.aws.credentials.provider: "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider"
driver:
Expand Down
4 changes: 2 additions & 2 deletions rust/crd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ version = "0.7.0-nightly"
publish = false

[dependencies]
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag="0.27.1" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag="0.30.2" }

semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde = "1.0"
serde_json = "1.0"
serde_yaml = "0.8"
snafu = "0.7"
Expand Down
Loading