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

extending ingress url format #1008

Merged
merged 3 commits into from
Sep 16, 2020

Conversation

jinxingwang
Copy link
Contributor

@jinxingwang jinxingwang commented Aug 28, 2020

Issue created: #1007

@jinxingwang jinxingwang force-pushed the new-ingress-url-format branch 3 times, most recently from b0102e7 to e06454c Compare August 31, 2020 17:54
@jinxingwang jinxingwang force-pushed the new-ingress-url-format branch from e06454c to 9a24da6 Compare August 31, 2020 18:19
@gongx
Copy link
Contributor

gongx commented Aug 31, 2020

@jinxingwang We might have the backward compatibility issue since the ingress URL format has been changed.
@liyinan926 Thoughts?

@jinxingwang
Copy link
Contributor Author

There should be no backward compatibility issue, I only extended the feature.

@gongx
Copy link
Contributor

gongx commented Sep 1, 2020

@liyinan926 Please review this PR.

@jinxingwang
Copy link
Contributor Author

@liyinan926 Please take look again, thanks!

@jacobhjkim
Copy link
Contributor

Hi, awesome PR. I was going to do this myself. Just a question, why does the CRD change so much?

@jinxingwang
Copy link
Contributor Author

@jacobhjkim Thanks. I think the CRD change may due to the previous PRs that didn't have it up to date.
If you are also trying to bind multiple spark UI under the same URL look up the settings needed here:
https://stackoverflow.com/questions/56368948/change-root-path-for-spark-web-ui

Copy link
Collaborator

@liyinan926 liyinan926 left a comment

Choose a reason for hiding this comment

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

LGTM with one question.

if err != nil {
return nil, err
}
if parsedURL.Scheme == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still trying to understand why do you need this second Parse()? How does ingressURL look like typically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to solve the problem where URL parser can't parse the host & path correctly when there is no schema, so I am using the parser to check if the URL has a schema, if not add a schema to parse.

@liyinan926 liyinan926 merged commit 664a69d into kubeflow:master Sep 16, 2020
@jinxingwang jinxingwang deleted the new-ingress-url-format branch September 16, 2020 16:18
@jinxingwang
Copy link
Contributor Author

jinxingwang commented Sep 16, 2020 via email

@kishorviswanathan
Copy link

kishorviswanathan commented Oct 19, 2020

@jinxingwang Great work here. I also wanted to use path based routing instead of DNS based for the spark jobs. But I can't get it working. I am getting redirected to the /jobs path.

@jacobhjkim Thanks. I think the CRD change may due to the previous PRs that didn't have it up to date.
If you are also trying to bind multiple spark UI under the same URL look up the settings needed here:
https://stackoverflow.com/questions/56368948/change-root-path-for-spark-web-ui

I saw your comment here, but still can't figure out how to do it with spark-on-k8s-operator. Can you please elaborate a little and possibly include the instructions in the User Guide ?

@jinxingwang
Copy link
Contributor Author

@kishorv06 Hi, I am happy to help you with the spark UI work.
on my StackOverflow post.
step 1 will be a sparkapplication spec change to add a sparkconfig spark.ui.proxyBase: /foo
Like this: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/cf3446097f47047ab46a076ebdb1f71ee9428f84/docs/user-guide.md#specifying-spark-configuration

step2: will be sparkapplicaiton spec change to add annotation on the ingress when it is created
doc here: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/bd1b7ec1f20d9a8bd991ddb335b908fab2cc3316/manifest/crds/sparkoperator.k8s.io_sparkapplications.yaml#L3653

step3: same as step 2, add the annotation to the ingress.

Let me know if this is helping, the doc on how to get spark UI works, in my opinion, don't really belong to here, because spark operator is mostly config how spark works. it should be engineer's chose how they want to config sparkApplication to config spark to work base on their specific cases.
That's why spark operator only docs on you can config these, but don't really care how to get it working.

@kishorviswanathan
Copy link

Hi @jinxingwang, I followed your suggestion, but it is causing too many redirects. These are my configuration.
Application:

  sparkConf:
    spark.ui.proxyBase: /foo
  sparkUIOptions:
    ingressAnnotations:
      nginx.ingress.kubernetes.io/proxy-redirect-from: http://$host/
      nginx.ingress.kubernetes.io/proxy-redirect-to: http://$host/foo/
      nginx.ingress.kubernetes.io/rewrite-target: /$2

Spark operator:

ingressUrlFormat: "example.com/foo"

Result:

curl -vvv "http://example.com/foo/jobs"
*   Trying 192.168.2.102:80...
* TCP_NODELAY set
* Connected to example.com (192.168.2.102) port 80 (#0)
> GET /foo/jobs HTTP/1.1
> Host: example.com
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Server: nginx/1.17.10
< Date: Tue, 20 Oct 2020 06:54:19 GMT
< Content-Length: 0
< Connection: keep-alive
< Cache-Control: no-cache, no-store, must-revalidate
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Location: http://example.com/foo/jobs/
< 
* Connection #0 to host example.com left intact

Thanks in advance.

@kishorviswanathan
Copy link

After a lot of trial and error, finally got the path based routing to work on spark-operator. These are the configurations I have used.
Spark operator:

ingressUrlFormat: "example.com/foo(/|$)(.*)"

Spark Application:

  sparkConf:
    spatk.ui.proxyRedirectUri: http://example.com
    spark.ui.proxyBase: /foo
  sparkUIOptions:
    ingressAnnotations:
      nginx.ingress.kubernetes.io/rewrite-target: /$2

Note: Executor tab is empty. I think it is a known bug as mentioned here: jupyterhub/jupyter-server-proxy#57 (comment)

@jinxingwang
Copy link
Contributor Author

Nice, I guess I had an assumption which you have Nginx installed. that's where ```

  nginx.ingress.kubernetes.io/proxy-redirect-from: http://$host/
  nginx.ingress.kubernetes.io/proxy-redirect-to: http://$host/foo/
being useful. 

@andyzheung
Copy link

andyzheung commented Sep 1, 2022

@kishorv06 Hi, I am happy to help you with the spark UI work. on my StackOverflow post. step 1 will be a sparkapplication spec change to add a sparkconfig spark.ui.proxyBase: /foo Like this: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/cf3446097f47047ab46a076ebdb1f71ee9428f84/docs/user-guide.md#specifying-spark-configuration

step2: will be sparkapplicaiton spec change to add annotation on the ingress when it is created doc here:

https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/bd1b7ec1f20d9a8bd991ddb335b908fab2cc3316/manifest/crds/sparkoperator.k8s.io_sparkapplications.yaml#L3653

step3: same as step 2, add the annotation to the ingress.

Let me know if this is helping, the doc on how to get spark UI works, in my opinion, don't really belong to here, because spark operator is mostly config how spark works. it should be engineer's chose how they want to config sparkApplication to config spark to work base on their specific cases. That's why spark operator only docs on you can config these, but don't really care how to get it working.

Hi, I am try to use kong as ingress-controller,and follow this guide, but seem can't work..
Is any suggestion? @jinxingwang @kishorv06
1、operator:
ingressUrlFormat: "spark-ui.private-cloud.xxx.com/sparkjob(/|$)(.*)"
2、sparkapplication:
sparkConf:
spatk.ui.proxyRedirectUri: http://spark-ui.private-cloud.xxx.com
spark.ui.proxyBase: /sparkjob
sparkUIOptions:
ingressAnnotations:
konghq.com/strip-path: "true"
kubernetes.io/ingress.class: "kong"
#nginx.ingress.kubernetes.io/rewrite-target: /spark-pi

but apply, get the ingress i find:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
konghq.com/strip-path: "true"
kubernetes.io/ingress.class: kong
nginx.ingress.kubernetes.io/rewrite-target: /$2
.....
spec:
rules:

  • host: spark-ui.private-cloud.xxx.com
    http:
    paths:
    • backend:
      service:
      name: spark-pi-ui-svc
      port:
      number: 4040
      path: /sparkjob(/|$)(.)(/|$)(.)
      pathType: ImplementationSpecific

jbhalodia-slack pushed a commit to jbhalodia-slack/spark-operator that referenced this pull request Oct 4, 2024
* init

* add test case & documentation.

* add additional on url
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.

6 participants