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

[KubeIngressProxy] Add reuse_existing_services option #656

Merged
merged 1 commit into from Mar 23, 2023

Conversation

dolfinus
Copy link
Contributor

@dolfinus dolfinus commented Oct 22, 2022

If KubeSpawner.services_enabled option is set to True, KubeIngressProxy will get target URL in a form http://jupyterhub-user--servername.pod-namespace.svc.cluster.local:8888, but instead of reusing the existing service it creates ExternalName pointing to jupyterhub-user--servername.pod-namespace.svc.cluster.local DNS name.

Sometimes it is useful, for example if pod is created in another namespace, and there is no way to create Ingress with rule pointing to another namespace.
But in other cases ExternalName is redundant, and may cause errors. In my case, ingress paths with ExternalName are quire unstable, 50% of runs end with an error "500 Redirect loop detected". k8s documentation says You may have trouble using ExternalName for some common protocols, including HTTP and HTTPS.

Here I've added a special case for make_ingress - if target is a valid k8s service name, and it has the same namespace as ingress, Ingress -> External -> Service is reduced to Ingress -> Service, and Service is reused instead of creating new one.
This behavior is activated by option KubeIngressProxy.reuse_existing_services=True, which is disabled by default to avoid backward compatibility issues.

@dolfinus dolfinus force-pushed the ingress_use_existing_service branch 3 times, most recently from 694c2c9 to 88534e9 Compare October 24, 2022 09:11
@dolfinus dolfinus changed the title [KubeIngressProxy] Reuse service created by KubeSpawner.services_enabled [KubeIngressProxy] Add reuse_existing_services option Oct 24, 2022
@consideRatio consideRatio added KubeIngressProxy KubeIngressProxy is a separate class from KubeSpawner! new labels Nov 6, 2022
@dolfinus dolfinus force-pushed the ingress_use_existing_service branch 2 times, most recently from 91587f6 to 5a5f5c0 Compare November 8, 2022 11:41
@dolfinus dolfinus force-pushed the ingress_use_existing_service branch 4 times, most recently from f3b406b to 6e21354 Compare November 11, 2022 08:23
@consideRatio
Copy link
Member

This behavior is activated by option KubeIngressProxy.reuse_existing_services=True, which is disabled by default to avoid backward compatibility issues.

Next release is a major version of KubeSpawner, and I think you have worked KubeIngressProxy significantly so that it could be fine to include a breaking change. Is this behavior the better default in your mind? If so, maybe we should switch to it.

@dolfinus
Copy link
Contributor Author

dolfinus commented Nov 11, 2022

Well, I'm not sure it this issue with accessing Service from ExternalName is related only to my k8s instance or it is a common behavior. It's better to wait for other users to use this option before changing the defaults.

@consideRatio consideRatio merged commit 70b65b2 into jupyterhub:main Mar 23, 2023
@consideRatio
Copy link
Member

Thank you @dolfinus!!! Sorry for the slow turnaround on reviewing your work

@dolfinus dolfinus deleted the ingress_use_existing_service branch March 23, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KubeIngressProxy KubeIngressProxy is a separate class from KubeSpawner! new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants