Skip to content
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

#1329 update the operator to allow subpaths to be used with the spark ui ingress. #1330

Merged
merged 2 commits into from
Oct 21, 2021

Conversation

TomHellier
Copy link
Contributor

Slightly restructure the way the ingressURL is created, and the variable which is passed around, and configure the Ingress manifest to work with subpaths

Fixes #1329

This allows me to use the following ingressUrlFormat spark.example.com/sparkjobs/{{$appName}}, and the url
spark.example.com/sparkjobs/spark-pi-1629482011066826445 now displays the spark ui correctly.

@TomHellier
Copy link
Contributor Author

TomHellier commented Aug 20, 2021

@liyinan926 would you mind having a look at this when you get a chance? I'm not sure what documentation I should add here, because I consider this more of a bugfix then a new feature

…ble which is passed around, and configure the Ingress manifest to work with subpaths

Signed-off-by: Tom Hellier <me@tomhellier.com>
@TomHellier TomHellier force-pushed the 1329-subpaths-with-ingress branch from bf00835 to 6d47b89 Compare August 20, 2021 18:00
@TomHellier
Copy link
Contributor Author

TomHellier commented Aug 23, 2021

I think this also resolves #1259 . The integration test appears to have failed because of some intermittent problem, but I cant seem to trigger a re-run.

helm/kind-action#42 applying this seems to fix the kind issue

@TomHellier TomHellier force-pushed the 1329-subpaths-with-ingress branch 3 times, most recently from d2cb1f0 to 96c4129 Compare August 25, 2021 10:29
ingressURL, err := getSparkUIingressURL(c.ingressURLFormat, app.GetName(), app.GetNamespace())
if err != nil {
glog.Errorf("failed to run get ingress url %s/%s: %v", app.Namespace, app.Name, err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

An else should be used here as the code below should only be run if err == nil.

if err != nil {
return nil, err
}
var ingressURLPath = ingressURL.Path
Copy link
Collaborator

Choose a reason for hiding this comment

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

ingressURLPath := ingressURI.Path

}
var ingressURLPath = ingressURL.Path
// If we're serving on a subpath, we need to ensure we create capture groups
if ingressURL.Path != "" && ingressURL.Path != "/" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ingressURLPath here.

@@ -115,11 +120,19 @@ func createSparkUIIngress(app *v1beta2.SparkApplication, service SparkService, i
if len(ingressResourceAnnotations) != 0 {
ingress.ObjectMeta.Annotations = ingressResourceAnnotations
}

// If we're serving on a subpath, we need to ensure we use the capture groups
if ingressURL.Path != "" && ingressURL.Path != "/" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto, use ingressURLPath .

@@ -542,7 +554,10 @@ func TestCreateSparkUIIngress(t *testing.T) {
app: app1,
expectedIngress: SparkIngress{
ingressName: fmt.Sprintf("%s-ui-ingress", app1.GetName()),
ingressURL: "ingress.clusterName.com/" + app1.GetNamespace() + "/" + app1.GetName(),
ingressURL: parseURLAndAssertError("ingress.clusterName.com/"+app1.GetNamespace()+"/"+app1.GetName(), t),

Choose a reason for hiding this comment

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

do you know if this will also work when there is no hostname, eg:

ingressUrlFormat="/{{$appNamespace}}/{{$appName}}"

Choose a reason for hiding this comment

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

I tried this in the test and looks like it does! 🎉

app.Spec.SparkConf = make(map[string]string)
}
app.Spec.SparkConf["spark.ui.proxyBase"] = ingressURL.Path
app.Spec.SparkConf["spark.ui.proxyRedirectUri"] = "/"

Choose a reason for hiding this comment

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

might be worth covering this in a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've written a test which covers this (sort of)... however, it looks like when I'm writing to SparkConf here, the contents of SparkConf isn't written back to the kubernetes resource. I'm unsure whether it is worth syncing this contents back to the SparkApplication when this has been done

…e subpath condition, and protect against empty paths

Signed-off-by: Tom Hellier <me@tomhellier.com>
@TomHellier TomHellier force-pushed the 1329-subpaths-with-ingress branch from 96c4129 to e3b0b5e Compare August 31, 2021 16:29
Copy link

@tekumara tekumara left a comment

Choose a reason for hiding this comment

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

🥳

@karpoftea
Copy link
Contributor

i'm really missing this feature! can we merge it?

@liyinan926 liyinan926 merged commit 9a85d4b into kubeflow:master Oct 21, 2021
@TomHellier TomHellier deleted the 1329-subpaths-with-ingress branch November 17, 2021 21:34
jbhalodia-slack pushed a commit to jbhalodia-slack/spark-operator that referenced this pull request Oct 4, 2024
…he spark ui ingress. (kubeflow#1330)

* Slightly restructure the way the ingressURL is created, and the variable which is passed around, and configure the Ingress manifest to work with subpaths

Signed-off-by: Tom Hellier <me@tomhellier.com>

* fix kubeflow#1329 unit tests now capture groups are being added in the subpath condition, and protect against empty paths

Signed-off-by: Tom Hellier <me@tomhellier.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using an Ingress created by the operator with subPaths fail
4 participants