-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add support for application templates #660
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
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ec247bc
add new CRD for application templates
razvan f9eab02
convert SparkApplication to dynamic object
razvan 6098115
Revert "convert SparkApplication to dynamic object"
razvan ed8d67e
added new crd::merger module (not used yet)
razvan 798b62b
implement logic to merge application templates
razvan d562d2a
Merge branch 'main' into feat/app-templates
razvan 20a0a8d
update application result fields and implement onCreate update strategy
razvan 5de6ef9
dev docs, op tracing and more unit tests
razvan fa9c19f
register new CRD with webhook, update helm templates, successfully ru…
razvan af4935e
user docs
razvan 8b68257
cosmetics: rename module for clarity
razvan 8d10908
chore: Generated commit to update templated files since the last temp…
stackable-bot 807140e
Apply suggestions from code review
razvan 6815c12
update docs
razvan fe28b00
fix clippy warnings
razvan 4dd5615
Merge remote-tracking branch 'origin/main' into feat/app-templates
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
docs/modules/spark-k8s/pages/usage-guide/app_templates.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| = Spark Application Templates | ||
| :description: Learn how to configure application templates for Spark applications on the Stackable Data Platform. | ||
|
|
||
| Spark application templates are used to define reusable configurations for Spark applications. | ||
| When you have many applications with similar configurations, templates can help you avoid duplication by grouping common settings together. | ||
| Application templates are available for the `v1alpha1` version of the SparkApplication custom resource and share the exact same structure as the SparkApplication resource, but with some differences in the way the operator handles them: | ||
|
|
||
| 1. Application templates are cluster wide resources, while Spark application resources are namespace-scoped. | ||
| This means that application templates can be used across multiple namespaces, while Spark application resources are limited to the namespace they are created in. | ||
| 2. Application templates are not reconciled by the operator, but must be referenced from a SparkApplication resource to be applied. This means that changes to an application template will not automatically trigger updates to SparkApplication resources that reference it. | ||
| 3. An application can reference multiple application templates, and the settings from these templates will be merged together. The merging order of the templates is indicated by their index in the reference list. The application fields have the highest precedence and will override any conflicting settings from the templates. This allows you to have a base template with common settings and then override specific settings in the application resource as needed. | ||
| 4. Application template references are immutable in the sense that once applied to an application they cannot be changed again. Currently templates are applied upon the creation of the application, and any changes to the template references after that will be ignored. | ||
| 5. Application and template CRDs must have the exact same versions. Currently only `v1alpha1` is supported. | ||
|
|
||
| == Examples | ||
|
|
||
| Applications use `metadata.annotations` to reference application templates as shown below: | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| --- | ||
| apiVersion: spark.stackable.tech/v1alpha1 | ||
| kind: SparkApplication | ||
| metadata: | ||
| name: app | ||
| annotations: | ||
| spark-application.template.merge: "true" # <1> | ||
adwk67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| spark-application.template.0.name: "app-template" # <2> | ||
| spark-application.template.upgradeStrategy: "onCreate" # <3> | ||
| spark-application.template.applyStrategy: "enforce" # <4> | ||
| spec: # <5> | ||
| sparkImage: | ||
| productVersion: "4.1.1" | ||
| mode: cluster | ||
| mainClass: com.example.Main | ||
| mainApplicationFile: "/examples.jar" | ||
| ---- | ||
| <1> Enable application template merging for this application. | ||
| <2> Name of the application template to reference. | ||
| <3> Optional. The upgrade strategy for the application template. Currently only `onCreate` is supported. This means that the application template will only be applied when the application is created, and any changes to the template after that will be ignored. | ||
| <4> Optional. The apply strategy for the application template. Currently only `enforce` is supported. This means that any errors that appear during the application of the template will be treated as errors for the application resource, and the application will not be created or updated until the errors are resolved. | ||
| <5> Application specification. The fields `sparkImage`, `mode`, `mainClass`, and `mainApplicationFile` are required for the application to be valid, but the rest of the fields are optional and can be defined in the application template. | ||
|
|
||
| The application template referenced in the example above is defined as follows: | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| --- | ||
| apiVersion: spark.stackable.tech/v1alpha1 | ||
| kind: SparkApplicationTemplate # <1> | ||
| metadata: | ||
| name: app-template # <2> | ||
| spec: | ||
| sparkImage: | ||
| productVersion: "4.1.1" | ||
| pullPolicy: IfNotPresent | ||
| mode: cluster | ||
| mainClass: com.example.Main | ||
| mainApplicationFile: "placeholder" # <3> | ||
| sparkConf: | ||
| spark.kubernetes.file.upload.path: "s3a://my-bucket" | ||
| s3connection: | ||
| reference: spark-history-s3-connection | ||
| logFileDirectory: | ||
| s3: | ||
| prefix: eventlogs/ | ||
| bucket: | ||
| reference: spark-history-s3-bucket | ||
| driver: | ||
| config: | ||
| logging: | ||
| enableVectorAgent: False | ||
| executor: | ||
| replicas: 1 | ||
| config: | ||
| logging: | ||
| enableVectorAgent: False | ||
| ---- | ||
| <1> The kind of the resource is `SparkApplicationTemplate` to indicate that this is an application template. | ||
| <2> Name of the application template. | ||
| <3> The value of `mainApplicationFile` is set to a placeholder value, which will be overridden by the application resource. Similarly to the application, The fields `sparkImage`, `mode`, `mainClass`, and `mainApplicationFile` are required for the template to be valid. | ||
adwk67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| An application can reference multiple application templates as shown below: | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| --- | ||
| apiVersion: spark.stackable.tech/v1alpha1 | ||
| kind: SparkApplication | ||
| metadata: | ||
| name: app | ||
| annotations: | ||
| spark-application.template.merge: "true" # <1> | ||
| spark-application.template.0.name: "app-template-0" # <2> | ||
| spark-application.template.1.name: "app-template-1" | ||
| spark-application.template.2.name: "app-template-2" | ||
| spec: # <3> | ||
| sparkImage: | ||
| productVersion: "4.1.1" | ||
| mode: cluster | ||
| mainClass: com.example.Main | ||
| mainApplicationFile: "/examples.jar" | ||
| ---- | ||
| <1> Enable application template merging for this application. | ||
| <2> The name of the application templates to reference. The settings from these templates will be merged together in the order they are referenced, with `app-template-0` having the lowest precedence and `app-template-2` having the highest precedence. The application fields have the highest overall precedence and will override any conflicting settings from the templates. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.