Add multi-tenant Databricks token support via cross-namespace K8s secrets#3394
Merged
machichima merged 2 commits intoflyteorg:masterfrom Mar 10, 2026
Merged
Conversation
|
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
3 tasks
pingsutw
approved these changes
Mar 4, 2026
Member
|
lgtm, thank you! Could you fix the lint errors? |
7ceb06f to
9eef1e0
Compare
pingsutw
approved these changes
Mar 4, 2026
9eef1e0 to
048ed2e
Compare
…space K8s secrets Enable per-project Databricks authentication by reading tokens from Kubernetes secrets in workflow namespaces, with backward-compatible fallback to the FLYTE_DATABRICKS_ACCESS_TOKEN environment variable. Changes: - Add get_secret_from_k8s() for cross-namespace K8s secret reading - Add get_databricks_token() with tiered resolution (K8s -> env var) - Update DatabricksJobMetadata to persist auth_token across lifecycle - Update DatabricksConnector.create/get/delete to use per-project tokens - Add DatabricksV2.databricks_token_secret for custom secret names - Add 31 comprehensive tests covering all token resolution paths Tracking: flyteorg/flyte#6911 Signed-off-by: Rohit Sharma <rohitrsh@gmail.com>
048ed2e to
0cfa9c8
Compare
Contributor
Author
Hey @pingsutw, so here's what I have done to fix the lint issue. Lint fix: Restored The lint CI was failing because Without the baseline, Pydoclint treated every pre-existing violation in the entire codebase as a new error, causing the failures in ruff, ruff-format, trailing-whitespace, and Pydoclint checks. What was done:
|
e13f8f9 to
1df2ae5
Compare
Resolve merge conflicts in task.py after flyteorg#3392 (serverless) was merged: - Combined DatabricksV2 attributes: kept all serverless fields, added databricks_token_secret - Combined get_custom() serialization for both feature sets - Added auth_token to serverless test metadata assertion - Removed emoji from error message Signed-off-by: Rohit Sharma <rohitrsh@gmail.com> Made-with: Cursor
1df2ae5 to
148e088
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking issue
Related to flyteorg/flyte#6911
Why are the changes needed?
The Databricks Spark connector currently uses a single global
FLYTE_DATABRICKS_ACCESS_TOKENenvironment variable for authenticating all Databricks API calls. This creates significant limitations for multi-tenant Flyte deployments:This PR adds per-project Databricks token support by enabling the connector to read tokens from Kubernetes secrets in the workflow's project namespace, with backwards-compatible fallback to the existing environment variable.
What changes were proposed in this pull request?
Token Resolution Strategy
The connector now resolves Databricks tokens using a tiered strategy:
databricks-token, key:token) from the workflow's Kubernetes namespace using cross-namespace lookup.FLYTE_DATABRICKS_ACCESS_TOKENif no namespace secret is found.Changes
connector.py:get_secret_from_k8s(secret_name, secret_key, namespace)Cross-namespace K8s secret reader using the Kubernetes Python client. Tries in-cluster config first, falls back to kubeconfig for local development.get_databricks_token(namespace, task_template, secret_name). Implements the token resolution strategy with structured logging and error handling.get_header()Now accepts an optionalauth_tokenparameter.DatabricksJobMetadataAddedauth_tokenfield to persist the resolved token across create/get/delete operations.DatabricksConnector.create(). Now acceptstask_execution_metadataparameter, extracts the namespace, and resolves the project-specific token.DatabricksConnector.get()/delete()Use storedauth_tokenfrom metadata.task.py:databricks_token_secretfield toDatabricksV2Allows users to specify a custom K8S secret name per task.get_custom()SerialisesdatabricksTokenSecretinto the task template custom dict.User Experience
No changes needed for existing users Existing workflows continue to work with the global
FLYTE_DATABRICKS_ACCESS_TOKEN.New capability for multi-tenant setups:
How was this patch tested?
Unit Tests (
test_databricks_token.py)30+ test cases covering:
get_secret_from_k8s:get_databricks_token:get_header:DatabricksJobMetadata:DatabricksConnector:DatabricksV2task config:Setup process
getpermission on secrets across namespaces:kubectl create secret generic databricks-token \ --from-literal=token='your-token' \ --namespace=your-project-namespaceScreenshots
N/A (backend-only change)
Check all the applicable boxes
Related PRs
Docs link
N/A