Skip to content

Commit

Permalink
add tensorboard routing rule (#143)
Browse files Browse the repository at this point in the history
* add tensorboard routing rule

* rename tb routing rule

* address comments

* remove debugger

* fix url prefix
  • Loading branch information
IronPan committed Nov 8, 2018
1 parent 26381f3 commit c2c3136
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/server/proxy-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function _routePathWithReferer(proxyPrefix: string, path: string, referer
// just trim out the /_proxy/ prefix. Use the origin of the resulting URL.
const proxiedUrlInReferer = _extractUrlFromReferer(proxyPrefix, referer);
let decodedPath =
decodeURIComponent(proxiedUrlInReferer || _trimProxyPrefix(proxyPrefix, path));
decodeURIComponent(proxiedUrlInReferer || _trimProxyPrefix(proxyPrefix, path));
if (!decodedPath.startsWith('http://') && !decodedPath.startsWith('https://')) {
decodedPath = 'http://' + decodedPath;
}
Expand All @@ -57,8 +57,11 @@ export default (app: express.Application, apisPrefix: string) => {
if (req.headers.referer) {
const refererUrl = _extractUrlFromReferer(proxyPrefix, req.headers.referer as string);
if (refererUrl && req.url.indexOf(proxyPrefix) !== 0) {
const proxiedUrl = decodeURIComponent(
_extractUrlFromReferer(proxyPrefix, req.headers.referer as string));
let proxiedUrl = decodeURIComponent(
_extractUrlFromReferer(proxyPrefix, req.headers.referer as string));
if (!proxiedUrl.startsWith('http://') && !proxiedUrl.startsWith('https://')) {
proxiedUrl = 'http://' + proxiedUrl;
}
const proxiedOrigin = new URL(proxiedUrl).origin;
req.url = proxyPrefix + encodeURIComponent(proxiedOrigin + req.url);
}
Expand Down
41 changes: 41 additions & 0 deletions ml-pipeline/ml-pipeline/pipeline-ui.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
all(namespace, ui_image):: [
$.parts(namespace).serviceAccount,
$.parts(namespace).serviceUi,
$.parts(namespace).tensorboardData,
$.parts(namespace).roleBinding,
$.parts(namespace).role,
$.parts(namespace).deployUi(ui_image),
Expand Down Expand Up @@ -56,6 +57,46 @@
},
}, //serviceUi

tensorboardData: {
apiVersion: "v1",
kind: "Service",
metadata: {
labels: {
app: "ml-pipeline-tensorboard-ui",
},
name: "ml-pipeline-tensorboard-ui",
namespace: namespace,
annotations: {
"getambassador.io/config":
std.join("\n", [
"---",
"apiVersion: ambassador/v0",
"kind: Mapping",
"name: pipeline-tensorboard-ui-mapping",
"prefix: /data",
"rewrite: /data",
"timeout_ms: 300000",
"service: ml-pipeline-ui." + namespace,
"use_websocket: true",
]),
}, //annotations
},
spec: {
ports: [
{
port: 80,
targetPort: 3000,
},
],
selector: {
app: "ml-pipeline-tensorboard-ui",
},
},
status: {
loadBalancer: {}
},
}, //tensorboardData

roleBinding:: {
apiVersion: "rbac.authorization.k8s.io/v1beta1",
kind: "RoleBinding",
Expand Down

0 comments on commit c2c3136

Please sign in to comment.