-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add oauth2-proxy sidecar support #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Spark Driver UI Access | ||
|
|
||
| ## Direct Access | ||
|
|
||
| ### Port-forward (simplest) | ||
|
|
||
| ```bash | ||
| kubectl -n <namespace> port-forward <driver-pod-name> 4040:4040 | ||
| ``` | ||
|
|
||
| Then open: `http://localhost:4040` | ||
|
|
||
| **Finding the pod:** Check Lookout UI for job details. Pod name is typically `armada-<job-id>-0`. | ||
|
|
||
| ### Basic Ingress (no auth) | ||
|
|
||
| ```bash | ||
| --conf spark.armada.driver.ingress.enabled=true | ||
| ``` | ||
|
|
||
| **Warning:** Exposes UI publicly without authentication! | ||
|
|
||
| --- | ||
|
|
||
| ## OAuth2-Protected Access | ||
|
|
||
| Uses [oauth2-proxy](https://oauth2-proxy.github.io/oauth2-proxy/) as a native sidecar for authentication. | ||
|
|
||
| ### Quick Start | ||
|
|
||
| ```bash | ||
| /opt/spark/bin/spark-class org.apache.spark.deploy.ArmadaSparkSubmit \ | ||
| --master armada://localhost:50051 \ | ||
| --deploy-mode cluster \ | ||
| --name my-secure-job \ | ||
| --class org.apache.spark.examples.SparkPi \ | ||
| --conf spark.armada.container.image=armada-spark \ | ||
| --conf spark.armada.oauth.enabled=true \ | ||
| --conf spark.armada.oauth.clientId=spark-oauth-client \ | ||
| --conf spark.armada.oauth.clientSecret=your-secret \ | ||
| --conf spark.armada.oauth.issuerUrl=https://keycloak.example.com/realms/spark \ | ||
| --conf spark.armada.driver.ingress.enabled=true \ | ||
| --conf spark.armada.driver.ingress.tls.enabled=true \ | ||
| --conf spark.armada.driver.ingress.certName=my-tls-cert \ | ||
| local:///opt/spark/examples/jars/spark-examples.jar | ||
| ``` | ||
|
|
||
| **What happens:** | ||
| 1. `oauth` sidecar container added to driver pod | ||
| 2. Ingress → oauth2-proxy (port 4180) → authenticates user → Spark UI (localhost:4040) | ||
| 3. oauth2-proxy terminates when driver completes | ||
|
|
||
| ### Configuration Examples | ||
|
|
||
| See [OAuth2 Authentication Configuration](./architecture.md#oauth2-authentication-configuration) for all parameters. | ||
|
|
||
| **Using OIDC discovery:** | ||
| ```bash | ||
| --conf spark.armada.oauth.enabled=true \ | ||
| --conf spark.armada.oauth.clientId=my-client \ | ||
| --conf spark.armada.oauth.clientSecret=my-secret \ | ||
| --conf spark.armada.oauth.issuerUrl=https://provider.com/realms/spark \ | ||
| --conf spark.armada.driver.ingress.enabled=true \ | ||
| --conf spark.armada.driver.ingress.tls.enabled=true | ||
| ``` | ||
|
|
||
| **Manual endpoints (no discovery):** | ||
| ```bash | ||
| --conf spark.armada.oauth.enabled=true \ | ||
| --conf spark.armada.oauth.skipProviderDiscovery=true \ | ||
| --conf spark.armada.oauth.loginUrl=https://provider.com/auth \ | ||
| --conf spark.armada.oauth.redeemUrl=http://provider.svc.cluster.local/token \ | ||
| --conf spark.armada.oauth.validateUrl=http://provider.svc.cluster.local/userinfo \ | ||
| --conf spark.armada.oauth.jwksUrl=http://provider.svc.cluster.local/certs | ||
| ``` | ||
|
|
||
| **Use cluster-internal URLs** for `redeemUrl`/`validateUrl`/`jwksUrl`, external URL for `loginUrl`. | ||
|
|
||
| **Using K8s secrets (recommended):** | ||
| ```bash | ||
| kubectl create secret generic spark-oauth-secret \ | ||
| --from-literal=client-secret=your-secret -n spark-jobs | ||
|
|
||
| --conf spark.armada.oauth.clientId=my-client \ | ||
| --conf spark.armada.oauth.clientSecretK8s=spark-oauth-secret | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### 502 Bad Gateway after login | ||
|
|
||
| **Cause:** Spark UI not running (job finished too quickly or UI disabled) | ||
|
|
||
| **Check logs:** | ||
| ```bash | ||
| kubectl logs -n <namespace> <driver-pod> -c oauth | ||
| ``` | ||
|
|
||
| Look for: `Error proxying to upstream server: dial tcp 127.0.0.1:4040: connect: connection refused` | ||
|
|
||
| **Solutions:** | ||
| - Use longer-running job (Spark Pi finishes in seconds) | ||
| - Spark UI has 90s delay after job completion by default | ||
| - Verify `spark.ui.enabled=true` (default) | ||
|
|
||
| ### Authentication keeps redirecting | ||
|
|
||
| **Cause:** Cookie config or OIDC provider issues | ||
|
|
||
| **Solutions:** | ||
| ```bash | ||
| # For HTTP (dev only): | ||
| --conf spark.armada.oauth.cookieSecure=false | ||
|
|
||
| # Check SameSite: | ||
| --conf spark.armada.oauth.cookieSamesite=lax | ||
|
|
||
| # Verify redirect URL matches OIDC provider config: | ||
| --conf spark.armada.oauth.redirectUrl=https://your-host/oauth2/callback | ||
| ``` | ||
|
|
||
| ### Finding ingress URL | ||
|
|
||
| In Lookout, under Result tab, as soon as a Job is leased to a Cluster and bound to a Node, the Ingress URL will be accessible in that tab. | ||
|
|
||
| Or alternatively, the Ingress URL can be looked up by fetching the Ingress from the namespace where the Job is scheduled. | ||
| ```bash | ||
| kubectl get ingress -n <namespace> | ||
| # Output: oauth-4180-armada-<job-id>-0.namespace.svc | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Resources | ||
|
|
||
| - [OAuth2 Configuration Reference](./architecture.md#oauth2-authentication-configuration) | ||
| - [oauth2-proxy docs](https://oauth2-proxy.github.io/oauth2-proxy/) | ||
| - [Spark UI docs](https://spark.apache.org/docs/latest/web-ui.html) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.