[KubeIngressProxy] Add reuse_existing_services option #656
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.
If
KubeSpawner.services_enabled
option is set toTrue
,KubeIngressProxy
will get target URL in a formhttp://jupyterhub-user--servername.pod-namespace.svc.cluster.local:8888
, but instead of reusing the existing service it creates ExternalName pointing tojupyterhub-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 saysYou may have trouble using ExternalName for some common protocols, including HTTP and HTTPS
.Here I've added a special case for
make_ingress
- iftarget
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.