forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'opendatahub-io:main' into task/RHOAIENG-7076-optimize-h…
…ow-we-fetch-for-pipeline-experiments
- Loading branch information
Showing
9 changed files
with
130 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,18 @@ | ||
import httpProxy from '@fastify/http-proxy'; | ||
import { KubeFastifyInstance } from '../../../../types'; | ||
import { DEV_MODE, MODEL_REGISTRY_NAMESPACE } from '../../../../utils/constants'; | ||
import { getParam, setParam } from '../../../../utils/proxy'; | ||
import { MODEL_REGISTRY_NAMESPACE } from '../../../../utils/constants'; | ||
import { proxyService } from '../../../../utils/proxy'; | ||
|
||
export default async (fastify: KubeFastifyInstance): Promise<void> => { | ||
fastify.register(httpProxy, { | ||
upstream: '', | ||
prefix: '/:name', | ||
rewritePrefix: '', | ||
replyOptions: { | ||
// preHandler must set the `upstream` param | ||
getUpstream: (request) => getParam(request, 'upstream'), | ||
}, | ||
preHandler: (request, _, done) => { | ||
const name = getParam(request, 'name'); | ||
|
||
const upstream = DEV_MODE | ||
? // Use port forwarding for local development: | ||
// kubectl port-forward -n <namespace> svc/<service-name> <local.port>:<service.port> | ||
`http://${process.env.MODEL_REGISTRY_SERVICE_HOST}:${process.env.MODEL_REGISTRY_SERVICE_PORT}` | ||
: // Construct service URL | ||
`http://${name}.${MODEL_REGISTRY_NAMESPACE}.svc.cluster.local:8080`; | ||
|
||
// assign the `upstream` param so we can dynamically set the upstream URL for http-proxy | ||
setParam(request, 'upstream', upstream); | ||
|
||
fastify.log.info(`Proxy ${request.method} request ${request.url} to ${upstream}`); | ||
done(); | ||
}, | ||
}); | ||
}; | ||
export default proxyService( | ||
null, | ||
{ | ||
port: 8080, | ||
namespace: MODEL_REGISTRY_NAMESPACE, | ||
}, | ||
{ | ||
// Use port forwarding for local development: | ||
// kubectl port-forward -n odh-model-registries svc/<service-name> 8085:8080 | ||
host: process.env.MODEL_REGISTRY_SERVICE_HOST, | ||
port: process.env.MODEL_REGISTRY_SERVICE_PORT, | ||
}, | ||
null, | ||
false, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ODH_DASHBOARD_URL: "http://odh-dashboard-opendatahub.apps.my-cluster.test.redhat.com" | ||
TEST_USER: | ||
AUTH_TYPE: foo-auth | ||
USERNAME: foo-user | ||
PASSWORD: foo-passwd | ||
OCP_ADMIN_USER: | ||
AUTH_TYPE: adm-auth | ||
USERNAME: adminuser | ||
PASSWORD: adminuser-passwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters