-
-
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
base: main
Are you sure you want to change the base?
Changes from all commits
ec247bc
f9eab02
6098115
ed8d67e
798b62b
d562d2a
20a0a8d
5de6ef9
fa9c19f
af4935e
8b68257
8d10908
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,99 @@ | ||||||||
| = 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. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sentences should be on new lines in the docs e.g.
Suggested change
(not sure if we want indenting there...) |
||||||||
| 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. | ||||||||
|
|
||||||||
| == 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> | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be good to include all available annotations in the example to be comprehensive. |
||||||||
| spark-application.template.0.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> Name of the application template to reference. | ||||||||
| <3> 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. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have to have define sparkImage etc. both in the template and the app? Is the plan with v1alpha2 to remove them as being mandatory in the application so we can only have them in the template (or override them)? If so, can they be optional in the template? |
||||||||
|
|
||||||||
| 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. Tha application fields have the highest overall precedence and will override any conflicting settings from the templates. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know yet if the plan is to keep versions in step with another (e.g a v1alpha2 is created for one entity when the other entity is bumped to v1alpha2). I think that might make mapping between app and template a little easier.