Skip to content

feat(operator): Auto-create RBAC for spark_application batch engine#6597

Merged
ntkathole merged 8 commits into
feast-dev:masterfrom
aniketpalu:feat/operator-batch-engine-rbac
Jul 18, 2026
Merged

feat(operator): Auto-create RBAC for spark_application batch engine#6597
ntkathole merged 8 commits into
feast-dev:masterfrom
aniketpalu:feat/operator-batch-engine-rbac

Conversation

@aniketpalu

@aniketpalu aniketpalu commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

When batch_engine: spark_application is configured, the Feast Operator creates a bare ServiceAccount with no Roles/RoleBindings. Materialization then fails with 403 Forbidden until users manually create server + driver RBAC.

This PR makes the operator auto-reconcile that RBAC from an embedded YAML template, and ensures the Spark driver uses the same ServiceAccount the operator creates.

Changes

  1. Auto-create batch-engine RBAC (batch_engine_rbac.go + rbac_templates/spark_application.yaml)

    • Server Role/RoleBinding on feast-<name>: ConfigMaps, SparkApplications, pods list, pods/log
    • Driver SA + Role/RoleBinding (feast-<name>-batch-driver by default): pods/services/configmaps/PVCs (incl. deletecollection) for Spark driver executor lifecycle
    • Resources are owner-referenced to the FeatureStore CR
    • Engine types without a template are a no-op; removing/changing engine cleans up owned RBAC
  2. Minimal operator ClusterRole widening (kubebuilder markers → role.yaml / CSV / install)

    • sparkoperator.k8s.io/sparkapplications: create/get/delete
    • pods/log: get
    • pods + services/configmaps/PVCs: verbs needed to grant driver Role (incl. deletecollection)
    • No secrets widening
  3. Bake default driver service_account into feature_store.yaml

    • If ConfigMap omits service_account, inject feast-<FeatureStoreName>-batch-driver
    • Explicit service_account overrides are preserved
    • Injection is limited to type: spark_application so other engines are unchanged

Design notes

  • Template-based handler so future engines (ray, k8s) can add a YAML file without new Go reconcile logic
  • Validated on OpenShift E2E: SparkApplication COMPLETED, materialize 10/10, 0 Forbidden, online features PRESENT

Which issue(s) this PR fixes:

Related to the same class of gap as #6408 (KubeRay RBAC). Enables zero-manual-RBAC materialization for spark_application.

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Manual (OpenShift E2E)

  • FeatureStore with batch_engine: spark_application (ConfigMap omitting service_account)
  • Operator created feast-<name>-batch-engine + feast-<name>-batch-driver Role/RoleBinding/SA
  • Baked config contained service_account: feast-<name>-batch-driver
  • SparkApplication completed; materialization succeeded without manual RBAC

Misc

Reconcile server/driver Roles from an embedded YAML template so FeatureStore
materialization works without manual SA/Role setup. Widen the operator
ClusterRole only as needed to grant those permissions (including
deletecollection for Spark driver cleanup).

Signed-off-by: Aniket Paluskar <[email protected]>
@aniketpalu
aniketpalu requested a review from a team as a code owner July 9, 2026 20:58
aniketpalu added a commit to aniketpalu/feast that referenced this pull request Jul 14, 2026
aniketpalu added a commit to aniketpalu/feast that referenced this pull request Jul 14, 2026
aniketpalu and others added 2 commits July 16, 2026 15:27
When batch_engine.service_account is omitted, inject feast-<cr>-batch-driver so the SparkApplication matches the SA/RBAC the operator already creates (R2-2).

Co-authored-by: Cursor <[email protected]>
Signed-off-by: Aniket Paluskar <[email protected]>
Limit service_account baking to spark_application so other batch engines
are not given an unexpected parameter.

Signed-off-by: Aniket Paluskar <[email protected]>
@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.64%. Comparing base (e0a8573) to head (3c00206).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6597   +/-   ##
=======================================
  Coverage   45.64%   45.64%           
=======================================
  Files         412      412           
  Lines       48761    48761           
  Branches     6913     6913           
=======================================
  Hits        22257    22257           
  Misses      24957    24957           
  Partials     1547     1547           
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 46.92% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0a8573...3c00206. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

aniketpalu added a commit to aniketpalu/feast that referenced this pull request Jul 16, 2026
… merged-spark-e2e

Includes spark_application-only SA bake-in.
aniketpalu and others added 3 commits July 16, 2026 18:03
gofmt repo_config_test map literals and refresh .secrets.baseline
line numbers after batch-engine RBAC wiring in services.go.

Signed-off-by: Aniket Paluskar <[email protected]>
}

if tmpl.Driver != nil {
driverSAName := feast.getBatchDriverSAName()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBatchEngineType() and getBatchDriverSAName() independently fetch and parse the same ConfigMap during a single reconcile. Should parse once and pass the result.

aniketpalu and others added 2 commits July 18, 2026 13:35
Share getBatchEngineConfig() for engine type and driver SA resolution
instead of fetching/parsing the same ConfigMap twice.

Signed-off-by: Aniket Paluskar <[email protected]>
@ntkathole
ntkathole merged commit f487b37 into feast-dev:master Jul 18, 2026
24 checks passed
aniketpalu added a commit to aniketpalu/feast that referenced this pull request Jul 18, 2026
Pick up feast-dev#6597 (operator batch-engine RBAC) and Iceberg REST catalog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants