Skip to content

Commit b2571d9

Browse files
committed
setup virtualservice to route traffic for workspaces
- Update the helper func with CopyDeepVirtualService Signed-off-by: Harshad Reddy Nalla <[email protected]>
1 parent 12c994f commit b2571d9

File tree

17 files changed

+292
-16
lines changed

17 files changed

+292
-16
lines changed

workspaces/backend/internal/models/workspaces/funcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func buildServices(ws *kubefloworgv1beta1.Workspace, wskPodTemplatePorts map[kub
359359
case kubefloworgv1beta1.ImagePortProtocolHTTP:
360360
services[i].HttpService = &HttpService{
361361
DisplayName: ptr.Deref(port.DisplayName, wskPort.DefaultDisplayName),
362-
HttpPath: fmt.Sprintf("/workspace/%s/%s/%s/", ws.Namespace, ws.Name, port.Id),
362+
HttpPath: fmt.Sprintf("/workspace/connect/%s/%s/%s/", ws.Namespace, ws.Name, port.Id),
363363
}
364364
}
365365
}

workspaces/controller/api/v1beta1/workspacekind_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ type WorkspaceKindVolumeMounts struct {
279279

280280
type HTTPProxy struct {
281281
// if the path prefix is stripped from incoming HTTP requests
282-
// - if true, the '/workspace/{profile_name}/{workspace_name}/' path prefix
282+
// - if true, the '/workspace/connect/{profile_name}/{workspace_name}/' path prefix
283283
// is stripped from incoming requests, the application sees the request
284284
// as if it was made to '/...'
285285
// - this only works if the application serves RELATIVE URLs for its assets
@@ -291,7 +291,7 @@ type HTTPProxy struct {
291291
// - sets the `spec.http[].headers.request` of the Istio VirtualService
292292
// https://istio.io/latest/docs/reference/config/networking/virtual-service/#Headers-HeaderOperations
293293
// - the following string templates are available:
294-
// - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
294+
// - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/connect/{profile_name}/{workspace_name}/')
295295
// +kubebuilder:validation:Optional
296296
RequestHeaders *IstioHeaderOperations `json:"requestHeaders,omitempty"`
297297
}

workspaces/controller/cmd/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
// to ensure that exec-entrypoint and run can make use of them.
2626
_ "k8s.io/client-go/plugin/pkg/client/auth"
2727

28+
istiov1 "istio.io/client-go/pkg/apis/networking/v1"
2829
"k8s.io/apimachinery/pkg/runtime"
2930
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3031
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -50,6 +51,8 @@ var (
5051
func init() {
5152
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5253

54+
utilruntime.Must(istiov1.AddToScheme(scheme))
55+
5356
utilruntime.Must(kubefloworgv1beta1.AddToScheme(scheme))
5457
// +kubebuilder:scaffold:scheme
5558
}

workspaces/controller/config/crd/bases/kubeflow.org_workspacekinds.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,7 +3699,7 @@ spec:
36993699
default: false
37003700
description: |-
37013701
if the path prefix is stripped from incoming HTTP requests
3702-
- if true, the '/workspace/{profile_name}/{workspace_name}/' path prefix
3702+
- if true, the '/workspace/connect/{profile_name}/{workspace_name}/' path prefix
37033703
is stripped from incoming requests, the application sees the request
37043704
as if it was made to '/...'
37053705
- this only works if the application serves RELATIVE URLs for its assets
@@ -3710,7 +3710,7 @@ spec:
37103710
- sets the `spec.http[].headers.request` of the Istio VirtualService
37113711
https://istio.io/latest/docs/reference/config/networking/virtual-service/#Headers-HeaderOperations
37123712
- the following string templates are available:
3713-
- `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
3713+
- `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/connect/{profile_name}/{workspace_name}/')
37143714
properties:
37153715
add:
37163716
additionalProperties:

workspaces/controller/config/manager/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ labels:
88
pairs:
99
app.kubernetes.io/component: controller-manager
1010

11+
configMapGenerator:
12+
- envs:
13+
- params.env
14+
name: config
15+
generatorOptions:
16+
disableNameSuffixHash: true
1117
images:
1218
- name: workspaces-controller
1319
newName: ghcr.io/kubeflow/notebooks/workspaces-controller

workspaces/controller/config/manager/manager.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ spec:
5454
- --health-probe-bind-address=:8081
5555
- --metrics-bind-address=0
5656
image: workspaces-controller:latest
57+
env:
58+
- name: USE_ISTIO
59+
valueFrom:
60+
configMapKeyRef:
61+
name: config
62+
key: USE_ISTIO
63+
- name: ISTIO_GATEWAY
64+
valueFrom:
65+
configMapKeyRef:
66+
name: config
67+
key: ISTIO_GATEWAY
68+
- name: ISTIO_HOST
69+
valueFrom:
70+
configMapKeyRef:
71+
name: config
72+
key: ISTIO_HOST
5773
imagePullPolicy: IfNotPresent
5874
name: manager
5975
securityContext:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
USE_ISTIO=true
2+
ISTIO_GATEWAY=kubeflow/kubeflow-gateway
3+
ISTIO_HOST=*
4+
CLUSTER_DOMAIN=cluster.local

workspaces/controller/config/samples/jupyterlab_v1beta1_workspacekind.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ spec:
153153
httpProxy:
154154

155155
## if the path prefix is stripped from incoming HTTP requests
156-
## - if true, the '/workspace/{profile_name}/{workspace_name}/' path prefix
156+
## - if true, the '/workspace/connect/{profile_name}/{workspace_name}/' path prefix
157157
## is stripped from incoming requests, the application sees the request
158158
## as if it was made to '/...'
159159
## - this only works if the application serves RELATIVE URLs for its assets
@@ -164,7 +164,7 @@ spec:
164164
## - sets the `spec.http[].headers.request` of the Istio VirtualService
165165
## https://istio.io/latest/docs/reference/config/networking/virtual-service/#Headers-HeaderOperations
166166
## - the following string templates are available:
167-
## - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
167+
## - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/connect/{profile_name}/{workspace_name}/')
168168
##
169169
requestHeaders: {}
170170
#set: { "X-RStudio-Root-Path": "{{ .PathPrefix }}" } # for RStudio

workspaces/controller/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ require (
77
github.com/onsi/ginkgo/v2 v2.19.0
88
github.com/onsi/gomega v1.33.1
99
golang.org/x/time v0.3.0
10+
istio.io/api v1.22.8
11+
istio.io/client-go v1.22.8
1012
k8s.io/api v0.31.0
1113
k8s.io/apimachinery v0.31.0
1214
k8s.io/client-go v0.31.0
@@ -59,6 +61,7 @@ require (
5961
golang.org/x/text v0.16.0 // indirect
6062
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
6163
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
64+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
6265
google.golang.org/protobuf v1.34.2 // indirect
6366
gopkg.in/inf.v0 v0.9.1 // indirect
6467
gopkg.in/yaml.v2 v2.4.0 // indirect

workspaces/controller/go.sum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
99
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1010
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
1111
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
12-
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
13-
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
12+
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
13+
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
1414
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
1515
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
1616
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
@@ -155,6 +155,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
155155
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
156156
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
157157
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
158+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
159+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
158160
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
159161
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
160162
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -170,6 +172,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
170172
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
171173
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
172174
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
175+
istio.io/api v1.22.8 h1:mhkaeFJ13WZ2d6pvL9+exNeQ9UB6HX7e6m+XwO9XoYY=
176+
istio.io/api v1.22.8/go.mod h1:S3l8LWqNYS9yT+d4bH+jqzH2lMencPkW7SKM1Cu9EyM=
177+
istio.io/client-go v1.22.8 h1:wojmt220jSbfhpRDsPiflj2nSFTBuYtZNiW9hqKeaWE=
178+
istio.io/client-go v1.22.8/go.mod h1:noO8SoyMxLwni3w+yGK67aydi2klExjmiqnXyeRS/00=
173179
k8s.io/api v0.31.0 h1:b9LiSjR2ym/SzTOlfMHm1tr7/21aD7fSkqgD/CVJBCo=
174180
k8s.io/api v0.31.0/go.mod h1:0YiFF+JfFxMM6+1hQei8FY8M7s1Mth+z/q7eF1aJkTE=
175181
k8s.io/apiextensions-apiserver v0.31.0 h1:fZgCVhGwsclj3qCw1buVXCV6khjRzKC5eCFt24kyLSk=

0 commit comments

Comments
 (0)