Skip to content

Commit 000933c

Browse files
Skip adding namespace suffix to VirtualService if it already exists (#45)
Co-authored-by: Harsimran Singh Maan <maan.harry@gmail.com>
1 parent 99cb033 commit 000933c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: proxy/create.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ func (i *IstioClient) createVirtualService(r route) error {
4343
return err
4444
}
4545
destinationHost, destinationPort := r.splitTarget()
46-
destinationHost = fmt.Sprintf("%s.%s.svc.%s", destinationHost, i.namespace, i.clusterDomain)
46+
47+
// If the destinationHost already has its complete fqdn we don't need to append namespace of the hub, service and cluster domain again.
48+
// This could be the case if the notebook pod is running in an other namespace than the hub pod
49+
// and c.KubeSpawner.pod_connect_ip needs to be set to something like "jupyter-{username}.<target-namespace-of-notebook>.svc.cluster.local"
50+
if !strings.HasSuffix(destinationHost, fmt.Sprintf(".svc.%s", i.clusterDomain)) {
51+
destinationHost = fmt.Sprintf("%s.%s.svc.%s", destinationHost, i.namespace, i.clusterDomain)
52+
}
53+
4754
vsName := i.virtualServiceNameWithPrefix(r.RouteSpec)
4855
vs := virtualService(vsName, i.gateway, i.host, destinationHost, destinationPort, r.RouteSpec, annotations)
4956

0 commit comments

Comments
 (0)