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

add tensorboard routing rule #143

Merged
merged 5 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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