Skip to content

Commit de525e2

Browse files
jiangzhodongjoon-hyun
authored andcommitted
[SPARK-49464] Add documentations
### What changes were proposed in this pull request? This PR includes Operator docs under `docs/` for configuration, architecture, operations, and metrics. ### Why are the changes needed? Operator docs are necessary for users to understand the design and getting started with the operator installation ### Does this PR introduce _any_ user-facing change? No - new release ### How was this patch tested? CIs ### Was this patch authored or co-authored using generative AI tooling? No Closes #113 from jiangzho/doc. Authored-by: zhou-jiang <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent aa9be2d commit de525e2

File tree

9 files changed

+645
-0
lines changed

9 files changed

+645
-0
lines changed

build-tools/docs-utils/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ tasks.register('generateConfPropsDoc', Exec) {
3838
description = "Generate config properties doc for operator"
3939
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), javaMainClass, docsPath
4040
}
41+
42+
build.finalizedBy(generateConfPropsDoc)

docs/architecture.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Design & Architecture
21+
22+
**Spark-Kubernetes-Operator** (Operator) acts as a control plane to manage the complete
23+
deployment lifecycle of Spark applications and clusters. The Operator can be installed on Kubernetes
24+
cluster(s) using Helm. In most production environments it is typically deployed in a designated
25+
namespace and controls Spark workload in one or more managed namespaces.
26+
Spark Operator enables user to describe Spark application(s) or cluster(s) as
27+
[Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
28+
29+
The Operator continuously tracks events related to the Spark custom resources in its reconciliation
30+
loops:
31+
32+
For SparkApplications:
33+
34+
* User submits a SparkApplication custom resource(CR) using kubectl / API
35+
* Operator launches driver and observes its status
36+
* Operator observes driver-spawn resources (e.g. executors) and record status till app terminates
37+
* Operator releases all Spark-app owned resources to cluster
38+
39+
For SparkClusters:
40+
41+
* User submits a SparkCluster custom resource(CR) using kubectl / API
42+
* Operator launches master and worker(s) based on CR spec and observes their status
43+
* Operator releases all Spark-cluster owned resources to cluster upon failure
44+
45+
The Operator is built with the [Java Operator SDK](https://javaoperatorsdk.io/) for
46+
launching Spark deployments and submitting jobs under the hood. It also uses
47+
[fabric8](https://fabric8.io/) client to interact with Kubernetes API Server.
48+
49+
## Application State Transition
50+
51+
[<img src="resources/application_state_machine.png">](resources/application_state_machine.png)
52+
53+
* Spark applications are expected to run from submitted to succeeded before releasing resources
54+
* User may configure the app CR to time-out after given threshold of time if it cannot reach healthy
55+
state after given threshold. The timeout can be configured for different lifecycle stages,
56+
when driver starting and when requesting executor pods. To update the default threshold,
57+
configure `.spec.applicationTolerations.applicationTimeoutConfig` for the application.
58+
* K8s resources created for an application would be deleted as the final stage of the application
59+
lifecycle by default. This is to ensure resource quota release for completed applications.
60+
* It is also possible to retain the created k8s resources for debug or audit purpose. To do so,
61+
user may set `.spec.applicationTolerations.resourceRetainPolicy` to `OnFailure` to retain
62+
resources upon application failure, or set to `Always` to retain resources regardless of
63+
application final state.
64+
- This controls the behavior of k8s resources created by Operator for the application, including
65+
driver pod, config map, service, and PVC(if enabled). This does not apply to resources created
66+
by driver (for example, executor pods). User may configure SparkConf to
67+
include `spark.kubernetes.executor.deleteOnTermination` for executor retention. Please refer
68+
[Spark docs](https://spark.apache.org/docs/latest/running-on-kubernetes.html) for details.
69+
- The created k8s resources have `ownerReference` to their related `SparkApplication` custom
70+
resource, such that they could be garbage collected when the `SparkApplication` is deleted.
71+
- Please be advised that k8s resources would not be retained if the application is configured to
72+
restart. This is to avoid resource quota usage increase unexpectedly or resource conflicts
73+
among multiple attempts.
74+
75+
## Cluster State Transition
76+
77+
[<img src="resources/cluster_state_machine.png">](resources/application_state_machine.png)
78+
79+
* Spark clusters are expected to be always running after submitted.
80+
* Similar to Spark applications, K8s resources created for a cluster would be deleted as the final
81+
stage of the cluster lifecycle by default.

docs/config_properties.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[//]: # (This doc is automatically generated by gradle task, manual updates would be overridden.)
2+
# Spark Operator Config Properties
3+
| Key | Type | Default Value | Allow Hot Reloading | Description |
4+
| --- | --- | --- | --- | --- |
5+
| spark.kubernetes.operator.name | String | spark-kubernetes-operator | false | Name of the operator. |
6+
| spark.kubernetes.operator.namespace | String | default | false | Namespace that operator is deployed within. |
7+
| spark.kubernetes.operator.watchedNamespaces | String | default | true | Comma-separated list of namespaces that the operator would be watching for Spark resources. If set to '*', operator would watch all namespaces. |
8+
| spark.kubernetes.operator.terminateOnInformerFailureEnabled | Boolean | false | false | Enable to indicate informer errors should stop operator startup. If disabled, operator startup will ignore recoverable errors, caused for example by RBAC issues and will retry periodically. |
9+
| spark.kubernetes.operator.reconciler.terminationTimeoutSeconds | Integer | 30 | false | Grace period for operator shutdown before reconciliation threads are killed. |
10+
| spark.kubernetes.operator.reconciler.parallelism | Integer | 50 | false | Thread pool size for Spark Operator reconcilers. Unbounded pool would be used if set to non-positive number. |
11+
| spark.kubernetes.operator.reconciler.foregroundRequestTimeoutSeconds | Long | 30 | true | Timeout (in seconds) to for requests made to API server. This applies only to foreground requests. |
12+
| spark.kubernetes.operator.reconciler.intervalSeconds | Long | 120 | true | Interval (in seconds, non-negative) to reconcile Spark applications. Note that reconciliation is always expected to be triggered when app spec / status is updated. This interval controls the reconcile behavior of operator reconciliation even when there's no update on SparkApplication, e.g. to determine whether a hanging app needs to be proactively terminated. Thus this is recommended to set to above 2 minutes to avoid unnecessary no-op reconciliation. |
13+
| spark.kubernetes.operator.reconciler.trimStateTransitionHistoryEnabled | Boolean | true | true | When enabled, operator would trim state transition history when a new attempt starts, keeping previous attempt summary only. |
14+
| spark.kubernetes.operator.reconciler.appStatusListenerClassNames | String | | false | Comma-separated names of SparkAppStatusListener class implementations |
15+
| spark.kubernetes.operator.reconciler.clusterStatusListenerClassNames | String | | false | Comma-separated names of SparkClusterStatusListener class implementations |
16+
| spark.kubernetes.operator.dynamicConfig.enabled | Boolean | false | false | When enabled, operator would use config map as source of truth for config property override. The config map need to be created in spark.kubernetes.operator.namespace, and labeled with operator name. |
17+
| spark.kubernetes.operator.dynamicConfig.selector | String | app.kubernetes.io/name=spark-kubernetes-operator,app.kubernetes.io/component=operator-dynamic-config-overrides | false | The selector str applied to dynamic config map. |
18+
| spark.kubernetes.operator.dynamicConfig.reconcilerParallelism | Integer | 1 | false | Parallelism for dynamic config reconciler. Unbounded pool would be used if set to non-positive number. |
19+
| spark.kubernetes.operator.reconciler.rateLimiter.refreshPeriodSeconds | Integer | 15 | false | Operator rate limiter refresh period(in seconds) for each resource. |
20+
| spark.kubernetes.operator.reconciler.rateLimiter.maxLoopForPeriod | Integer | 5 | false | Max number of reconcile loops triggered within the rate limiter refresh period for each resource. Setting the limit <= 0 disables the limiter. |
21+
| spark.kubernetes.operator.reconciler.retry.initialIntervalSeconds | Integer | 5 | false | Initial interval(in seconds) of retries on unhandled controller errors. |
22+
| spark.kubernetes.operator.reconciler.retry.intervalMultiplier | Double | 1.5 | false | Interval multiplier of retries on unhandled controller errors. Setting this to 1 for linear retry. |
23+
| spark.kubernetes.operator.reconciler.retry.maxIntervalSeconds | Integer | -1 | false | Max interval(in seconds) of retries on unhandled controller errors. Set to non-positive for unlimited. |
24+
| spark.kubernetes.operator.api.retryMaxAttempts | Integer | 15 | false | Max attempts of retries on unhandled controller errors. Setting this to non-positive value means no retry. |
25+
| spark.kubernetes.operator.api.retryAttemptAfterSeconds | Long | 1 | false | Default time (in seconds) to wait till next request. This would be used if server does not set Retry-After in response. Setting this to non-positive number means immediate retry. |
26+
| spark.kubernetes.operator.api.statusPatchMaxAttempts | Long | 3 | false | Maximal number of retry attempts of requests to k8s server for resource status update. This would be performed on top of k8s client spark.kubernetes.operator.retry.maxAttempts to overcome potential conflicting update on the same SparkApplication. This should be positive number. |
27+
| spark.kubernetes.operator.api.secondaryResourceCreateMaxAttempts | Long | 3 | false | Maximal number of retry attempts of requesting secondary resource for Spark application. This would be performed on top of k8s client spark.kubernetes.operator.retry.maxAttempts to overcome potential conflicting reconcile on the same SparkApplication. This should be positive number |
28+
| spark.kubernetes.operator.metrics.josdkMetricsEnabled | Boolean | true | false | When enabled, the josdk metrics will be added in metrics source and configured for operator. |
29+
| spark.kubernetes.operator.metrics.clientMetricsEnabled | Boolean | true | false | Enable KubernetesClient metrics for measuring the HTTP traffic to the Kubernetes API Server. Since the metrics is collected via Okhttp interceptors, can be disabled when opt in customized interceptors. |
30+
| spark.kubernetes.operator.metrics.clientMetricsGroupByResponseCodeEnabled | Boolean | true | false | When enabled, additional metrics group by http response code group(1xx, 2xx, 3xx, 4xx, 5xx) received from API server will be added. Users can disable it when their monitoring system can combine lower level kubernetes.client.http.response.<3-digit-response-code> metrics. |
31+
| spark.kubernetes.operator.metrics.port | Integer | 19090 | false | The port used for checking metrics |
32+
| spark.kubernetes.operator.health.probePort | Integer | 19091 | false | The port used for health/readiness check probe status. |
33+
| spark.kubernetes.operator.health.sentinelExecutorPoolSize | Integer | 3 | false | Size of executor service in Sentinel Managers to check the health of sentinel resources. |
34+
| spark.kubernetes.operator.health.sentinelResourceReconciliationDelaySeconds | Integer | 60 | true | Allowed max time(seconds) between spec update and reconciliation for sentinel resources. |
35+
| spark.kubernetes.operator.leaderElection.enabled | Boolean | false | false | Enable leader election for the operator to allow running standby instances. When this is disabled, only one operator instance is expected to be up and running at any time (replica = 1) to avoid race condition. |
36+
| spark.kubernetes.operator.leaderElection.leaseName | String | spark-operator-lease | false | Leader election lease name, must be unique for leases in the same namespace. |
37+
| spark.kubernetes.operator.leaderElection.leaseDurationSeconds | Integer | 180 | false | Leader election lease duration in seconds, non-negative. |
38+
| spark.kubernetes.operator.leaderElection.renewDeadlineSeconds | Integer | 120 | false | Leader election renew deadline in seconds, non-negative. This needs to be smaller than the lease duration to allow current leader renew the lease before lease expires. |
39+
| spark.kubernetes.operator.leaderElection.retryPeriodSeconds | Integer | 5 | false | Leader election retry period in seconds, non-negative. |
40+

0 commit comments

Comments
 (0)