zwangsheng commented on code in PR #2: URL: https://github.com/apache/spark-kubernetes-operator/pull/2#discussion_r1560388851
########## spark-operator-docs/architecture.md: ########## @@ -0,0 +1,64 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# Design & Architecture + +**Spark-Kubernetes-Operator** (Operator) acts as a control plane to manage the complete +deployment lifecycle of Spark applications. The Operator can be installed on a Kubernetes +cluster using Helm. In most production environments it is typically deployed in a designated +namespace and controls Spark deployments in one or more managed namespaces. The custom resource +definition (CRD) that describes the schema of a SparkApplication is a cluster wide resource. +For a CRD, the declaration must be registered before any resources of that CRDs kind(s) can be +used, and the registration process sometimes takes a few seconds. + +Users can interact with the operator using the kubectl or k8s API. The Operator continuously +tracks cluster events relating to the SparkApplication custom resources. When the operator +receives a new resource update, it will take action to adjust the Kubernetes cluster to the +desired state as part of its reconciliation loop. The initial loop consists of the following +high-level steps: + +* User submits a SparkApplication custom resource(CR) using kubectl / API +* Operator launches driver and observes its status +* Operator observes driver-spawn resources (e.g. executors) till app terminates +* Operator releases all Spark-app owned resources to cluster +* The SparkApplication CR can be (re)applied on the cluster any time - e.g. to issue proactive + termination of an application. The Operator makes continuous adjustments to imitate the + desired state until the + current state becomes the desired state. All lifecycle management operations are realized + using this very simple + principle in the Operator. + +The Operator is built with the Java Operator SDK and uses the Native Kubernetes Integration for +launching Spark deployments and submitting jobs under the hood. The Java Operator SDK is a +higher level +framework and related tooling to support writing Kubernetes Operators in Java. Both the Java +Operator SDK and Spark’s native +kubernetes integration itself is using the Fabric8 Kubernetes Client to interact with the +Kubernetes API Server. + +## State Transition + +[<img src="resources/state.png">](resources/state.png) Review Comment: Will `Running with below Threshold Executor` turn into `Failed`? ########## README.md: ########## @@ -1 +1,44 @@ -# spark-kubernetes-operator +# Spark-Kubernetes-Operator + +Welcome to the **Spark-Kubernetes-Operator**, a Kubernetes operator designed to simplify and +automate the management of Spark applications in Kubernetes environments. + +## Project Status + +As of Apr 1, 2024, Spark-Kubernetes-Operator is under Active Development. + +- We are actively working on new features and improvements. We welcome contributions and + feedback to make the operator even better. Check out the **Issues** section to see what's + currently in progress or suggest new features. +- Current API Version: `v1alpha1` + +## Key Features + +- Deploy and monitor SparkApplications throughout its lifecycle +- Start / stop Spark Apps with simple yaml schema +- Spark version agnostic +- Full logging and metrics integration +- Flexible deployments and native integration with Kubernetes tooling + +Please refer the [design](spark-operator-docs/architecture.md) section for architecture and +design. + +## Quickstart + +[Getting started doc](./spark-operator-docs/getting_started.md) gives an example to install +operator and run Spark Applications locally. + +In addition, [SparkApplication](./spark-operator-docs/spark_application.md) section +describes how to write your own apps, [Operations](./spark-operator-docs/operations.md) section +describes how to install operator with custom config overriding. + + + +## Contributing + +You can learn more about how to contribute in the [Apache Spark website](https://spark. +apache.org/contributing.html). Review Comment: Keep in same line, otherwise, it will incorrectly display. ########## spark-operator-docs/getting_started.md: ########## @@ -0,0 +1,193 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## Getting Started + +This doc provides a quick introduction to creating and managing Spark applications with +Operator. + +To follow along with this guide, first, clone this repository and have a +[Minikube](https://minikube.sigs.k8s.io/docs/) cluster ready for a quick start of running examples +locally. Make sure to update kube config as well - this example would deploy Spark Operator +and run Spark application(s) in the current context and namespace. + +It is possible to try the operator on remote k8s cluster (EKS / GKE .etc). To do so, make +sure you publish the built operator image to a docker registry that's accessible for the +cluster. + +### Compatibility + +- JDK11, 17, or 23 +- Operator used fabric8 which assumes to be compatible with available k8s versions. +- Spark versions 3.4 and above + +### Start minikube + +Start miniKube and make it access locally-built image + +```shell +minikube start +eval $(minikube docker-env) +``` + +### Build Spark Operator Locally + + ```bash + # Build a local container image which can be used for minikube.etc. + # For testing in remote k8s cluster, please also do `docker push` to make it available + # to the cluster / nodes + docker build --build-arg BASE_VERSION=1.0.0-alpha -t spark-kubernetes-operator:1.0.0-alpha . + + # Generate CRD yaml and make it available for chart deployment + ./gradlew spark-operator-api:copyGeneratedCRD Review Comment: Maybe we should try to mention some preliminaries in this local, such as installing helm and yq. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
