jerryshao opened a new issue, #13613:
URL: https://github.com/apache/gravitino/issues/13613

   ### Describe the subtask
   
   Add a job executor named `k8s` in a new module `plugins/k8s-job-executor`. 
It runs SPARK job templates as `SparkApplication` resources of 
[apache/spark-kubernetes-operator](https://github.com/apache/spark-kubernetes-operator)
 0.9.x through the fabric8 Kubernetes client. It rejects SHELL templates for 
now.
   
   - Module: a shaded jar with fabric8 kubernetes-client 7.2.0 and its JDK HTTP 
client. Jackson and SnakeYAML are relocated to 
`org.apache.gravitino.k8s.shaded`.
   - Connection, configured with the `gravitino.jobExecutor.k8s.` prefix: 
`kubeconfig` and `context`, or `masterUrl`, `caCertFile` and `tokenFile`. The 
token file is re-read when it changes. If neither is set, fabric8's default 
lookup applies. Setting both is an error. `cluster` names the job cluster, 
`default` by default.
   - Job identity: each job gets a SparkApplication named 
`<namePrefix>-<jobId>`, labeled `app.kubernetes.io/managed-by=gravitino` and 
`gravitino.apache.org/job-id=<jobId>`. Its job execution id is 
`<cluster>/sparkapp/<namespace>/<name>`. The namespace is the job's 
`spark.kubernetes.namespace`, or the `namespace` config if that isn't set. On a 
409 conflict, the existing resource is adopted only if it carries the same job 
id label.
   - Mapping: the executable, main class, arguments, jars, files, archives and 
Spark configs go into the SparkApplication. The operator owns `spark.master` 
and `spark.submit.deployMode`, so they are removed. The image, driver service 
account and Spark version come from the executor config as defaults. Resources 
must be URIs reachable from the cluster, so paths without a scheme and 
`file://` URIs are rejected. Unresolved placeholders are rejected too. 
Templates with environment variables are rejected until they can be passed 
through Secrets.
   - Lifecycle: `restartPolicy: Never`, and `resourceRetainPolicy: Always` 
keeps the driver pod so its output can be read. The pod retain duration, the 
SparkApplication TTL and the operator's start timeouts are configurable.
   - Status: operator states map to Gravitino statuses. The final states 
`ResourceReleased` and `TerminatedWithoutReleaseResources` walk back through 
`stateTransitionHistory` to the last outcome, and the started and finished 
times also come from that history. A SparkApplication that has no status after 
`noStatusTimeoutMs` is failed.
   - Status queries LIST each namespace once and cache the result for 
`statusCacheTtlMs`. A cache miss falls back to a GET, and only a 404 raises 
`NoSuchJobException`.
   - Cancel: the SparkApplication gets a cancel-requested annotation, then is 
deleted with `Foreground` propagation. The job is reported `CANCELLED` only 
when the annotation is set and the SparkApplication is being deleted or has 
finished.
   - Output: stdout is the tail of the driver pod log. Kubernetes merges stdout 
and stderr, so stderr is empty.
   
   Separate subtasks cover registering the executor and shipping it in the 
distribution, built-in jobs, environment variables through Secrets, 
`maxActiveJobs`, the Spark image and docs.
   
   ### Parent issue
   
   #13554
   


-- 
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]

Reply via email to