feat(spark)!: delegate SparkApplication driver service account to the Spark Operator #776
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
🎉 Welcome to the Kubeflow SDK! 🎉
Thanks for opening your first PR! We're happy to have you as part of our community 🚀
Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏
/ok-to-test
/retest
service_account=driver.service_account if driver else None, should be removed.
)
assert spec.service_account is None
This change is not necessary.
spec = get_spark_job_driver_spec()
/retitle feat(spark)!: delegate SparkApplication driver service account to the Spark Operator
The Spark examples run against a Kubernetes cluster with the Spark Operator installed. The SDK does not set a ServiceAccount on the driver spec, so the Spark Operator must be configured with a fallback ServiceAccount that can create executor pods in the target namespace (`controller.defaultServiceAccount` in the Helm chart). See the [Spark SDK docs](https://sdk.kubeflow.org/en/latest/spark/index.html) for prerequisites.
``SparkClient`` does not set a ServiceAccount on the driver spec. Both
interactive sessions and batch jobs need the driver to run as a
ServiceAccount with permission to create executor pods in the target
namespace. That ServiceAccount is provisioned and selected by the platform,
not by the SDK.
On a Kubeflow Platform install, the Profile controller creates a
``default-editor`` ServiceAccount in every profile namespace and binds it to
the ``kubeflow-edit`` ClusterRole, which covers pods and services
in-namespace. Set ``controller.defaultServiceAccount=default-editor`` in the
Spark Operator Helm chart so the operator falls back to it. On a standalone
Spark Operator install, set it to a ServiceAccount that exists in every
namespace where you submit jobs — for example the ``<release>-spark``
account the chart creates in the namespaces listed under
``spark.jobNamespaces``.
When ``controller.defaultServiceAccount`` is unset, the driver runs as the
namespace's ``default`` ServiceAccount and the job fails with a
``403 Forbidden`` error when the driver tries to create executor pods.
Interactive sessions can override the ServiceAccount per session with
``Driver(service_account=...)``; batch jobs have no per-job override.
We do not need the second test case.
config={},
The service account is intentionally left unset so that the Spark
Operator's configured fallback service account is used.
Hi @adibmbrk! I have added a few comments.
/assign
/retest
Looks good for the default case. Can we also add a case that passes Driver(service_account="something") and asserts it comes through untouched?
Thanks for the PR!
Addressed in a739415
Hi @tariq-hasan @Goku2099! Thank you for the review. I have addressed all your comments. Let me know if further changes are needed.
Actually we can do without this test case. It will bring back the redundant driver.service_account pass-through. Let's remove the last commit.
Thanks!
/lgtm
@andreyvelich I am wondering how we should move this PR forward. This change depends on https://github.com/kubeflow/spark-operator/issues/3049 which has been completed recently.
As there is an upstream dependency that has not been released yet I am thinking if we'd need a release note for the breaking change that would basically only work for the next operator release - v2.6.0.
I don't think we need it.
/retest
/retest
Hi @tariq-hasan, the E2E check has failed in this PR, I believe it's a flake, would you be able to trigger the tests once again to confirm.
/ok-to-test
/retest
/retest
/ok-to-test
/retest
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubeflow/sdk/pull/776#pullrequestreview-5444598294" title="Approved">andreyvelich</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
tariq-hasan
adibmbrk
What this PR does / why we need it:
Removes the hardcoded
spark-operator-sparkdefault service account for theSparkApplicationdriver spec. The Spark Operator now supports a fallback service account mechanism for the driver (kubeflow/spark-operator#3092, merged), so the SDK no longer needs to set this default itself.get_spark_job_driver_specnow leavesservice_accountunset unless a caller explicitly provides one viaDriver.service_account, keeping the SDK decoupled from operator cluster-admin concerns.Which issue(s) this PR fixes:
Fixes #616
Checklist: